Skip to content

Commit 23f9c6f

Browse files
committed
TST: fix various remote tests
1 parent 6be3e41 commit 23f9c6f

File tree

8 files changed

+86
-59
lines changed

8 files changed

+86
-59
lines changed

astroquery/alma/tests/test_alma_remote.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from astropy import units as u
1111
import numpy as np
1212
import pytest
13+
from pyvo.dal.exceptions import DALOverflowWarning
1314

1415
from astroquery.exceptions import CorruptDataWarning
1516
from astroquery.utils.commons import ASTROPY_LT_4_1
@@ -48,11 +49,15 @@ def alma(request):
4849
@pytest.mark.remote_data
4950
class TestAlma:
5051
def test_public(self, alma):
51-
results = alma.query(payload=None, public=True, maxrec=100)
52+
with pytest.warns(expected_warning=DALOverflowWarning,
53+
match="Partial result set. Potential causes MAXREC, async storage space, etc."):
54+
results = alma.query(payload=None, public=True, maxrec=100)
5255
assert len(results) == 100
5356
for row in results:
5457
assert row['data_rights'] == 'Public'
55-
results = alma.query(payload=None, public=False, maxrec=100)
58+
with pytest.warns(expected_warning=DALOverflowWarning,
59+
match="Partial result set. Potential causes MAXREC, async storage space, etc."):
60+
results = alma.query(payload=None, public=False, maxrec=100)
5661
assert len(results) == 100
5762
for row in results:
5863
assert row['data_rights'] == 'Proprietary'
@@ -79,7 +84,9 @@ def test_freq(self, alma):
7984
def test_bands(self, alma):
8085
payload = {'band_list': ['5', '7']}
8186
# Added maxrec here as downloading and reading the results take too long.
82-
result = alma.query(payload, maxrec=1000)
87+
with pytest.warns(expected_warning=DALOverflowWarning,
88+
match="Partial result set. Potential causes MAXREC, async storage space, etc."):
89+
result = alma.query(payload, maxrec=1000)
8390
assert len(result) > 0
8491
for row in result:
8592
assert ('5' in row['band_list']) or ('7' in row['band_list'])
@@ -131,9 +138,9 @@ def test_data_proprietary(self, alma):
131138
query = "select top 1 member_ous_uid from ivoa.obscore where " \
132139
"obs_release_date > '{}'".format(now)
133140
result = alma.query_tap(query)
134-
assert len(result.table) == 1
141+
assert len(result.to_table()) == 1
135142
# proprietary
136-
assert alma.is_proprietary(result.table[0][0])
143+
assert alma.is_proprietary(result.to_table()[0][0])
137144
# non existent
138145
with pytest.raises(AttributeError):
139146
alma.is_proprietary('uid://NON/EXI/STING')

astroquery/atomic/tests/test_atomic_remote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def test_default_form_values():
1313
default_response = AtomicLineList._request(
1414
method="GET", url=AtomicLineList.FORM_URL,
1515
data={}, timeout=AtomicLineList.TIMEOUT)
16-
bs = BeautifulSoup(default_response.text, 'html5')
16+
bs = BeautifulSoup(default_response.text, 'html5lib')
1717
form = bs.find('form')
1818

1919
default_form_values = AtomicLineList._get_default_form_values(form)

astroquery/cds/tests/test_mocserver_remote.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ def test_field_l_param(self, field_l):
6969
reason="requires MOCPy")
7070
@pytest.mark.parametrize('moc_order', [5, 10])
7171
def test_moc_order_param(self, moc_order, tmp_cwd):
72+
73+
# We need a long timeout for this
74+
cds.TIMEOUT = 300
75+
7276
moc_region = MOC.from_json({'0': [1]})
7377

7478
result = cds.query_region(region=moc_region,

astroquery/nist/tests/test_nist_remote.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# Licensed under a 3-clause BSD style license - see LICENSE.rst
22

3-
4-
import numpy as np
5-
63
from astropy.table import Table
74
import astropy.units as u
85

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

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

2926
def test_unescape_html(self):
3027
response = nist.core.Nist.query_async(4333 * u.AA, 4334 * u.AA, "V I")

astroquery/ogle/tests/test_ogle_remote.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import pytest
33
import astropy.units as u
44
from astropy.coordinates import SkyCoord
5+
from astropy.utils.exceptions import AstropyDeprecationWarning
56

67
from .. import Ogle
78

@@ -25,6 +26,7 @@ def test_ogle_list():
2526
@pytest.mark.remote_data
2627
def test_ogle_list_values():
2728
co_list = [[0, 0, 0], [3, 3, 3]]
28-
response = Ogle.query_region(coord=co_list)
29+
with pytest.warns(AstropyDeprecationWarning):
30+
response = Ogle.query_region(coord=co_list)
2931
assert len(response) == 3
3032
assert response['RA[hr]'][0] == response['RA[hr]'][1] == response['RA[hr]'][2]

astroquery/sdss/tests/test_sdss_remote.py

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from astropy.coordinates import SkyCoord
77
from astropy.table import Table
8+
from astropy.utils.exceptions import AstropyUserWarning
89

910
from urllib.error import URLError
1011

@@ -13,6 +14,7 @@
1314

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

1719

1820
@pytest.mark.remote_data
@@ -47,7 +49,12 @@ def test_images_timeout(self):
4749

4850
@pytest.mark.parametrize("dr", dr_list)
4951
def test_sdss_spectrum(self, dr):
50-
xid = sdss.SDSS.query_region(self.coords, spectro=True, data_release=dr)
52+
if dr in dr_warn_list:
53+
with pytest.warns(AstropyUserWarning, match='Field info are not available for this data release'):
54+
xid = sdss.SDSS.query_region(self.coords, spectro=True, data_release=dr)
55+
else:
56+
xid = sdss.SDSS.query_region(self.coords, spectro=True, data_release=dr)
57+
5158
assert isinstance(xid, Table)
5259
sdss.SDSS.get_spectra(matches=xid, data_release=dr)
5360

@@ -176,8 +183,13 @@ def test_query_non_default_field(self):
176183

177184
@pytest.mark.parametrize("dr", dr_list)
178185
def test_query_crossid(self, dr):
179-
query1 = sdss.SDSS.query_crossid(self.coords, data_release=dr)
180-
query2 = sdss.SDSS.query_crossid([self.coords, self.coords], data_release=dr)
186+
if dr in dr_warn_list:
187+
with pytest.warns(AstropyUserWarning, match='Field info are not available for this data release'):
188+
query1 = sdss.SDSS.query_crossid(self.coords, data_release=dr)
189+
query2 = sdss.SDSS.query_crossid([self.coords, self.coords], data_release=dr)
190+
else:
191+
query1 = sdss.SDSS.query_crossid(self.coords, data_release=dr)
192+
query2 = sdss.SDSS.query_crossid([self.coords, self.coords], data_release=dr)
181193
assert isinstance(query1, Table)
182194
assert query1['objID'][0] == 1237652943176138868
183195

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

187199
@pytest.mark.parametrize("dr", dr_list)
188200
def test_spectro_query_crossid(self, dr):
189-
query1 = sdss.SDSS.query_crossid(self.coords,
190-
specobj_fields=['specObjID', 'z'],
191-
data_release=dr, cache=False)
192-
query2 = sdss.SDSS.query_crossid([self.coords, self.coords],
193-
specobj_fields=['specObjID', 'z'],
194-
data_release=dr, cache=False)
201+
if dr in dr_warn_list:
202+
with pytest.warns(AstropyUserWarning, match='Field info are not available for this data release'):
203+
query1 = sdss.SDSS.query_crossid(self.coords, specobj_fields=['specObjID', 'z'],
204+
data_release=dr, cache=False)
205+
query2 = sdss.SDSS.query_crossid([self.coords, self.coords], specobj_fields=['specObjID', 'z'],
206+
data_release=dr, cache=False)
207+
else:
208+
query1 = sdss.SDSS.query_crossid(self.coords, specobj_fields=['specObjID', 'z'],
209+
data_release=dr, cache=False)
210+
query2 = sdss.SDSS.query_crossid([self.coords, self.coords], specobj_fields=['specObjID', 'z'],
211+
data_release=dr, cache=False)
195212
assert isinstance(query1, Table)
196213
assert query1['specObjID'][0] == 845594848269461504
197214

docs/jplhorizons/jplhorizons.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ asteroid (433) Eros for a given date relative to the Sun:
220220
... epochs=2458133.33546)
221221
>>> el = obj.elements()
222222
>>> print(el)
223-
targetname datetime_jd ... Q P
224-
--- d ... AU d
223+
targetname datetime_jd ... Q P
224+
--- d ... AU d
225225
------------------ ------------- ... ---------------- -----------------
226226
433 Eros (A898 PA) 2458133.33546 ... 1.78244269692907 642.9387351308188
227227

@@ -263,8 +263,8 @@ epochs:
263263
... 'step':'10m'})
264264
>>> vec = obj.vectors()
265265
>>> print(vec)
266-
targetname datetime_jd ... range range_rate
267-
--- d ... AU AU / d
266+
targetname datetime_jd ... range range_rate
267+
--- d ... AU AU / d
268268
---------- ----------------- ... ------------------- ---------------------
269269
(2012 TC4) 2458027.5 ... 0.04293321045723708 -0.004080187126604792
270270
(2012 TC4) 2458027.506944444 ... 0.04290487481710865 -0.004080407273252692
@@ -428,7 +428,7 @@ in quadrature:
428428
14.775809055378625
429429
11.874886005626538
430430
7.183281978025435
431-
7.295600636473737
431+
7.295600209387093
432432
94.84824546372009
433433
23.952470898018017
434434

@@ -457,7 +457,7 @@ h`` - arcseconds per hour:
457457
-12.107
458458
-9.32616
459459
-5.80004
460-
3.115854
460+
3.115853
461461
85.22719
462462
19.02548
463463
@@ -479,7 +479,7 @@ same dimensions. For instance, we can turn ``RA_rate`` into ``arcsec / s``:
479479
-0.0033630555555555553
480480
-0.0025905999999999998
481481
-0.0016111222222222222
482-
0.0008655150000000001
482+
0.0008655147222222222
483483
0.023674219444444443
484484
0.005284855555555556
485485

docs/nist/nist.rst

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,29 @@ you can set it to several other values like "Na;Mg", etc. Lets now see a simple
2828
>>> table = Nist.query(4000 * u.AA, 7000 * u.AA, linename="H I")
2929
>>> print(table)
3030
Observed Ritz Transition Rel. ... Type TP Line
31-
------------- ------------- ------------- ------ ... ---- ----- --------
32-
-- 4102.85985517 24373.2429403 -- ... -- T8637 --
33-
-- 4102.86191087 24373.2307283 -- ... -- T8637 --
34-
-- 4102.8632 24373.223 -- ... -- -- c57
35-
4102.86503481 4102.86503481 24373.2121704 -- ... E2 -- L11759
36-
-- 4102.86579132 24373.2076763 -- ... -- T8637 --
37-
4102.86785074 4102.86785074 24373.1954423 -- ... M1 -- L11759
38-
-- 4102.8680725 24373.1941249 -- ... -- T8637 --
39-
4102.892 4102.8991 24373.05 70000 ... -- T8637 L7436c29
40-
-- 4102.8922 24373.051 -- ... -- -- c58
41-
-- 4102.92068748 24372.8815683 -- ... -- T8637 --
42-
... ... ... ... ... ... ... ...
43-
-- 6564.564672 15233.302588 -- ... -- T8637 --
44-
-- 6564.579878 15233.267302 -- ... M1 -- --
45-
-- 6564.583 15233.26 -- ... -- -- c66
46-
6564.584404 6564.584403 15233.256799 -- ... -- T8637 L6891c38
47-
6564.6 6564.632 15233.21 500000 ... -- T8637 L7400c29
48-
-- 6564.608 15233.202 -- ... -- -- c69
49-
6564.66464 6564.66466 15233.07061 -- ... -- T8637 L2752
50-
-- 6564.6662 15233.067 -- ... -- -- c71
51-
-- 6564.667 15233.065 -- ... -- -- c70
52-
-- 6564.680232 15233.034432 -- ... -- T8637 --
53-
-- 6564.722349 15232.9367 -- ... -- T8637 --
31+
------------- ------------- ------------- ------ ... ---- ----- --------
32+
-- 4102.85985517 24373.2429403 -- ... -- T7771 --
33+
-- 4102.86191087 24373.2307283 -- ... -- T7771 --
34+
-- 4102.8632 24373.223 -- ... -- -- c57
35+
4102.86503488 4102.86503481 24373.2121704 -- ... E2 -- L11759
36+
-- 4102.86579132 24373.2076763 -- ... -- T7771 --
37+
4102.86785081 4102.86785074 24373.1954423 -- ... M1 -- L11759
38+
-- 4102.8680725 24373.1941249 -- ... -- T7771 --
39+
4102.892 4102.8991 24373.05 70000 ... -- T8637 L7436c29
40+
-- 4102.8922 24373.051 -- ... -- -- c58
41+
-- 4102.92068748 24372.8815683 -- ... -- T7771 --
42+
... ... ... ... ... ... ... ...
43+
-- 6564.564672 15233.302588 -- ... -- T7771 --
44+
-- 6564.579878 15233.267302 -- ... M1 -- --
45+
-- 6564.583 15233.26 -- ... -- -- c66
46+
6564.584404 6564.584403 15233.256799 -- ... -- T7771 L6891c38
47+
6564.6 6564.632 15233.21 500000 ... -- T8637 L7400c29
48+
-- 6564.608 15233.202 -- ... -- -- c69
49+
6564.66464 6564.66466 15233.07061 -- ... -- T7771 L2752
50+
-- 6564.6662 15233.067 -- ... -- -- c71
51+
-- 6564.667 15233.065 -- ... -- -- c70
52+
-- 6564.680232 15233.034432 -- ... -- T7771 --
53+
-- 6564.722349 15232.9367 -- ... -- T7771 --
5454
Length = 53 rows
5555

5656

@@ -76,15 +76,15 @@ or 'vac+air'. Here is an example with all these parameters.
7676
Observed Ritz Transition Rel. ... Upper level Type TP Line
7777
-------- ----------- ----------- ----- ... ------------------- ---- ----- -----
7878
-- 4020.871 2487.024 (200) ... 14 | | -- T8637 --
79-
-- 4052.18664 2467.803411 -- ... 5d | 2D | 3/2 -- T8637 --
80-
-- 4052.19376 2467.79907 -- ... 5p | 2P* | 3/2 -- T8637 --
81-
-- 4052.22121 2467.78236 -- ... 5s | 2S | 1/2 -- T8637 --
82-
-- 4052.23222 2467.77565 -- ... 5p | 2P* | 1/2 -- T8637 --
83-
-- 4052.248747 2467.765585 -- ... 5f | 2F* | 5/2 -- T8637 --
84-
-- 4052.24892 2467.765479 -- ... 5d | 2D | 5/2 -- T8637 --
85-
-- 4052.26147 2467.75784 -- ... 5p | 2P* | 3/2 -- T8637 --
86-
-- 4052.26174 2467.757676 -- ... 5d | 2D | 3/2 -- T8637 --
87-
-- 4052.26738 2467.75424 -- ... 5g | 2G | 7/2 -- T8637 --
79+
-- 4052.18664 2467.803411 -- ... 5d | 2D | 3/2 -- T7771 --
80+
-- 4052.19376 2467.79907 -- ... 5p | 2P* | 3/2 -- T7771 --
81+
-- 4052.22121 2467.78236 -- ... 5s | 2S | 1/2 -- T7771 --
82+
-- 4052.23222 2467.77565 -- ... 5p | 2P* | 1/2 -- T7771 --
83+
-- 4052.248747 2467.765585 -- ... 5f | 2F* | 5/2 -- T7771 --
84+
-- 4052.24892 2467.765479 -- ... 5d | 2D | 5/2 -- T7771 --
85+
-- 4052.26147 2467.75784 -- ... 5p | 2P* | 3/2 -- T7771 --
86+
-- 4052.26174 2467.757676 -- ... 5d | 2D | 3/2 -- T7771 --
87+
-- 4052.26738 2467.75424 -- ... 5g | 2G | 7/2 -- T7771 --
8888
... ... ... ... ... ... ... ... ...
8989
5128.65 5128.662 1949.83 (450) ... 10 | | -- T8637 L7452
9090
-- 5169.282 1934.5047 -- ... 19 | | -- T8637 --

0 commit comments

Comments
 (0)