@@ -48,6 +48,25 @@ def ehst_request(request):
48
48
return mp
49
49
50
50
51
+ def get_cone_mockreturn (method , request , url , params , * args , ** kwargs ):
52
+ file = data_path ('cone_search_m31_5.vot' )
53
+ if 'OBSERVATION_ID' in params :
54
+ file = params ['OBSERVATION_ID' ] + ".vot"
55
+ response = data_path (file )
56
+ shutil .copy (response + '.test' , response )
57
+ return response
58
+
59
+
60
+ @pytest .fixture (autouse = True )
61
+ def ehst_cone_search (request ):
62
+ try :
63
+ mp = request .getfixturevalue ("monkeypatch" )
64
+ except AttributeError : # pytest < 3
65
+ mp = request .getfuncargvalue ("monkeypatch" )
66
+ mp .setattr (ESAHubbleClass , 'cone_search' , get_cone_mockreturn )
67
+ return mp
68
+
69
+
51
70
class TestESAHubble ():
52
71
53
72
def get_dummy_tap_handler (self ):
@@ -101,7 +120,6 @@ def test_query_target(self):
101
120
ehst .query_target (name = parameters ['name' ],
102
121
verbose = parameters ['verbose' ])
103
122
104
- @pytest .mark .remote_data
105
123
def test_cone_search (self ):
106
124
coords = coordinates .SkyCoord ("00h42m44.51s +41d16m08.45s" , frame = 'icrs' )
107
125
@@ -113,7 +131,7 @@ def test_cone_search(self):
113
131
114
132
parameters = {'coordinates' : coords ,
115
133
'radius' : 0.0 ,
116
- 'file_name ' : 'file_cone' ,
134
+ 'filename ' : 'file_cone' ,
117
135
'output_format' : 'votable' ,
118
136
'cache' : True }
119
137
@@ -126,39 +144,35 @@ def test_cone_search(self):
126
144
ehst ._request = MagicMock (return_value = response )
127
145
ehst .cone_search (parameters ['coordinates' ],
128
146
parameters ['radius' ],
129
- parameters ['file_name ' ],
147
+ parameters ['filename ' ],
130
148
parameters ['output_format' ],
131
149
parameters ['cache' ])
132
150
133
- @pytest .mark .remote_data
134
151
def test_cone_search_coords (self ):
135
152
coords = "00h42m44.51s +41d16m08.45s"
136
153
137
154
parameterst = {'query' : "select top 10 * from hsc_v2.hubble_sc2" ,
138
155
'output_file' : "test2.vot" ,
139
156
'output_format' : "votable" ,
140
- 'verbose' : False }
157
+ 'verbose' : True }
141
158
dummyTapHandler = DummyHubbleTapHandler ("launch_job" , parameterst )
142
159
143
160
parameters = {'coordinates' : coords ,
144
161
'radius' : 0.0 ,
145
- 'file_name' : 'file_cone' ,
162
+ 'filename' : 'file_cone' ,
163
+ 'async_job' : False ,
146
164
'output_format' : 'votable' ,
147
165
'cache' : True }
148
166
149
167
ehst = ESAHubbleClass (dummyTapHandler )
150
168
ehst .cone_search (parameters ['coordinates' ],
151
169
parameters ['radius' ],
152
- parameters ['file_name ' ],
170
+ parameters ['filename ' ],
153
171
parameters ['output_format' ],
172
+ parameters ['async_job' ],
154
173
parameters ['cache' ])
155
- parameters [coordinates ] = 1234
156
174
with pytest .raises (ValueError ) as err :
157
- ehst .cone_search (parameters ['coordinates' ],
158
- parameters ['radius' ],
159
- parameters ['file_name' ],
160
- parameters ['output_format' ],
161
- parameters ['cache' ])
175
+ ehst ._getCoordInput (1234 , 'coordinate' )
162
176
assert "coordinate must be either a string or " \
163
177
"astropy.coordinates" in err .value .args [0 ]
164
178
@@ -192,6 +206,10 @@ def test_get_tables(self):
192
206
ehst = ESAHubbleClass (self .get_dummy_tap_handler ())
193
207
ehst .get_tables (True , True )
194
208
209
+ def test_get_artifact (self ):
210
+ ehst = ESAHubbleClass (self .get_dummy_tap_handler ())
211
+ ehst .get_artifact ("w0ji0v01t_c2f.fits.gz" )
212
+
195
213
def test_get_columns (self ):
196
214
parameters = {'query' : "select top 10 * from hsc_v2.hubble_sc2" ,
197
215
'output_file' : "test2.vot" ,
@@ -367,6 +385,37 @@ def test_cone_search_criteria(self):
367
385
verbose = parameters1 ['verbose' ])
368
386
dummy_tap_handler = DummyHubbleTapHandler ("launch_job" , parameters3 )
369
387
dummy_tap_handler .check_call ("launch_job" , parameters3 )
388
+ c = coordinates .SkyCoord ("00h42m44.51s +41d16m08.45s" , frame = 'icrs' )
389
+ ehst .cone_search_criteria (coordinates = c ,
390
+ radius = parameters1 ['radius' ],
391
+ data_product_type = parameters1
392
+ ['data_product_type' ],
393
+ obs_collection = parameters1 ['obs_collection' ],
394
+ instrument_name = parameters1
395
+ ['instrument_name' ],
396
+ filters = parameters1 ['filters' ],
397
+ async_job = parameters1 ['async_job' ],
398
+ filename = parameters1 ['filename' ],
399
+ output_format = parameters1 ['output_format' ],
400
+ verbose = parameters1 ['verbose' ])
401
+ with pytest .raises (TypeError ) as err :
402
+ ehst .cone_search_criteria (target = parameters1 ['target' ],
403
+ coordinates = 123 ,
404
+ radius = parameters1 ['radius' ],
405
+ data_product_type = parameters1
406
+ ['data_product_type' ],
407
+ obs_collection = parameters1
408
+ ['obs_collection' ],
409
+ instrument_name = parameters1
410
+ ['instrument_name' ],
411
+ filters = parameters1 ['filters' ],
412
+ async_job = parameters1 ['async_job' ],
413
+ filename = parameters1 ['filename' ],
414
+ output_format = parameters1
415
+ ['output_format' ],
416
+ verbose = parameters1 ['verbose' ])
417
+ assert "Please use only target or coordinates as" \
418
+ "parameter." in err .value .args [0 ]
370
419
371
420
def test_query_criteria_no_params (self ):
372
421
ehst = ESAHubbleClass (self .get_dummy_tap_handler ())
0 commit comments