Skip to content

Commit

Permalink
Code is sent with subject and test doesn't filter out acq files
Browse files Browse the repository at this point in the history
  • Loading branch information
hkethi002 committed Sep 11, 2017
1 parent 4d96321 commit 0a651e6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
10 changes: 6 additions & 4 deletions api/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,12 @@ def _preflight_archivestream(self, req_spec, collection=None):
subject_prefixes = {}
for session in session_dict.itervalues():
if session.get('subject'):
code = session['subject'].get('code', 'unknown_subject')
# This is bad and we should try to combine these somehow,
# or at least make sure we get all the files
subject_dict[code] = session['subject']
subject = session.get('subject', {'code': 'unknown_subject'})
code = subject.get('code')
if code is None:
code = 'unknown_subject'
subject['code'] = code
subject_dict[code] = subject

for code, subject in subject_dict.iteritems():
subject_prefix = prefix + '/' + self._path_from_container(subject, used_subpaths, ids_of_paths, code)
Expand Down
9 changes: 3 additions & 6 deletions test/integration_tests/python/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,10 @@ def test_download(data_builder, file_form, as_admin, api_db):
r = as_admin.post('/download', json={
'optional': False,
'filters': [{'tags': {
'-': ['minus'],
'+': ['plus']
'-': ['minus']
}}],
'nodes': [
{'level': 'project', '_id': project},
{'level': 'session', '_id': session},
{'level': 'acquisition', '_id': acquisition},
{'level': 'acquisition', '_id':acquisition2},
{'level': 'project', '_id': project},
]
})
assert r.ok
Expand All @@ -60,6 +56,7 @@ def test_download(data_builder, file_form, as_admin, api_db):
# Verify a single file in tar with correct file name
found_second_session = False
for tarinfo in tar:
print tarinfo.name
assert os.path.basename(tarinfo.name) == file_name
if 'session1_0' in str(tarinfo.name):
found_second_session = True
Expand Down

0 comments on commit 0a651e6

Please sign in to comment.