Skip to content

Commit 2e0ef17

Browse files
committed
TST: remove tests for pseudo async methods, it needs a full rewrite. Also, skip BOX tests as TAP server doesn’t support it
1 parent 7c57ff8 commit 2e0ef17

File tree

3 files changed

+19
-124
lines changed

3 files changed

+19
-124
lines changed

astroquery/ipac/irsa/core.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@
88
"""
99

1010
import warnings
11-
import astropy.units as u
12-
from astropy.coordinates import SkyCoord, ICRS
11+
from astropy.coordinates import SkyCoord
12+
from astropy import units as u
1313
from astropy.utils.decorators import deprecated_renamed_argument
1414
from pyvo.dal.tap import TAPService
1515
from astroquery import log
1616
from astroquery.query import BaseQuery
1717
from astroquery.utils.commons import parse_coordinates
1818
from astroquery.ipac.irsa import conf
19-
from astroquery.exceptions import TableParseError, NoResultsWarning, InvalidQueryError
19+
from astroquery.exceptions import InvalidQueryError
2020

2121

2222
__all__ = ['Irsa', 'IrsaClass']
23+
24+
2325
class IrsaClass(BaseQuery):
2426

2527
def __init__(self):

astroquery/ipac/irsa/tests/test_irsa.py

Lines changed: 10 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -41,54 +41,10 @@ def get_mockreturn(method, url, params=None, timeout=10, cache=False, **kwargs):
4141
return MockResponse(content, **kwargs)
4242

4343

44-
@pytest.mark.parametrize(('dim'),
45-
['5d0m0s', 0.3 * u.rad, '5h0m0s', 2 * u.arcmin])
46-
def test_parse_dimension(dim):
47-
# check that the returned dimension is always in units of 'arcsec',
48-
# 'arcmin' or 'deg'
49-
new_dim = irsa.core._parse_dimension(dim)
50-
assert new_dim.unit in ['arcsec', 'arcmin', 'deg']
51-
52-
53-
@pytest.mark.parametrize(('ra', 'dec', 'expected'),
54-
[(10, 10, '10 +10'),
55-
(10.0, -11, '10.0 -11')
56-
])
57-
def test_format_decimal_coords(ra, dec, expected):
58-
out = irsa.core._format_decimal_coords(ra, dec)
59-
assert out == expected
60-
61-
62-
@pytest.mark.parametrize(('coordinates', 'expected'),
63-
[("5h0m0s 0d0m0s", "75.0 +0.0")
64-
])
65-
def test_parse_coordinates(coordinates, expected):
66-
out = irsa.core._parse_coordinates(coordinates)
67-
for a, b in zip(out.split(), expected.split()):
68-
try:
69-
a = float(a)
70-
b = float(b)
71-
np.testing.assert_almost_equal(a, b)
72-
except ValueError:
73-
assert a == b
74-
75-
76-
def test_args_to_payload():
77-
out = Irsa._args_to_payload("fp_psc")
78-
assert out == dict(catalog='fp_psc', outfmt=3, outrows=conf.row_limit,
79-
selcols='')
80-
81-
82-
@pytest.mark.parametrize(("coordinates"), OBJ_LIST)
83-
def test_query_region_cone_async(coordinates, patch_get):
84-
response = Irsa.query_region_async(
85-
coordinates, catalog='fp_psc', spatial='Cone',
86-
radius=2 * u.arcmin, get_query_payload=True)
87-
assert response['radius'] == 2
88-
assert response['radunits'] == 'arcmin'
89-
response = Irsa.query_region_async(
90-
coordinates, catalog='fp_psc', spatial='Cone', radius=2 * u.arcmin)
91-
assert response is not None
44+
#def test_args_to_payload():
45+
# out = Irsa._args_to_payload("fp_psc")
46+
# assert out == dict(catalog='fp_psc', outfmt=3, outrows=conf.row_limit,
47+
# selcols='')
9248

9349

9450
@pytest.mark.parametrize(("coordinates"), OBJ_LIST)
@@ -99,18 +55,8 @@ def test_query_region_cone(coordinates, patch_get):
9955
assert isinstance(result, Table)
10056

10157

102-
@pytest.mark.parametrize(("coordinates"), OBJ_LIST)
103-
def test_query_region_box_async(coordinates, patch_get):
104-
response = Irsa.query_region_async(
105-
coordinates, catalog='fp_psc', spatial='Box',
106-
width=2 * u.arcmin, get_query_payload=True)
107-
assert response['size'] == 120
108-
response = Irsa.query_region_async(
109-
coordinates, catalog='fp_psc', spatial='Box', width=2 * u.arcmin)
110-
assert response is not None
111-
112-
113-
@pytest.mark.parametrize(("coordinates"), OBJ_LIST)
58+
@pytest.mark.skip("Upstream TAP doesn't support Box geometry yet")
59+
@pytest.mark.parametrize("coordinates", OBJ_LIST)
11460
def test_query_region_box(coordinates, patch_get):
11561
result = Irsa.query_region(
11662
coordinates, catalog='fp_psc', spatial='Box', width=2 * u.arcmin)
@@ -125,51 +71,17 @@ def test_query_region_box(coordinates, patch_get):
12571
(10.0 * u.deg, 10.0 * u.deg)]
12672

12773

128-
@pytest.mark.parametrize(("polygon"), [poly1, poly2])
129-
def test_query_region_async_polygon(polygon, patch_get):
130-
response = Irsa.query_region_async(
131-
"m31", catalog="fp_psc", spatial="Polygon",
132-
polygon=polygon, get_query_payload=True)
133-
134-
for a, b in zip(re.split("[ ,]", response["polygon"]),
135-
re.split("[ ,]", "10.1 +10.1,10.0 +10.1,10.0 +10.0")):
136-
for a1, b1 in zip(a.split(), b.split()):
137-
a1 = float(a1)
138-
b1 = float(b1)
139-
np.testing.assert_almost_equal(a1, b1)
140-
141-
response = Irsa.query_region_async(
142-
"m31", catalog="fp_psc", spatial="Polygon", polygon=polygon)
143-
144-
assert response is not None
145-
146-
147-
@pytest.mark.parametrize(("polygon"),
148-
[poly1,
149-
poly2,
150-
])
74+
@pytest.mark.parametrize("polygon", [poly1, poly2])
15175
def test_query_region_polygon(polygon, patch_get):
152-
result = Irsa.query_region(
153-
"m31", catalog="fp_psc", spatial="Polygon", polygon=polygon)
76+
result = Irsa.query_region("m31", catalog="fp_psc", spatial="Polygon", polygon=polygon)
15477

15578
assert isinstance(result, Table)
15679

15780

158-
@pytest.mark.parametrize(('spatial', 'result'),
159-
zip(('Cone', 'Box', 'Polygon', 'All-Sky'),
160-
('Cone', 'Box', 'Polygon', 'NONE')))
161-
def test_spatial_valdi(spatial, result):
162-
out = Irsa._parse_spatial(
163-
spatial, coordinates='m31', radius=5 * u.deg, width=5 * u.deg,
164-
polygon=[(5 * u.hour, 5 * u.deg)] * 3)
165-
assert out['spatial'] == result
166-
167-
168-
@pytest.mark.parametrize(('spatial'), [('cone', 'box', 'polygon', 'all-Sky',
169-
'All-sky', 'invalid', 'blah')])
81+
@pytest.mark.parametrize('spatial', ['cone', 'box', 'polygon', 'all-Sky', 'All-sky', 'invalid'])
17082
def test_spatial_invalid(spatial):
17183
with pytest.raises(ValueError):
172-
Irsa._parse_spatial(spatial, coordinates='m31')
84+
Irsa.query_region("m31", catalog='invalid_spatial', spatial=spatial)
17385

17486

17587
def test_deprecated_namespace_import_warning():

astroquery/ipac/irsa/tests/test_irsa_remote.py

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,18 @@
1616

1717
@pytest.mark.remote_data
1818
class TestIrsa:
19-
def test_query_region_cone_async(self):
20-
response = Irsa.query_region_async(
21-
'm31', catalog='fp_psc', spatial='Cone', radius=2 * u.arcmin, cache=False)
22-
assert response is not None
23-
2419
def test_query_region_cone(self):
2520
result = Irsa.query_region(
2621
'm31', catalog='fp_psc', spatial='Cone', radius=2 * u.arcmin, cache=False)
2722
assert isinstance(result, Table)
2823

29-
def test_query_region_box_async(self):
30-
response = Irsa.query_region_async(
31-
"00h42m44.330s +41d16m07.50s", catalog='fp_psc', spatial='Box',
32-
width=2 * u.arcmin, cache=False)
33-
assert response is not None
34-
24+
@pytest.mark.skip("Upstream TAP doesn't support Box geometry yet")
3525
def test_query_region_box(self):
3626
result = Irsa.query_region(
3727
"00h42m44.330s +41d16m07.50s", catalog='fp_psc', spatial='Box',
3828
width=2 * u.arcmin, cache=False)
3929
assert isinstance(result, Table)
4030

41-
def test_query_region_async_polygon(self):
42-
polygon = [SkyCoord(ra=10.1, dec=10.1, unit=(u.deg, u.deg)),
43-
SkyCoord(ra=10.0, dec=10.1, unit=(u.deg, u.deg)),
44-
SkyCoord(ra=10.0, dec=10.0, unit=(u.deg, u.deg))]
45-
response = Irsa.query_region_async(
46-
"m31", catalog="fp_psc", spatial="Polygon", polygon=polygon, cache=False)
47-
48-
assert response is not None
49-
5031
def test_query_region_polygon(self):
5132
polygon = [(10.1, 10.1), (10.0, 10.1), (10.0, 10.0)]
5233
with pytest.warns(UserWarning, match='Polygon endpoints are being interpreted'):
@@ -56,7 +37,7 @@ def test_query_region_polygon(self):
5637
assert isinstance(result, Table)
5738

5839
def test_list_catalogs(self):
59-
catalogs = Irsa.list_catalogs(cache=False)
40+
catalogs = Irsa.list_catalogs()
6041
# Number of available catalogs may change over time, test only for significant drop.
61-
# (at the time of writing there are 587 catalogs in the list).
62-
assert len(catalogs) > 500
42+
# (at the time of writing there are 933 tables in the list).
43+
assert len(catalogs) > 900

0 commit comments

Comments
 (0)