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

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
1from __future__ import print_function
2from builtins import str
3import os
4import unittest
5import shutil
6import unittest
7import yaml
8from soxspipe.utKit import utKit
9from fundamentals import tools
10from os.path import expanduser
11home = expanduser("~")
13packageDirectory = utKit("").get_project_root()
14settingsFile = packageDirectory + "/test_settings.yaml"
15# settingsFile = home + \
16# "/git_repos/_misc_/settings/soxspipe/test_settings.yaml"
18su = tools(
19 arguments={"settingsFile": settingsFile},
20 docString=__doc__,
21 logLevel="DEBUG",
22 options_first=False,
23 projectName=None,
24 defaultSettingsFile=False
25)
26arguments, settings, log, dbConn = su.setup()
28# SETUP PATHS TO COMMON DIRECTORIES FOR TEST DATA
29moduleDirectory = os.path.dirname(__file__)
30pathToInputDir = moduleDirectory + "/input/"
31pathToOutputDir = moduleDirectory + "/output/"
33try:
34 shutil.rmtree(pathToOutputDir)
35except:
36 pass
37# COPY INPUT TO OUTPUT DIR
38shutil.copytree(pathToInputDir, pathToOutputDir)
40# Recursively create missing directories
41if not os.path.exists(pathToOutputDir):
42 os.makedirs(pathToOutputDir)
45# xt-setup-unit-testing-files-and-folders
48class test_detector_lookup(unittest.TestCase):
50 def test_detector_lookup_function(self):
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())
60 def test_detector_lookup_get_function(self):
62 from soxspipe.commonutils import detector_lookup
63 detectDict = detector_lookup(
64 log=log,
65 settings=settings
66 ).get("NIR")
67 print(detectDict)
69 detectDict = detector_lookup(
70 log=log,
71 settings=settings
72 ).get("UVB")
73 print(detectDict)
75 detectDict = detector_lookup(
76 log=log,
77 settings=settings
78 ).get("VIS")
79 print(detectDict)
81 # HOW ABOUT LOWERCASE?
82 detectDict = detector_lookup(
83 log=log,
84 settings=settings
85 ).get("nir")
86 print(detectDict)
88 def test_detector_lookup_function_wrong_arm(self):
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))
101 def test_detector_lookup_function_exception(self):
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))
116 # x-print-testpage-for-pessto-marshall-web-object
118 # x-class-to-test-named-worker-function