Skip to content

Commit 4f5a927

Browse files
committed
Cleaning up stage_data usage from tests
1 parent 8904740 commit 4f5a927

File tree

1 file changed

+12
-88
lines changed

1 file changed

+12
-88
lines changed

astroquery/alma/tests/test_alma_remote.py

Lines changed: 12 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def test_m83(self, temp_dir, alma):
135135

136136
m83_data = alma.query_object('M83', science=True, legacy_columns=True)
137137
uids = np.unique(m83_data['Member ous id'])
138-
link_list = alma.stage_data(uids)
138+
link_list = alma.get_data_info(uids)
139139

140140
# On Feb 8, 2016 there were 83 hits. This number should never go down.
141141
# Except it has. On May 18, 2016, there were 47.
@@ -156,82 +156,6 @@ def test_m83(self, temp_dir, alma):
156156
# 'same UIDs, the result returned is probably correct,'
157157
# ' otherwise you may need to create a fresh astroquery.Alma instance.'))
158158

159-
@pytest.mark.skipif("SKIP_SLOW", reason="Known issue")
160-
def test_stage_data(self, temp_dir, alma):
161-
alma.cache_location = temp_dir
162-
163-
result_s = alma.query_object('Sgr A*', legacy_columns=True)
164-
165-
if ASTROPY_LT_4_1:
166-
assert b'2013.1.00857.S' in result_s['Project code']
167-
assert b'uid://A002/X40d164/X1b3' in result_s['Asdm uid']
168-
assert b'uid://A002/X391d0b/X23d' in result_s['Member ous id']
169-
match_val = b'uid://A002/X40d164/X1b3'
170-
else:
171-
assert '2013.1.00857.S' in result_s['Project code']
172-
assert 'uid://A002/X40d164/X1b3' in result_s['Asdm uid']
173-
assert 'uid://A002/X391d0b/X23d' in result_s['Member ous id']
174-
match_val = 'uid://A002/X40d164/X1b3'
175-
176-
match = result_s['Asdm uid'] == match_val
177-
uid = result_s['Member ous id'][match]
178-
# this is temporary to switch back to ALMA servers
179-
# del alma.dataarchive_url
180-
# alma.archive_url = 'http://almascience.org'
181-
result = alma.stage_data(uid)
182-
183-
found = False
184-
for url in result['URL']:
185-
if 'uid___A002_X40d164_X1b3' in url:
186-
found = True
187-
break
188-
assert found, 'URL to uid___A002_X40d164_X1b3 expected'
189-
190-
def test_stage_data_listall(self, temp_dir, alma):
191-
"""
192-
test for expanded capability created in #1683
193-
"""
194-
alma.cache_location = temp_dir
195-
196-
uid = 'uid://A001/X12a3/Xe9'
197-
result1 = alma.stage_data(uid, expand_tarfiles=False)
198-
result2 = alma.stage_data(uid, expand_tarfiles=True)
199-
200-
expected_names = [
201-
'2017.1.01185.S_uid___A002_Xd28a9e_X71b8.asdm.sdm.tar',
202-
'2017.1.01185.S_uid___A002_Xd28a9e_X7b4d.asdm.sdm.tar',
203-
'2017.1.01185.S_uid___A002_Xd29c1f_X1f74.asdm.sdm.tar',
204-
'2017.1.01185.S_uid___A002_Xd29c1f_X5cf.asdm.sdm.tar']
205-
expected_names_with_aux = expected_names + \
206-
['2017.1.01185.S_uid___A001_X12a3_Xe9_auxiliary.tar']
207-
for name in expected_names_with_aux:
208-
assert name in result1['name']
209-
for res in result1:
210-
p = re.compile(r'.*(uid__.*)\.asdm.*')
211-
if res['name'] in expected_names:
212-
assert 'application/x-tar' == res['type']
213-
assert res['id'] == p.search(res['name']).group(1)
214-
else:
215-
assert res['type'] in ['application/x-tar', 'application/x-votable+xml;content=datalink', 'text/plain']
216-
assert res['id'] == 'None'
217-
assert 'UNKNOWN' == res['permission']
218-
assert res['mous_uid'] == uid
219-
assert len(result2) > len(result1)
220-
221-
def test_stage_data_json(self, temp_dir, alma):
222-
"""
223-
test for json returns
224-
"""
225-
alma.cache_location = temp_dir
226-
227-
uid = 'uid://A001/X12a3/Xe9'
228-
# this is temporary to switch back to ALMA servers
229-
# alma.archive_url = 'http://almascience.org'
230-
result = alma.stage_data(uid, return_json=False)
231-
assert len(result) > 0
232-
with pytest.raises(AttributeError):
233-
# this no longer works
234-
alma.stage_data(uid, return_json=True)
235159

236160
def test_data_proprietary(self, alma):
237161
# public
@@ -372,11 +296,11 @@ def test_doc_example(self, temp_dir, alma):
372296

373297
assert X30.sum() == 4 # Jul 13, 2020
374298
assert X31.sum() == 4 # Jul 13, 2020
375-
mous1 = alma.stage_data('uid://A001/X11f/X30')
299+
mous1 = alma.get_data_info('uid://A001/X11f/X30')
376300
totalsize_mous1 = mous1['size'].sum() * u.Unit(mous1['size'].unit)
377301
assert (totalsize_mous1.to(u.B) > 1.9*u.GB)
378302

379-
mous = alma.stage_data('uid://A002/X3216af/X31')
303+
mous = alma.get_data_info('uid://A002/X3216af/X31')
380304
totalsize_mous = mous['size'].sum() * u.Unit(mous['size'].unit)
381305
# More recent ALMA request responses do not include any information
382306
# about file size, so we have to allow for the possibility that all
@@ -493,9 +417,9 @@ def test_cycle1(self, temp_dir, alma):
493417

494418
# Need new Alma() instances each time
495419
a1 = alma()
496-
uid_url_table_mous = a1.stage_data(result['Member ous id'])
420+
uid_url_table_mous = a1.get_data_info(result['Member ous id'])
497421
a2 = alma()
498-
uid_url_table_asdm = a2.stage_data(result['Asdm uid'])
422+
uid_url_table_asdm = a2.get_data_info(result['Asdm uid'])
499423
# I believe the fixes as part of #495 have resulted in removal of a
500424
# redundancy in the table creation, so a 1-row table is OK here.
501425
# A 2-row table may not be OK any more, but that's what it used to
@@ -542,8 +466,8 @@ def test_cycle0(self, temp_dir, alma):
542466

543467
alma1 = alma()
544468
alma2 = alma()
545-
uid_url_table_mous = alma1.stage_data(result['Member ous id'])
546-
uid_url_table_asdm = alma2.stage_data(result['Asdm uid'])
469+
uid_url_table_mous = alma1.get_data_info(result['Member ous id'])
470+
uid_url_table_asdm = alma2.get_data_info(result['Asdm uid'])
547471
assert len(uid_url_table_asdm) == 1
548472
assert len(uid_url_table_mous) == 32
549473

@@ -609,7 +533,7 @@ def test_project_metadata(alma):
609533
@pytest.mark.skip('Not working for now - Investigating')
610534
def test_staging_postfeb2020(alma):
611535

612-
tbl = alma.stage_data('uid://A001/X121/X4ba')
536+
tbl = alma.get_data_info('uid://A001/X121/X4ba')
613537

614538
assert 'mous_uid' in tbl.colnames
615539

@@ -619,7 +543,7 @@ def test_staging_postfeb2020(alma):
619543
@pytest.mark.remote_data
620544
@pytest.mark.skip('Not working for now - Investigating')
621545
def test_staging_uptofeb2020(alma):
622-
tbl = alma.stage_data('uid://A001/X121/X4ba')
546+
tbl = alma.get_data_info('uid://A001/X121/X4ba')
623547

624548
assert 'mous_uid' in tbl.colnames
625549

@@ -629,9 +553,9 @@ def test_staging_uptofeb2020(alma):
629553

630554

631555
@pytest.mark.remote_data
632-
def test_staging_stacking(alma):
633-
alma.stage_data(['uid://A001/X13d5/X1d', 'uid://A002/X3216af/X31',
634-
'uid://A001/X12a3/X240'])
556+
def test_data_info_stacking(alma):
557+
alma.get_data_info(['uid://A001/X13d5/X1d', 'uid://A002/X3216af/X31',
558+
'uid://A001/X12a3/X240'])
635559

636560

637561
@pytest.mark.remote_data

0 commit comments

Comments
 (0)