Coverage for soxspipe/utKit.py: 68%

# Coverage for soxspipe/utKit.py : 68%

## 22 statements 15 run 7 missing 0 excluded

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1"""

2*Unit testing tools*

3"""

4 from fundamentals import utKit

5

6# OVERRIDES

7

8

9 class utKit(utKit):

10

11 """

12 *Override dryx utKit*

13 """

14 # Variable Data Atrributes

15

16 # Override Variable Data Atrributes

17 # Initialisation

18 def __init__(

19 self,

20 moduleDirectory,

21 dbConn=False

22 ):

23 self.moduleDirectory = moduleDirectory

24 # x-self-arg-tmpx

25

26 # SETUP PATHS TO COMMON DIRECTORIES FOR TEST DATA

27 self.pathToInputDir = moduleDirectory + "/input/"

28 self.pathToOutputDir = moduleDirectory + "/output/"

29

30 # SETUP LOGGING

31 self.loggerConfig = """

32 version: 1

33 formatters:

34 file_style:

35 format: '* %(asctime)s - %(name)s - %(levelname)s (%(filename)s > %(funcName)s > %(lineno)d) - %(message)s '

36 datefmt: '%Y/%m/%d %H:%M:%S'

37 console_style:

38 format: '* %(asctime)s - %(levelname)s: %(filename)s:%(funcName)s:%(lineno)d > %(message)s'

39 datefmt: '%H:%M:%S'

40 html_style:

41 format: '<div id="row" class="%(levelname)s"><span class="date">%(asctime)s</span> <span class="label">file:</span><span class="filename">%(filename)s</span> <span class="label">method:</span><span class="funcName">%(funcName)s</span> <span class="label">line#:</span><span class="lineno">%(lineno)d</span> <span class="pathname">%(pathname)s</span> <div class="right"><span class="message">%(message)s</span><span class="levelname">%(levelname)s</span></div></div>'

42 datefmt: '%Y-%m-%d <span class= "time">%H:%M <span class= "seconds">%Ss</span></span>'

43 handlers:

44 console:

45 class: logging.StreamHandler

46 level: DEBUG

47 formatter: console_style

48 stream: ext://sys.stdout

49 root:

50 level: WARNING

51 handlers: [console]"""

52

53 # Override Variable Data Atrributes

54 self.dbConfig = False

55 if dbConn:

56 self.dbConfig = """

57 version: 1

58 db: dryx_unit_testing

59 host: localhost

60 user: unittesting

61 password: utpass

62 """

63

64 return

65

66 def get_project_root(self):

67 """

68 *Get the root of the `python` package - useful for getting files in the root directory of a project*

69

70 **Return:**

71 - ``rootPath`` -- the root path of a project

72 """

73 import os

74 rootPath = os.path.dirname(__file__)

75

76 return rootPath

77

78 def refresh_database(self):

79 """

80 *Refresh the unit test database*

81 """

82 from fundamentals.mysql import directory_script_runner

83 from fundamentals import tools

84 packageDirectory = self.get_project_root()

85 su = tools(

86 arguments={"settingsFile": packageDirectory +

87 "/test_settings.yaml"},

88 docString=__doc__,

89 logLevel="DEBUG",

90 options_first=False,

91 projectName=None,

92 defaultSettingsFile=False

93 )

94 arguments, settings, log, dbConn = su.setup()

95 directory_script_runner(

96 log=log,

97 pathToScriptDirectory=packageDirectory + "/tests/input",

98 dbConn=dbConn,

99 successRule=None,

100 failureRule=None

101 )