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 yaml 

7from sloancone.utKit import utKit 

8from fundamentals import tools 

9from os.path import expanduser 

10home = expanduser("~") 

11 

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

13settingsFile = packageDirectory + "/test_settings.yaml" 

14 

15su = tools( 

16 arguments={"settingsFile": settingsFile}, 

17 docString=__doc__, 

18 logLevel="DEBUG", 

19 options_first=False, 

20 projectName=None, 

21 defaultSettingsFile=False 

22) 

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

24 

25# SETUP PATHS TO COMMON DIRECTORIES FOR TEST DATA 

26moduleDirectory = os.path.dirname(__file__) 

27pathToInputDir = moduleDirectory + "/input/" 

28pathToOutputDir = moduleDirectory + "/output/" 

29 

30try: 

31 shutil.rmtree(pathToOutputDir) 

32except: 

33 pass 

34# COPY INPUT TO OUTPUT DIR 

35shutil.copytree(pathToInputDir, pathToOutputDir) 

36 

37# Recursively create missing directories 

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

39 os.makedirs(pathToOutputDir) 

40 

41 

42class test_image(unittest.TestCase): 

43 

44 def test_image_function(self): 

45 

46 from sloancone import image 

47 this = image( 

48 log=log, 

49 settings=settings, 

50 ra="09:40:50.10", 

51 dec="-09:42:52.7", 

52 downloadDirectory=pathToOutputDir, 

53 filename="test_01.jpeg" 

54 ) 

55 this.get() 

56 

57 def test_image_function02(self): 

58 

59 from sloancone import image 

60 this = image( 

61 log=log, 

62 settings=settings, 

63 ra="179.689293428354", 

64 dec="-0.454379056007667", 

65 downloadDirectory=pathToOutputDir, 

66 filename="test_02.jpeg", 

67 grid=False, 

68 label=False, 

69 photocat=False, 

70 speccat=False, 

71 invertColors=False, 

72 arcminWidth=5, 

73 pixelWidth=500 

74 ) 

75 this.get() 

76 

77 def test_image_function03(self): 

78 

79 from sloancone import image 

80 this = image( 

81 log=log, 

82 settings=settings, 

83 ra="179.689293428354", 

84 dec="-0.454379056007667", 

85 downloadDirectory=pathToOutputDir, 

86 filename="test_03.jpeg", 

87 grid=True, 

88 label=False, 

89 photocat=False, 

90 speccat=False, 

91 invertColors=False, 

92 arcminWidth=5, 

93 pixelWidth=500 

94 ) 

95 this.get() 

96 

97 def test_image_function04(self): 

98 

99 from sloancone import image 

100 this = image( 

101 log=log, 

102 settings=settings, 

103 ra="179.689293428354", 

104 dec="-0.454379056007667", 

105 downloadDirectory=pathToOutputDir, 

106 filename="test_04.jpeg", 

107 grid=False, 

108 label=True, 

109 photocat=False, 

110 speccat=False, 

111 invertColors=False, 

112 arcminWidth=5, 

113 pixelWidth=500 

114 ) 

115 this.get() 

116 

117 def test_image_function05(self): 

118 

119 from sloancone import image 

120 this = image( 

121 log=log, 

122 settings=settings, 

123 ra="179.689293428354", 

124 dec="-0.454379056007667", 

125 downloadDirectory=pathToOutputDir, 

126 filename="test_05.jpeg", 

127 grid=False, 

128 label=False, 

129 photocat=True, 

130 speccat=False, 

131 invertColors=False, 

132 arcminWidth=5, 

133 pixelWidth=500 

134 ) 

135 this.get() 

136 

137 def test_image_function06(self): 

138 

139 from sloancone import image 

140 this = image( 

141 log=log, 

142 settings=settings, 

143 ra="179.689293428354", 

144 dec="-0.454379056007667", 

145 downloadDirectory=pathToOutputDir, 

146 filename="test_06.jpeg", 

147 grid=False, 

148 label=False, 

149 photocat=False, 

150 speccat=True, 

151 invertColors=False, 

152 arcminWidth=5, 

153 pixelWidth=500 

154 ) 

155 this.get() 

156 

157 def test_image_function07(self): 

158 

159 from sloancone import image 

160 this = image( 

161 log=log, 

162 settings=settings, 

163 ra="179.689293428354", 

164 dec="-0.454379056007667", 

165 downloadDirectory=pathToOutputDir, 

166 filename="test_07.jpeg", 

167 grid=False, 

168 label=False, 

169 photocat=False, 

170 speccat=False, 

171 invertColors=True, 

172 arcminWidth=5, 

173 pixelWidth=500 

174 ) 

175 this.get() 

176 

177 def test_image_function08(self): 

178 

179 from sloancone import image 

180 this = image( 

181 log=log, 

182 settings=settings, 

183 ra="179.689293428354", 

184 dec="-0.454379056007667", 

185 downloadDirectory=pathToOutputDir, 

186 filename="test_08.jpeg", 

187 grid=False, 

188 label=False, 

189 photocat=False, 

190 speccat=False, 

191 invertColors=False, 

192 arcminWidth=50, 

193 pixelWidth=500 

194 ) 

195 this.get() 

196 

197 def test_image_function09(self): 

198 

199 from sloancone import image 

200 this = image( 

201 log=log, 

202 settings=settings, 

203 ra="179.689293428354", 

204 dec="-0.454379056007667", 

205 downloadDirectory=pathToOutputDir, 

206 filename="test_09.jpeg", 

207 grid=True, 

208 label=True, 

209 photocat=True, 

210 speccat=True, 

211 invertColors=True, 

212 arcminWidth=5, 

213 pixelWidth=500 

214 ) 

215 this.get() 

216 

217 def test_image_function_exception(self): 

218 

219 from sloancone import image 

220 try: 

221 this = image( 

222 log=log, 

223 settings=settings, 

224 fakeKey="break the code" 

225 ) 

226 this.get() 

227 assert False 

228 except Exception as e: 

229 assert True 

230 print(str(e)) 

231 

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

233 

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