Skip to content

Commit

Permalink
Merge pull request #2346 from bsipocz/MNT_fix_eso_gaia_remote
Browse files Browse the repository at this point in the history
MNT: fixing more remote tests
  • Loading branch information
bsipocz authored Mar 29, 2022
2 parents b6de267 + 9270204 commit f91c955
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 15 deletions.
40 changes: 29 additions & 11 deletions astroquery/eso/tests/test_eso_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import pytest
import tempfile
import shutil
from ...exceptions import LoginError
import warnings

from astroquery.exceptions import LoginError, NoResultsWarning

from ...eso import Eso

Expand Down Expand Up @@ -93,8 +95,9 @@ def test_empty_return(self):
surveys = eso.list_surveys(cache=False)
assert len(surveys) > 0
# Avoid SESAME
result_s = eso.query_surveys(surveys[0], coord1=202.469575,
coord2=47.195258, cache=False)
with pytest.warns(NoResultsWarning):
result_s = eso.query_surveys(surveys[0], coord1=202.469575,
coord2=47.195258, cache=False)

assert result_s is None

Expand Down Expand Up @@ -163,7 +166,7 @@ def test_apex_retrieval(self):
tbl = eso.query_apex_quicklooks(prog_id='095.F-9802')
tblb = eso.query_apex_quicklooks('095.F-9802')

assert len(tbl) == 4
assert len(tbl) == 5
assert set(tbl['Release Date']) == {'2015-07-17', '2015-07-18',
'2015-09-15', '2015-09-18'}

Expand All @@ -174,20 +177,35 @@ def test_each_instrument_SgrAstar(self, temp_dir):
eso.cache_location = temp_dir

instruments = eso.list_instruments(cache=False)
for instrument in instruments:
result_i = eso.query_instrument(instrument, coord1=266.41681662,
coord2=-29.00782497, cache=False)

for instrument in instruments:
with pytest.warns(None) as record:
result_i = eso.query_instrument(instrument, coord1=266.41681662,
coord2=-29.00782497, cache=False)
# Sometimes there are ResourceWarnings, we ignore those for this test
if len(record) > 0 and NoResultsWarning in {record[i].category for i in range(len(record))}:
assert result_i is None
else:
assert len(result_i) > 0

@pytest.mark.filterwarnings("ignore::ResourceWarning")
def test_each_survey_SgrAstar(self, temp_dir):
eso = Eso()
eso.cache_location = temp_dir

surveys = eso.list_surveys(cache=False)
for survey in surveys:
result_s = eso.query_surveys(survey, coord1=266.41681662,
coord2=-29.00782497,
box='01 00 00',
cache=False)
with pytest.warns(None) as record:
result_s = eso.query_surveys(survey, coord1=266.41681662,
coord2=-29.00782497,
box='01 00 00',
cache=False)
# Sometimes there are ResourceWarnings, we ignore those for this test
if len(record) > 0 and NoResultsWarning in {record[i].category for i in range(len(record))}:
assert result_s is None
else:
print([record[i].message for i in range(len(record))])
assert len(result_s) > 0

@pytest.mark.skipif("SKIP_SLOW")
@pytest.mark.parametrize('cache', (False, True))
Expand Down
7 changes: 3 additions & 4 deletions docs/gaia/gaia.rst
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ radius argument.
INFO: Query finished. [astroquery.utils.tap.core]
>>> r = j.get_results()
>>> r.pprint()
solution_id designation ... dist
solution_id DESIGNATION ... dist
...
------------------- ---------------------------- ... ---------------------
1635721458409799680 Gaia DR2 6636090334814214528 ... 0.0026034636994048854
Expand All @@ -184,7 +184,6 @@ radius argument.
1635721458409799680 Gaia DR2 6636089583198817664 ... 0.008338509690874027
1635721458409799680 Gaia DR2 6636089578899968384 ... 0.008406677772258921
... ... ... ...

1635721458409799680 Gaia DR2 6636089510180765312 ... 0.01943176697471851
1635721458409799680 Gaia DR2 6636066871411763712 ... 0.019464719601172412
1635721458409799680 Gaia DR2 6636089514475519232 ... 0.019467068628703368
Expand Down Expand Up @@ -418,8 +417,8 @@ Query without saving results in a file:
INFO: Query finished. [astroquery.utils.tap.core]
>>> r = job.get_results()
>>> print(r)
designation ra dec
deg deg
DESIGNATION ra dec
deg deg
---------------------- ------------------ --------------------
Gaia DR2 4295806720 44.996153684159594 0.005615806210679649
Gaia DR2 34361129088 45.004316164207644 0.021045032689712983
Expand Down

0 comments on commit f91c955

Please sign in to comment.