Skip to content

Commit

Permalink
Merge pull request #2587 from bsipocz/TST_fixing_remote_failures
Browse files Browse the repository at this point in the history
MAINT: fixing various remote test failures
  • Loading branch information
bsipocz authored Nov 16, 2022
2 parents 065ea83 + d4f8603 commit 0eb8daa
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 60 deletions.
23 changes: 18 additions & 5 deletions astroquery/alma/tests/test_alma_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
from astropy import units as u
import numpy as np
import pytest
try:
# This requires pyvo 1.4
from pyvo.dal.exceptions import DALOverflowWarning
except ImportError:
pass

from astroquery.exceptions import CorruptDataWarning
from astroquery.utils.commons import ASTROPY_LT_4_1
Expand Down Expand Up @@ -48,11 +53,16 @@ def alma(request):
@pytest.mark.remote_data
class TestAlma:
def test_public(self, alma):
results = alma.query(payload=None, public=True, maxrec=100)
# This warning was added in pyvo 1.4, but we don't test older versions with remote-data
with pytest.warns(expected_warning=DALOverflowWarning,
match="Partial result set. Potential causes MAXREC, async storage space, etc."):
results = alma.query(payload=None, public=True, maxrec=100)
assert len(results) == 100
for row in results:
assert row['data_rights'] == 'Public'
results = alma.query(payload=None, public=False, maxrec=100)
with pytest.warns(expected_warning=DALOverflowWarning,
match="Partial result set. Potential causes MAXREC, async storage space, etc."):
results = alma.query(payload=None, public=False, maxrec=100)
assert len(results) == 100
for row in results:
assert row['data_rights'] == 'Proprietary'
Expand All @@ -79,7 +89,10 @@ def test_freq(self, alma):
def test_bands(self, alma):
payload = {'band_list': ['5', '7']}
# Added maxrec here as downloading and reading the results take too long.
result = alma.query(payload, maxrec=1000)
# This warning was added in pyvo 1.4, but we don't test older versions with remote-data
with pytest.warns(expected_warning=DALOverflowWarning,
match="Partial result set. Potential causes MAXREC, async storage space, etc."):
result = alma.query(payload, maxrec=1000)
assert len(result) > 0
for row in result:
assert ('5' in row['band_list']) or ('7' in row['band_list'])
Expand Down Expand Up @@ -131,9 +144,9 @@ def test_data_proprietary(self, alma):
query = "select top 1 member_ous_uid from ivoa.obscore where " \
"obs_release_date > '{}'".format(now)
result = alma.query_tap(query)
assert len(result.table) == 1
assert len(result.to_table()) == 1
# proprietary
assert alma.is_proprietary(result.table[0][0])
assert alma.is_proprietary(result.to_table()[0][0])
# non existent
with pytest.raises(AttributeError):
alma.is_proprietary('uid://NON/EXI/STING')
Expand Down
2 changes: 1 addition & 1 deletion astroquery/atomic/tests/test_atomic_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_default_form_values():
default_response = AtomicLineList._request(
method="GET", url=AtomicLineList.FORM_URL,
data={}, timeout=AtomicLineList.TIMEOUT)
bs = BeautifulSoup(default_response.text, 'html5')
bs = BeautifulSoup(default_response.text, 'html5lib')
form = bs.find('form')

default_form_values = AtomicLineList._get_default_form_values(form)
Expand Down
4 changes: 4 additions & 0 deletions astroquery/cds/tests/test_mocserver_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ def test_field_l_param(self, field_l):
reason="requires MOCPy")
@pytest.mark.parametrize('moc_order', [5, 10])
def test_moc_order_param(self, moc_order, tmp_cwd):

# We need a long timeout for this
cds.TIMEOUT = 300

moc_region = MOC.from_json({'0': [1]})

result = cds.query_region(region=moc_region,
Expand Down
5 changes: 1 addition & 4 deletions astroquery/nist/tests/test_nist_remote.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst


import numpy as np

from astropy.table import Table
import astropy.units as u

Expand All @@ -24,7 +21,7 @@ def test_query(self):

# check that no javascript was left in the table
# (regression test for 1355)
assert np.all(result['TP'] == 'T8637')
assert set(result['TP']) == set(['T8637', 'T7771'])

def test_unescape_html(self):
response = nist.core.Nist.query_async(4333 * u.AA, 4334 * u.AA, "V I")
Expand Down
4 changes: 3 additions & 1 deletion astroquery/ogle/tests/test_ogle_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pytest
import astropy.units as u
from astropy.coordinates import SkyCoord
from astropy.utils.exceptions import AstropyDeprecationWarning

from .. import Ogle

Expand All @@ -25,6 +26,7 @@ def test_ogle_list():
@pytest.mark.remote_data
def test_ogle_list_values():
co_list = [[0, 0, 0], [3, 3, 3]]
response = Ogle.query_region(coord=co_list)
with pytest.warns(AstropyDeprecationWarning):
response = Ogle.query_region(coord=co_list)
assert len(response) == 3
assert response['RA[hr]'][0] == response['RA[hr]'][1] == response['RA[hr]'][2]
35 changes: 26 additions & 9 deletions astroquery/sdss/tests/test_sdss_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from astropy.coordinates import SkyCoord
from astropy.table import Table
from astropy.utils.exceptions import AstropyUserWarning

from urllib.error import URLError

Expand All @@ -13,6 +14,7 @@

# DR11 is a quasi-internal data release that does not have SkyServer support.
dr_list = (8, 9, 10, 12, 13, 14, 15, 16, 17)
dr_warn_list = (8, 9)


@pytest.mark.remote_data
Expand Down Expand Up @@ -47,7 +49,12 @@ def test_images_timeout(self):

@pytest.mark.parametrize("dr", dr_list)
def test_sdss_spectrum(self, dr):
xid = sdss.SDSS.query_region(self.coords, spectro=True, data_release=dr)
if dr in dr_warn_list:
with pytest.warns(AstropyUserWarning, match='Field info are not available for this data release'):
xid = sdss.SDSS.query_region(self.coords, spectro=True, data_release=dr)
else:
xid = sdss.SDSS.query_region(self.coords, spectro=True, data_release=dr)

assert isinstance(xid, Table)
sdss.SDSS.get_spectra(matches=xid, data_release=dr)

Expand Down Expand Up @@ -176,8 +183,13 @@ def test_query_non_default_field(self):

@pytest.mark.parametrize("dr", dr_list)
def test_query_crossid(self, dr):
query1 = sdss.SDSS.query_crossid(self.coords, data_release=dr)
query2 = sdss.SDSS.query_crossid([self.coords, self.coords], data_release=dr)
if dr in dr_warn_list:
with pytest.warns(AstropyUserWarning, match='Field info are not available for this data release'):
query1 = sdss.SDSS.query_crossid(self.coords, data_release=dr)
query2 = sdss.SDSS.query_crossid([self.coords, self.coords], data_release=dr)
else:
query1 = sdss.SDSS.query_crossid(self.coords, data_release=dr)
query2 = sdss.SDSS.query_crossid([self.coords, self.coords], data_release=dr)
assert isinstance(query1, Table)
assert query1['objID'][0] == 1237652943176138868

Expand All @@ -186,12 +198,17 @@ def test_query_crossid(self, dr):

@pytest.mark.parametrize("dr", dr_list)
def test_spectro_query_crossid(self, dr):
query1 = sdss.SDSS.query_crossid(self.coords,
specobj_fields=['specObjID', 'z'],
data_release=dr, cache=False)
query2 = sdss.SDSS.query_crossid([self.coords, self.coords],
specobj_fields=['specObjID', 'z'],
data_release=dr, cache=False)
if dr in dr_warn_list:
with pytest.warns(AstropyUserWarning, match='Field info are not available for this data release'):
query1 = sdss.SDSS.query_crossid(self.coords, specobj_fields=['specObjID', 'z'],
data_release=dr, cache=False)
query2 = sdss.SDSS.query_crossid([self.coords, self.coords], specobj_fields=['specObjID', 'z'],
data_release=dr, cache=False)
else:
query1 = sdss.SDSS.query_crossid(self.coords, specobj_fields=['specObjID', 'z'],
data_release=dr, cache=False)
query2 = sdss.SDSS.query_crossid([self.coords, self.coords], specobj_fields=['specObjID', 'z'],
data_release=dr, cache=False)
assert isinstance(query1, Table)
assert query1['specObjID'][0] == 845594848269461504

Expand Down
14 changes: 7 additions & 7 deletions docs/jplhorizons/jplhorizons.rst
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ asteroid (433) Eros for a given date relative to the Sun:
... epochs=2458133.33546)
>>> el = obj.elements()
>>> print(el)
targetname datetime_jd ... Q P
--- d ... AU d
targetname datetime_jd ... Q P
--- d ... AU d
------------------ ------------- ... ---------------- -----------------
433 Eros (A898 PA) 2458133.33546 ... 1.78244269692907 642.9387351308188

Expand Down Expand Up @@ -263,8 +263,8 @@ epochs:
... 'step':'10m'})
>>> vec = obj.vectors()
>>> print(vec)
targetname datetime_jd ... range range_rate
--- d ... AU AU / d
targetname datetime_jd ... range range_rate
--- d ... AU AU / d
---------- ----------------- ... ------------------- ---------------------
(2012 TC4) 2458027.5 ... 0.04293321045723708 -0.004080187126604792
(2012 TC4) 2458027.506944444 ... 0.04290487481710865 -0.004080407273252692
Expand Down Expand Up @@ -428,7 +428,7 @@ in quadrature:
14.775809055378625
11.874886005626538
7.183281978025435
7.295600636473737
7.295600209387093
94.84824546372009
23.952470898018017

Expand Down Expand Up @@ -457,7 +457,7 @@ h`` - arcseconds per hour:
-12.107
-9.32616
-5.80004
3.115854
3.115853
85.22719
19.02548
Expand All @@ -479,7 +479,7 @@ same dimensions. For instance, we can turn ``RA_rate`` into ``arcsec / s``:
-0.0033630555555555553
-0.0025905999999999998
-0.0016111222222222222
0.0008655150000000001
0.0008655147222222222
0.023674219444444443
0.005284855555555556

Expand Down
64 changes: 32 additions & 32 deletions docs/nist/nist.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,29 @@ you can set it to several other values like "Na;Mg", etc. Lets now see a simple
>>> table = Nist.query(4000 * u.AA, 7000 * u.AA, linename="H I")
>>> print(table)
Observed Ritz Transition Rel. ... Type TP Line
------------- ------------- ------------- ------ ... ---- ----- --------
-- 4102.85985517 24373.2429403 -- ... -- T8637 --
-- 4102.86191087 24373.2307283 -- ... -- T8637 --
-- 4102.8632 24373.223 -- ... -- -- c57
4102.86503481 4102.86503481 24373.2121704 -- ... E2 -- L11759
-- 4102.86579132 24373.2076763 -- ... -- T8637 --
4102.86785074 4102.86785074 24373.1954423 -- ... M1 -- L11759
-- 4102.8680725 24373.1941249 -- ... -- T8637 --
4102.892 4102.8991 24373.05 70000 ... -- T8637 L7436c29
-- 4102.8922 24373.051 -- ... -- -- c58
-- 4102.92068748 24372.8815683 -- ... -- T8637 --
... ... ... ... ... ... ... ...
-- 6564.564672 15233.302588 -- ... -- T8637 --
-- 6564.579878 15233.267302 -- ... M1 -- --
-- 6564.583 15233.26 -- ... -- -- c66
6564.584404 6564.584403 15233.256799 -- ... -- T8637 L6891c38
6564.6 6564.632 15233.21 500000 ... -- T8637 L7400c29
-- 6564.608 15233.202 -- ... -- -- c69
6564.66464 6564.66466 15233.07061 -- ... -- T8637 L2752
-- 6564.6662 15233.067 -- ... -- -- c71
-- 6564.667 15233.065 -- ... -- -- c70
-- 6564.680232 15233.034432 -- ... -- T8637 --
-- 6564.722349 15232.9367 -- ... -- T8637 --
------------- ------------- ------------- ------ ... ---- ----- --------
-- 4102.85985517 24373.2429403 -- ... -- T7771 --
-- 4102.86191087 24373.2307283 -- ... -- T7771 --
-- 4102.8632 24373.223 -- ... -- -- c57
4102.86503488 4102.86503481 24373.2121704 -- ... E2 -- L11759
-- 4102.86579132 24373.2076763 -- ... -- T7771 --
4102.86785081 4102.86785074 24373.1954423 -- ... M1 -- L11759
-- 4102.8680725 24373.1941249 -- ... -- T7771 --
4102.892 4102.8991 24373.05 70000 ... -- T8637 L7436c29
-- 4102.8922 24373.051 -- ... -- -- c58
-- 4102.92068748 24372.8815683 -- ... -- T7771 --
... ... ... ... ... ... ... ...
-- 6564.564672 15233.302588 -- ... -- T7771 --
-- 6564.579878 15233.267302 -- ... M1 -- --
-- 6564.583 15233.26 -- ... -- -- c66
6564.584404 6564.584403 15233.256799 -- ... -- T7771 L6891c38
6564.6 6564.632 15233.21 500000 ... -- T8637 L7400c29
-- 6564.608 15233.202 -- ... -- -- c69
6564.66464 6564.66466 15233.07061 -- ... -- T7771 L2752
-- 6564.6662 15233.067 -- ... -- -- c71
-- 6564.667 15233.065 -- ... -- -- c70
-- 6564.680232 15233.034432 -- ... -- T7771 --
-- 6564.722349 15232.9367 -- ... -- T7771 --
Length = 53 rows


Expand All @@ -76,15 +76,15 @@ or 'vac+air'. Here is an example with all these parameters.
Observed Ritz Transition Rel. ... Upper level Type TP Line
-------- ----------- ----------- ----- ... ------------------- ---- ----- -----
-- 4020.871 2487.024 (200) ... 14 | | -- T8637 --
-- 4052.18664 2467.803411 -- ... 5d | 2D | 3/2 -- T8637 --
-- 4052.19376 2467.79907 -- ... 5p | 2P* | 3/2 -- T8637 --
-- 4052.22121 2467.78236 -- ... 5s | 2S | 1/2 -- T8637 --
-- 4052.23222 2467.77565 -- ... 5p | 2P* | 1/2 -- T8637 --
-- 4052.248747 2467.765585 -- ... 5f | 2F* | 5/2 -- T8637 --
-- 4052.24892 2467.765479 -- ... 5d | 2D | 5/2 -- T8637 --
-- 4052.26147 2467.75784 -- ... 5p | 2P* | 3/2 -- T8637 --
-- 4052.26174 2467.757676 -- ... 5d | 2D | 3/2 -- T8637 --
-- 4052.26738 2467.75424 -- ... 5g | 2G | 7/2 -- T8637 --
-- 4052.18664 2467.803411 -- ... 5d | 2D | 3/2 -- T7771 --
-- 4052.19376 2467.79907 -- ... 5p | 2P* | 3/2 -- T7771 --
-- 4052.22121 2467.78236 -- ... 5s | 2S | 1/2 -- T7771 --
-- 4052.23222 2467.77565 -- ... 5p | 2P* | 1/2 -- T7771 --
-- 4052.248747 2467.765585 -- ... 5f | 2F* | 5/2 -- T7771 --
-- 4052.24892 2467.765479 -- ... 5d | 2D | 5/2 -- T7771 --
-- 4052.26147 2467.75784 -- ... 5p | 2P* | 3/2 -- T7771 --
-- 4052.26174 2467.757676 -- ... 5d | 2D | 3/2 -- T7771 --
-- 4052.26738 2467.75424 -- ... 5g | 2G | 7/2 -- T7771 --
... ... ... ... ... ... ... ... ...
5128.65 5128.662 1949.83 (450) ... 10 | | -- T8637 L7452
-- 5169.282 1934.5047 -- ... 19 | | -- T8637 --
Expand Down
5 changes: 4 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ remote_data_strict = true
addopts = --color=yes --doctest-rst
filterwarnings =
error
## These are temporary measures, all of these should be fixed:
# These are temporary measures, all of these should be fixed:
# -----------------------------------------------------------
ignore:distutils Version classes are deprecated:DeprecationWarning
# Upstream issues in many packages, not clear whether we can do anything about these in astroquery
ignore:unclosed <socket.socket:ResourceWarning
ignore:unclosed <ssl.SSLSocket:ResourceWarning
# Various VO warnings from vo_conesearch
ignore::astropy.io.votable.exceptions.W21
Expand Down

0 comments on commit 0eb8daa

Please sign in to comment.