Skip to content

Commit 59ff73e

Browse files
committed
Updated tests and fixed queries.
1 parent a077dd1 commit 59ff73e

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

astroquery/alma/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ def is_proprietary(self, uid):
606606
proprietary or not.
607607
"""
608608
query = "select distinct data_rights from ivoa.obscore where " \
609-
"obs_id='{}'".format(uid)
609+
"member_ous_uid='{}'".format(uid)
610610
result = self.query_tap(query)
611611
if result:
612612
tableresult = result.to_table()

astroquery/alma/tests/test_alma.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,12 @@ def test_pol_sql():
246246
def test_unused_args():
247247
alma = Alma()
248248
alma._get_dataarchive_url = Mock()
249-
with patch('astroquery.alma.tapsql.coord.SkyCoord.from_name') as name_mock, pytest.raises(TypeError) as typeError:
250-
name_mock.return_value = SkyCoord(1, 2, unit='deg')
251-
alma.query_object('M13', public=False, bogus=True, nope=False, band_list=[3])
249+
# with patch('astroquery.alma.tapsql.coord.SkyCoord.from_name') as name_mock, pytest.raises(TypeError) as typeError:
250+
with patch('astroquery.alma.tapsql.coord.SkyCoord.from_name') as name_mock:
251+
with pytest.raises(TypeError) as typeError:
252+
name_mock.return_value = SkyCoord(1, 2, unit='deg')
253+
alma.query_object('M13', public=False, bogus=True, nope=False, band_list=[3])
254+
252255
assert "['bogus -> True', 'nope -> False']" in str(typeError.value)
253256

254257

astroquery/alma/tests/test_alma_remote.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ def test_freq(self, alma):
8787

8888
def test_bands(self, alma):
8989
payload = {'band_list': ['5', '7']}
90-
result = alma.query(payload)
90+
# Added maxrec here as downloading and reading the results take too long.
91+
result = alma.query(payload, maxrec=1000)
9192
assert len(result) > 0
9293
for row in result:
9394
assert ('5' in row['band_list']) or ('7' in row['band_list'])
@@ -136,7 +137,7 @@ def test_data_proprietary(self, alma):
136137
assert not alma.is_proprietary('uid://A001/X12a3/Xe9')
137138
IVOA_DATE_FORMAT = "%Y-%m-%dT%H:%M:%S.%f"
138139
now = datetime.utcnow().strftime(IVOA_DATE_FORMAT)[:-3]
139-
query = "select top 1 obs_id from ivoa.obscore where " \
140+
query = "select top 1 member_ous_uid from ivoa.obscore where " \
140141
"obs_release_date > '{}'".format(now)
141142
result = alma.query_tap(query)
142143
assert len(result.table) == 1
@@ -146,6 +147,7 @@ def test_data_proprietary(self, alma):
146147
with pytest.raises(AttributeError):
147148
alma.is_proprietary('uid://NON/EXI/STING')
148149

150+
@pytest.mark.xfail(reason="Depends on PR 2438 (https://github.com/astropy/astroquery/pull/2438)")
149151
def test_data_info(self, temp_dir, alma):
150152
alma.cache_location = temp_dir
151153

@@ -257,6 +259,7 @@ def test_doc_example(self, temp_dir, alma):
257259
gc_data = alma.query_region(galactic_center, 1 * u.deg)
258260
# assert len(gc_data) >= 425 # Feb 8, 2016
259261
assert len(gc_data) >= 50 # Nov 16, 2016
262+
content_length_column_name = 'content_length'
260263

261264
uids = np.unique(m83_data['Member ous id'])
262265
if ASTROPY_LT_4_1:
@@ -271,11 +274,11 @@ def test_doc_example(self, temp_dir, alma):
271274
assert X30.sum() == 4 # Jul 13, 2020
272275
assert X31.sum() == 4 # Jul 13, 2020
273276
mous1 = alma.get_data_info('uid://A001/X11f/X30')
274-
totalsize_mous1 = mous1['size'].sum() * u.Unit(mous1['size'].unit)
277+
totalsize_mous1 = mous1[content_length_column_name].sum() * u.Unit(mous1[content_length_column_name].unit)
275278
assert (totalsize_mous1.to(u.B) > 1.9*u.GB)
276279

277280
mous = alma.get_data_info('uid://A002/X3216af/X31')
278-
totalsize_mous = mous['size'].sum() * u.Unit(mous['size'].unit)
281+
totalsize_mous = mous[content_length_column_name].sum() * u.Unit(mous[content_length_column_name].unit)
279282
# More recent ALMA request responses do not include any information
280283
# about file size, so we have to allow for the possibility that all
281284
# file sizes are replaced with -1
@@ -313,11 +316,13 @@ def test_misc(self, alma):
313316
result = alma.query(payload={'pi_name': '*Bally*'}, public=False,
314317
maxrec=10)
315318
assert result
316-
result.write('/tmp/alma-onerow.txt', format='ascii')
319+
# Add overwrite=True in case the test previously died unexpectedly
320+
# and left the temp file.
321+
result.write('/tmp/alma-onerow.txt', format='ascii', overwrite=True)
317322
for row in result:
318323
assert 'Bally' in row['obs_creator_name']
319324
result = alma.query(payload=dict(project_code='2016.1.00165.S'),
320-
public=False, cache=False)
325+
public=False)
321326
assert result
322327
for row in result:
323328
assert '2016.1.00165.S' == row['proposal_id']
@@ -336,8 +341,7 @@ def test_misc(self, alma):
336341

337342
result = alma.query_region(
338343
coordinates.SkyCoord('5:35:14.461 -5:21:54.41', frame='fk5',
339-
unit=(u.hour, u.deg)), radius=0.034 * u.deg,
340-
payload={'energy.frequency-asu': '215 .. 220'})
344+
unit=(u.hour, u.deg)), radius=0.034 * u.deg)
341345

342346
result = alma.query(payload=dict(project_code='2012.*',
343347
public_data=True))

0 commit comments

Comments
 (0)