Hide keyboard shortcuts

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("~") 

12 

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() 

25 

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() 

31 

32try: 

33 shutil.rmtree(pathToOutputDir) 

34except: 

35 pass 

36# COPY INPUT TO OUTPUT DIR 

37shutil.copytree(pathToInputDir, pathToOutputDir) 

38 

39# Recursively create missing directories 

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

41 os.makedirs(pathToOutputDir) 

42 

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

44 

45 

46class test_soxs_mdark(unittest.TestCase): 

47 

48 def test_soxs_mdark_nir_function(self): 

49 sofPath = "~/xshooter-pipeline-data/unittest_data/xshooter-mdark/sofs/nir_6s_darks.sof" 

50 from soxspipe.recipes import soxs_mdark 

51 this = soxs_mdark( 

52 log=log, 

53 settings=settings, 

54 inputFrames=sofPath 

55 ) 

56 productPath = this.produce_product() 

57 print(f"Here is the final product `{productPath}`") 

58 

59 sofPath = "~/xshooter-pipeline-data/unittest_data/xshooter-mdark/sofs/nir_240s_darks.sof" 

60 from soxspipe.recipes import soxs_mdark 

61 this = soxs_mdark( 

62 log=log, 

63 settings=settings, 

64 inputFrames=sofPath 

65 ) 

66 productPath = this.produce_product() 

67 print(f"Here is the final product `{productPath}`") 

68 

69 sofPath = "~/xshooter-pipeline-data/unittest_data/xshooter-mdark/sofs/nir_125s_darks.sof" 

70 from soxspipe.recipes import soxs_mdark 

71 this = soxs_mdark( 

72 log=log, 

73 settings=settings, 

74 inputFrames=sofPath 

75 ) 

76 productPath = this.produce_product() 

77 print(f"Here is the final product `{productPath}`") 

78 

79 def test_soxs_mdark_uvb_function(self): 

80 

81 sofPath = "~/xshooter-pipeline-data/unittest_data/xshooter-mdark/sofs/uvb_1x1_dark_3600s.sof" 

82 from soxspipe.recipes import soxs_mdark 

83 this = soxs_mdark( 

84 log=log, 

85 settings=settings, 

86 inputFrames=sofPath 

87 ) 

88 productPath = this.produce_product() 

89 print(f"Here is the final product `{productPath}`") 

90 

91 sofPath = "~/xshooter-pipeline-data/unittest_data/xshooter-mdark/sofs/uvb_2x2_dark_3600s.sof" 

92 from soxspipe.recipes import soxs_mdark 

93 this = soxs_mdark( 

94 log=log, 

95 settings=settings, 

96 inputFrames=sofPath 

97 ) 

98 productPath = this.produce_product() 

99 print(f"Here is the final product `{productPath}`") 

100 

101 def test_soxs_mdark_vis_function(self): 

102 sofPath = "~/xshooter-pipeline-data/unittest_data/xshooter-mdark/sofs/vis_1x1_dark_3600s.sof" 

103 from soxspipe.recipes import soxs_mdark 

104 this = soxs_mdark( 

105 log=log, 

106 settings=settings, 

107 inputFrames=sofPath 

108 ) 

109 productPath = this.produce_product() 

110 print(f"Here is the final product `{productPath}`") 

111 

112 sofPath = "~/xshooter-pipeline-data/unittest_data/xshooter-mdark/sofs/vis_2x2_dark_3600s.sof" 

113 from soxspipe.recipes import soxs_mdark 

114 this = soxs_mdark( 

115 log=log, 

116 settings=settings, 

117 inputFrames=sofPath 

118 ) 

119 productPath = this.produce_product() 

120 print(f"Here is the final product `{productPath}`") 

121 

122 # def test_soxs_mdark_function(self): 

123 

124 # # utKit.refresh_database() # reset database to database found in 

125 # # soxspipe/test/input 

126 # from soxspipe.recipes import soxs_mdark 

127 # this = soxs_mdark( 

128 # log=log, 

129 # settings=settings 

130 # ) 

131 # this.get() 

132 

133 def test_soxs_mdark_function_exception(self): 

134 

135 from soxspipe.recipes import soxs_mdark 

136 try: 

137 sofPath = "~/xshooter-pipeline-data/unittest_data/xshooter-mdark/sofs/nir_mixed_exptime_darks.sof" 

138 from soxspipe.recipes import soxs_mdark 

139 this = soxs_mdark( 

140 log=log, 

141 settings=settings, 

142 inputFrames=sofPath 

143 ) 

144 assert False 

145 except Exception as e: 

146 assert True 

147 print(str(e)) 

148 

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

150 

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