Skip to content
Snippets Groups Projects
Commit 7e06aab6 authored by Harsha Kethineni's avatar Harsha Kethineni Committed by Megan Henning
Browse files

test for #917

parent f6ce28c4
No related branches found
No related tags found
No related merge requests found
......@@ -67,6 +67,41 @@ def test_download(data_builder, file_form, as_admin, api_db):
tar.close()
# Download one session with many acquisitions and make sure they are in the same subject folder
acquisition3 = data_builder.create_acquisition(session=session)
r = as_admin.post('/acquisitions/' + acquisition3 + '/files', files=file_form(
file_name, meta={'name': file_name, 'type': 'csv'}))
assert r.ok
r = as_admin.post('/download', json={
'optional': False,
'nodes': [
{'level': 'acquisition', '_id': acquisition},
{'level': 'acquisition', '_id': acquisition3},
]
})
assert r.ok
ticket = r.json()['ticket']
# Perform the download
r = as_admin.get('/download', params={'ticket': ticket})
assert r.ok
tar_file = cStringIO.StringIO(r.content)
tar = tarfile.open(mode="r", fileobj=tar_file)
# Verify a single file in tar with correct file name
found_second_session = False
for tarinfo in tar:
assert os.path.basename(tarinfo.name) == file_name
if 'session1_0' in str(tarinfo.name):
found_second_session = True
assert not found_second_session
tar.close()
# Try to perform the download from a different IP
update_result = api_db.downloads.update_one(
{'_id': ticket},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment