Skip to content

Commit 0ab42e8

Browse files
jespinosaar“Javier
authored andcommitted
Coverage and HAP methods removed
1 parent a0d611d commit 0ab42e8

File tree

4 files changed

+62
-95
lines changed

4 files changed

+62
-95
lines changed

astroquery/esa/hubble/core.py

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -609,88 +609,6 @@ def __check_list_strings(self, list):
609609
raise ValueError("One of the lists is empty or there are "
610610
"elements that are not strings")
611611

612-
def get_hap_proposals(self, async_job=True, output_file=None,
613-
output_format="votable",
614-
verbose=False):
615-
"""Launches a synchronous or asynchronous job to extract ALL HAP
616-
proposals
617-
618-
Parameters
619-
----------
620-
async_job : bool, optional, default 'False'
621-
executes the query (job) in asynchronous/synchronous mode (default
622-
synchronous)
623-
output_file : str, optional, default None
624-
file name where the results are saved if dumpToFile is True.
625-
If this parameter is not provided, the jobid is used instead
626-
output_format : str, optional, default 'votable'
627-
results format
628-
verbose : bool, optional, default 'False'
629-
flag to display information about the process
630-
631-
Returns
632-
-------
633-
A table object
634-
"""
635-
query = "select distinct p.* from ehst.proposal as p LEFT JOIN "\
636-
"ehst.observation as o on o.proposal_id = p.proposal_id "\
637-
"where (p.proposal_type LIKE '%HAP%' AND o.observation_id "\
638-
"like '%hst%' AND o.collection LIKE '%HST%') ORDER BY "\
639-
"p.proposal_id DESC"
640-
if verbose:
641-
print(query)
642-
job = self.query_hst_tap(query=query, async_job=async_job,
643-
output_file=output_file,
644-
output_format=output_format,
645-
verbose=verbose)
646-
try:
647-
table = job.get_results()
648-
except Exception:
649-
raise ValueError('There are not HAP proposals in this DB')
650-
return table
651-
652-
def get_hap_publications(self, async_job=False, output_file=None,
653-
output_format="votable",
654-
verbose=False):
655-
"""Launches a synchronous or asynchronous job to extract ALL HAP
656-
publications
657-
658-
Parameters
659-
----------
660-
async_job : bool, optional, default 'False'
661-
executes the query (job) in asynchronous/synchronous mode (default
662-
synchronous)
663-
output_file : str, optional, default None
664-
file name where the results are saved if dumpToFile is True.
665-
If this parameter is not provided, the jobid is used instead
666-
output_format : str, optional, default 'votable'
667-
results format
668-
verbose : bool, optional, default 'False'
669-
flag to display information about the process
670-
671-
Returns
672-
-------
673-
A table object
674-
"""
675-
query = "select distinct pb.* from ehst.publication as pb LEFT JOIN "\
676-
"ehst.publication_proposal as pp on pp.bib_code = "\
677-
"pb.bib_code LEFT JOIN ehst.proposal as p on pp.proposal_id="\
678-
"p.proposal_id LEFT JOIN ehst.observation as o on "\
679-
"o.proposal_id = p.proposal_id WHERE (p.proposal_type "\
680-
"LIKE '%HAP%' AND o.observation_id like '%hst%' AND "\
681-
"o.collection LIKE '%HST%') ORDER BY pb.bib_code DESC"
682-
if verbose:
683-
print(query)
684-
job = self.query_hst_tap(query=query, async_job=async_job,
685-
output_file=output_file,
686-
output_format=output_format,
687-
verbose=verbose)
688-
try:
689-
table = job.get_results()
690-
except Exception:
691-
raise ValueError('There are not HAP publications in this DB')
692-
return table
693-
694612
def get_tables(self, only_names=True, verbose=False):
695613
"""Get the available table in EHST TAP service
696614
Binary file not shown.
Binary file not shown.

astroquery/esa/hubble/tests/test_esa_hubble.py

Lines changed: 62 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,25 @@ def ehst_request(request):
4848
return mp
4949

5050

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+
5170
class TestESAHubble():
5271

5372
def get_dummy_tap_handler(self):
@@ -101,7 +120,6 @@ def test_query_target(self):
101120
ehst.query_target(name=parameters['name'],
102121
verbose=parameters['verbose'])
103122

104-
@pytest.mark.remote_data
105123
def test_cone_search(self):
106124
coords = coordinates.SkyCoord("00h42m44.51s +41d16m08.45s", frame='icrs')
107125

@@ -113,7 +131,7 @@ def test_cone_search(self):
113131

114132
parameters = {'coordinates': coords,
115133
'radius': 0.0,
116-
'file_name': 'file_cone',
134+
'filename': 'file_cone',
117135
'output_format': 'votable',
118136
'cache': True}
119137

@@ -126,39 +144,35 @@ def test_cone_search(self):
126144
ehst._request = MagicMock(return_value=response)
127145
ehst.cone_search(parameters['coordinates'],
128146
parameters['radius'],
129-
parameters['file_name'],
147+
parameters['filename'],
130148
parameters['output_format'],
131149
parameters['cache'])
132150

133-
@pytest.mark.remote_data
134151
def test_cone_search_coords(self):
135152
coords = "00h42m44.51s +41d16m08.45s"
136153

137154
parameterst = {'query': "select top 10 * from hsc_v2.hubble_sc2",
138155
'output_file': "test2.vot",
139156
'output_format': "votable",
140-
'verbose': False}
157+
'verbose': True}
141158
dummyTapHandler = DummyHubbleTapHandler("launch_job", parameterst)
142159

143160
parameters = {'coordinates': coords,
144161
'radius': 0.0,
145-
'file_name': 'file_cone',
162+
'filename': 'file_cone',
163+
'async_job': False,
146164
'output_format': 'votable',
147165
'cache': True}
148166

149167
ehst = ESAHubbleClass(dummyTapHandler)
150168
ehst.cone_search(parameters['coordinates'],
151169
parameters['radius'],
152-
parameters['file_name'],
170+
parameters['filename'],
153171
parameters['output_format'],
172+
parameters['async_job'],
154173
parameters['cache'])
155-
parameters[coordinates] = 1234
156174
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')
162176
assert "coordinate must be either a string or "\
163177
"astropy.coordinates" in err.value.args[0]
164178

@@ -192,6 +206,10 @@ def test_get_tables(self):
192206
ehst = ESAHubbleClass(self.get_dummy_tap_handler())
193207
ehst.get_tables(True, True)
194208

209+
def test_get_artifact(self):
210+
ehst = ESAHubbleClass(self.get_dummy_tap_handler())
211+
ehst.get_artifact("w0ji0v01t_c2f.fits.gz")
212+
195213
def test_get_columns(self):
196214
parameters = {'query': "select top 10 * from hsc_v2.hubble_sc2",
197215
'output_file': "test2.vot",
@@ -367,6 +385,37 @@ def test_cone_search_criteria(self):
367385
verbose=parameters1['verbose'])
368386
dummy_tap_handler = DummyHubbleTapHandler("launch_job", parameters3)
369387
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]
370419

371420
def test_query_criteria_no_params(self):
372421
ehst = ESAHubbleClass(self.get_dummy_tap_handler())

0 commit comments

Comments
 (0)