Coverage for soxspipe/commonutils/tests/test_detector_lookup.py: 0%

# Coverage for soxspipe/commonutils/tests/test_detector_lookup.py : 0%

## 58 statements 0 run 58 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 from __future__ import print_function

2 from builtins import str

3 import os

4 import unittest

5 import shutil

6 import unittest

7 import yaml

8 from soxspipe.utKit import utKit

9 from fundamentals import tools

10 from os.path import expanduser

11 home = expanduser("~")

12

13 packageDirectory = utKit("").get_project_root()

14 settingsFile = packageDirectory + "/test_settings.yaml"

15# settingsFile = home + \

16# "/git_repos/_misc_/settings/soxspipe/test_settings.yaml"

17

18 su = tools(

19 arguments={"settingsFile": settingsFile},

20 docString=__doc__,

21 logLevel="DEBUG",

22 options_first=False,

23 projectName=None,

24 defaultSettingsFile=False

25)

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

27

28# SETUP PATHS TO COMMON DIRECTORIES FOR TEST DATA

29 moduleDirectory = os.path.dirname(__file__)

30 pathToInputDir = moduleDirectory + "/input/"

31 pathToOutputDir = moduleDirectory + "/output/"

32

33 try:

34 shutil.rmtree(pathToOutputDir)

35 except:

36 pass

37# COPY INPUT TO OUTPUT DIR

38 shutil.copytree(pathToInputDir, pathToOutputDir)

39

40# Recursively create missing directories

41 if not os.path.exists(pathToOutputDir):

42 os.makedirs(pathToOutputDir)

43

44

45# xt-setup-unit-testing-files-and-folders

46

47

48 class test_detector_lookup(unittest.TestCase):

49

50 def test_detector_lookup_function(self):

51

52 from soxspipe.commonutils import detector_lookup

53 this = detector_lookup(

54 log=log,

55 settings=settings

56 )

57 detectorDict = this._select_dictionary()

58 print(this._select_dictionary())

59

60 def test_detector_lookup_get_function(self):

61

62 from soxspipe.commonutils import detector_lookup

63 detectDict = detector_lookup(

64 log=log,

65 settings=settings

66 ).get("NIR")

67 print(detectDict)

68

69 detectDict = detector_lookup(

70 log=log,

71 settings=settings

72 ).get("UVB")

73 print(detectDict)

74

75 detectDict = detector_lookup(

76 log=log,

77 settings=settings

78 ).get("VIS")

79 print(detectDict)

80

81 # HOW ABOUT LOWERCASE?

82 detectDict = detector_lookup(

83 log=log,

84 settings=settings

85 ).get("nir")

86 print(detectDict)

87

88 def test_detector_lookup_function_wrong_arm(self):

89

90 from soxspipe.commonutils import detector_lookup

91 try:

92 detectDict = detector_lookup(

93 log=log,

94 settings=settings

95 ).get("RUBBISH")

96 assert False

97 except Exception as e:

98 assert True

99 print(str(e))

100

101 def test_detector_lookup_function_exception(self):

102

103 from soxspipe.commonutils import detector_lookup

104 try:

105 this = detector_lookup(

106 log=log,

107 settings=settings,

108 fakeKey="break the code"

109 )

110 this.get()

111 assert False

112 except Exception as e:

113 assert True

114 print(str(e))

115

116 # x-print-testpage-for-pessto-marshall-web-object

117

118 # x-class-to-test-named-worker-function