Coverage for soxspipe/recipes/tests/test_soxs_disp_solution.py : 92%

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 + "/.config/soxspipe/soxspipe.yaml"
16su = tools(
17 arguments={"settingsFile": settingsFile},
18 docString=__doc__,
19 logLevel="DEBUG",
20 options_first=False,
21 projectName=None,
22 defaultSettingsFile=False
23)
24arguments, settings, log, dbConn = su.setup()
26# SETUP AND TEARDOWN FIXTURE FUNCTIONS FOR THE ENTIRE MODULE
27moduleDirectory = os.path.dirname(__file__)
28utKit = utKit(moduleDirectory)
29log, dbConn, pathToInputDir, pathToOutputDir = utKit.setupModule()
30utKit.tearDownModule()
32try:
33 shutil.rmtree(pathToOutputDir)
34except:
35 pass
36# COPY INPUT TO OUTPUT DIR
37shutil.copytree(pathToInputDir, pathToOutputDir)
39# Recursively create missing directories
40if not os.path.exists(pathToOutputDir):
41 os.makedirs(pathToOutputDir)
44# xt-setup-unit-testing-files-and-folders
47class test_soxs_disp_solution(unittest.TestCase):
49 def test_soxs_disp_solution_nir_function(self):
50 sofPath = "~/xshooter-pipeline-data/unittest_data/xsh/xshooter-disp-solution/sof/20170818_NIR_DISP_SOLUTION.sof"
51 from soxspipe.recipes import soxs_disp_solution
52 disp_map_path = soxs_disp_solution(
53 log=log,
54 settings=settings,
55 inputFrames=sofPath
56 ).produce_product()
57 print(f"Here is the final product `{disp_map_path}`")
59 def test_soxs_disp_solution_uvb_function(self):
61 sofPath = "~/xshooter-pipeline-data/unittest_data/xsh/xshooter-disp-solution/sof/20170818_UVB_DISP_SOLUTION_1x1_fast.sof"
62 from soxspipe.recipes import soxs_disp_solution
63 disp_map_path = soxs_disp_solution(
64 log=log,
65 settings=settings,
66 inputFrames=sofPath
67 ).produce_product()
68 print(f"Here is the final product `{disp_map_path}`")
70 def test_soxs_disp_solution_vis_function(self):
71 sofPath = "~/xshooter-pipeline-data/unittest_data/xsh/xshooter-disp-solution/sof/20170818_VIS_DISP_SOLUTION_1x1_fast.sof"
72 from soxspipe.recipes import soxs_disp_solution
73 disp_map_path = soxs_disp_solution(
74 log=log,
75 settings=settings,
76 inputFrames=sofPath
77 ).produce_product()
78 print(f"Here is the final product `{disp_map_path}`")
80 # def test_soxs_disp_solution_function(self):
82 # # utKit.refresh_database() # reset database to database found in
83 # # soxspipe/test/input
84 # from soxspipe.recipes import soxs_disp_solution
85 # this = soxs_disp_solution(
86 # log=log,
87 # settings=settings
88 # )
89 # this.get()
91 def test_soxs_disp_solution_function_exception(self):
93 from soxspipe.recipes import soxs_disp_solution
94 try:
95 sofPath = "~/xshooter-pipeline-data/unittest_data/xsh/xshooter-mdark/sofs/nir_mixed_exptime_darks.sof"
96 from soxspipe.recipes import soxs_disp_solution
97 this = soxs_disp_solution(
98 log=log,
99 settings=settings,
100 inputFrames=sofPath
101 )
102 assert False
103 except Exception as e:
104 assert True
105 print(str(e))
107 # x-print-testpage-for-pessto-marshall-web-object
109 # x-class-to-test-named-worker-function