Skip to content

Commit

Permalink
Added tests for other engine upload containers
Browse files Browse the repository at this point in the history
  • Loading branch information
hkethi002 committed Mar 9, 2018
1 parent 9aebeff commit 5c6e8d4
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions tests/integration_tests/python/test_uploads.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,14 +777,19 @@ def test_session_engine_upload(data_builder, file_form, as_root):
'name': 'two.csv',
'type': 'engine type 1',
'info': {'test': 'f1'}
},
{
'name': 'folder:three.csv',
'type': 'engine type 2',
'info': {'test': 'f2'}
}
]
}
}

r = as_root.post('/engine',
params={'level': 'session', 'id': session},
files=file_form('one.csv', 'two.csv', meta=metadata)
files=file_form('one.csv', 'two.csv', 'folder:three.csv', meta=metadata)
)
assert r.ok

Expand All @@ -807,7 +812,11 @@ def test_session_engine_upload(data_builder, file_form, as_root):
assert s_timestamp == m_timestamp

for f in s['files']:
mf = find_file_in_array(f['name'], metadata['session']['files'])
if '/' in f['name']:
assert f['name'] == 'folder/three.csv'
mf = find_file_in_array(f['name'].replace('/', ':'), metadata['session']['files'])
else:
mf = find_file_in_array(f['name'], metadata['session']['files'])
assert mf is not None
assert f['type'] == mf['type']
assert f['info'] == mf['info']
Expand All @@ -829,14 +838,19 @@ def test_project_engine_upload(data_builder, file_form, as_root):
'name': 'two.csv',
'type': 'engine type 1',
'info': {'test': 'f1'}
},
{
'name': 'folder:three.csv',
'type': 'engine type 2',
'info': {'test': 'f2'}
}
]
}
}

r = as_root.post('/engine',
params={'level': 'project', 'id': project},
files=file_form('one.csv', 'two.csv', meta=metadata)
files=file_form('one.csv', 'two.csv', 'folder:three.csv', meta=metadata)
)
assert r.ok

Expand All @@ -848,15 +862,20 @@ def test_project_engine_upload(data_builder, file_form, as_root):
assert p['info'] == metadata['project']['info']

for f in p['files']:
mf = find_file_in_array(f['name'], metadata['project']['files'])
if '/' in f['name']:
assert f['name'] == 'folder/three.csv'
mf = find_file_in_array(f['name'].replace('/', ':'), metadata['project']['files'])
else:
mf = find_file_in_array(f['name'], metadata['project']['files'])
assert mf is not None
assert f['type'] == mf['type']
assert f['info'] == mf['info']


def test_acquisition_file_only_engine_upload(data_builder, file_form, as_root):
acquisition = data_builder.create_acquisition()
file_names = ['one.csv', 'two.csv']
file_names = ['one.csv', 'folder:two.csv']
expected_file_names = ['one.csv', 'folder/two.csv']

r = as_root.post('/engine',
params={'level': 'acquisition', 'id': acquisition},
Expand All @@ -866,7 +885,7 @@ def test_acquisition_file_only_engine_upload(data_builder, file_form, as_root):

r = as_root.get('/acquisitions/' + acquisition)
assert r.ok
assert set(f['name'] for f in r.json()['files']) == set(file_names)
assert set(f['name'] for f in r.json()['files']) == set(expected_file_names)


def test_acquisition_subsequent_file_engine_upload(data_builder, file_form, as_root):
Expand Down

0 comments on commit 5c6e8d4

Please sign in to comment.