Skip to content

Commit 13d5c59

Browse files
committed
TST: adding test for list_collections() servicetype
1 parent b01b123 commit 13d5c59

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

astroquery/ipac/irsa/core.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -132,22 +132,22 @@ def list_collections(self, servicetype=None):
132132
A table listing all the possible collections for IRSA SIA queries.
133133
"""
134134

135-
servicetype = servicetype.upper()
136-
137135
if not servicetype:
138136
query = "SELECT DISTINCT collection from caom.observation ORDER by collection"
139-
elif servicetype == 'SIA':
140-
query = ("SELECT DISTINCT o.collection FROM caom.observation o "
141-
"JOIN caom.plane p ON o.obsid = p.obsid "
142-
"WHERE (p.dataproducttype = 'image' OR p.dataproducttype = 'cube') "
143-
"order by collection")
144-
elif servicetype == 'SSA':
145-
query = ("SELECT DISTINCT o.collection FROM caom.observation o "
146-
"JOIN caom.plane p ON o.obsid = p.obsid "
147-
"WHERE (p.dataproducttype = 'spectrum' OR p.dataproducttype = 'cube') "
148-
"order by collection")
149137
else:
150-
raise ValueError("if specified, servicetype should be 'SIA' or 'SSA'")
138+
servicetype = servicetype.upper()
139+
if servicetype == 'SIA':
140+
query = ("SELECT DISTINCT o.collection FROM caom.observation o "
141+
"JOIN caom.plane p ON o.obsid = p.obsid "
142+
"WHERE (p.dataproducttype = 'image' OR p.dataproducttype = 'cube') "
143+
"order by collection")
144+
elif servicetype == 'SSA':
145+
query = ("SELECT DISTINCT o.collection FROM caom.observation o "
146+
"JOIN caom.plane p ON o.obsid = p.obsid "
147+
"WHERE (p.dataproducttype = 'spectrum' OR p.dataproducttype = 'cube') "
148+
"order by collection")
149+
else:
150+
raise ValueError("if specified, servicetype should be 'SIA' or 'SSA'")
151151

152152
collections = self.query_tap(query=query)
153153
return collections.to_table()

astroquery/ipac/irsa/tests/test_irsa_remote.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,18 @@ def test_list_catalogs(self):
6767
# (at the time of writing there are 933 tables in the list).
6868
assert len(catalogs) > 900
6969

70-
def test_list_collections(self):
71-
collections = Irsa.list_collections()
70+
@pytest.mark.parametrize('servicetype', (None, 'sia', 'ssa'))
71+
def test_list_collections(self, servicetype):
72+
collections = Irsa.list_collections(servicetype=servicetype)
7273
# Number of available collections may change over time, test only for significant drop.
73-
# (at the time of writing there are 110 collections in the list).
74-
assert len(collections) > 100
75-
assert 'spitzer_seip' in collections['collection']
76-
assert 'wise_allwise' in collections['collection']
74+
# (at the time of writing there are 104 SIA and 35 SSA collections in the list).
75+
if servicetype == 'ssa':
76+
assert len(collections) > 30
77+
assert 'sofia_exes' in collections['collection']
78+
else:
79+
assert len(collections) > 100
80+
assert 'spitzer_seip' in collections['collection']
81+
assert 'wise_allwise' in collections['collection']
7782

7883
def test_tap(self):
7984
query = "SELECT TOP 5 ra,dec FROM cosmos2015"

0 commit comments

Comments
 (0)