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_cone_search(unittest.TestCase): 

43 

44 def test_cone_search_function(self): 

45 

46 from sloancone.cone_search import cone_search 

47 this = cone_search( 

48 log=log, 

49 ra="12:45:23.2323", 

50 dec="30.343122", 

51 searchRadius=60., 

52 nearest=True, 

53 outputFormat="table", 

54 galaxyType="all" 

55 ) 

56 print(this.get()) 

57 

58 from sloancone.cone_search import cone_search 

59 this = cone_search( 

60 log=log, 

61 ra="12:45:23.2323", 

62 dec="30.343122", 

63 searchRadius=60., 

64 nearest=False, 

65 outputFormat="table", 

66 galaxyType="all" 

67 ) 

68 print(this.get()) 

69 

70 def test_cone_search_function2(self): 

71 

72 from sloancone.cone_search import cone_search 

73 this = cone_search( 

74 log=log, 

75 ra="112.233432", 

76 dec="15:34:31.22", 

77 searchRadius=60., 

78 nearest=True, 

79 outputFormat="table", 

80 galaxyType="all" 

81 ) 

82 print(this.get()) 

83 

84 from sloancone.cone_search import cone_search 

85 this = cone_search( 

86 log=log, 

87 ra="112.233432", 

88 dec="15:34:31.22", 

89 searchRadius=60., 

90 nearest=False, 

91 outputFormat="table", 

92 galaxyType="all" 

93 ) 

94 print(this.get()) 

95 

96 def test_cone_search_function3(self): 

97 

98 from sloancone.cone_search import cone_search 

99 this = cone_search( 

100 log=log, 

101 ra="112.233432", 

102 dec="15:34:31.22", 

103 searchRadius=60., 

104 nearest=True, 

105 outputFormat="csv", 

106 galaxyType="all" 

107 ) 

108 print(this.get()) 

109 

110 from sloancone.cone_search import cone_search 

111 this = cone_search( 

112 log=log, 

113 ra="112.233432", 

114 dec="15:34:31.22", 

115 searchRadius=60., 

116 nearest=False, 

117 outputFormat="csv", 

118 galaxyType="all" 

119 ) 

120 print(this.get()) 

121 

122 def test_cone_search_function4(self): 

123 

124 from sloancone.cone_search import cone_search 

125 csResults = cone_search( 

126 log=log, 

127 ra="12:45:23.2323", 

128 dec="30.343122", 

129 searchRadius=600., 

130 nearest=False, 

131 outputFormat="table", 

132 galaxyType="specz" 

133 ).get() 

134 

135 print(csResults) 

136 

137 def test_cone_search_function5(self): 

138 

139 from sloancone.cone_search import cone_search 

140 csResults = cone_search( 

141 log=log, 

142 ra="12:45:23.2323", 

143 dec="30.343122", 

144 searchRadius=60., 

145 nearest=False, 

146 outputFormat="table", 

147 galaxyType=False 

148 ).get() 

149 

150 print(csResults) 

151 

152 def test_cone_search_function_exception(self): 

153 

154 from sloancone.cone_search import cone_search 

155 try: 

156 this = cone_search( 

157 log=log, 

158 fakeKey="break the code" 

159 ) 

160 this.get() 

161 assert False 

162 except Exception as e: 

163 assert True 

164 print(str(e)) 

165 

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

167 

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