From 4a6142f669c5a34274944c87c955f9eeb2ce66fe Mon Sep 17 00:00:00 2001 From: Harsha Kethineni Date: Mon, 11 Sep 2017 12:15:48 -0500 Subject: [PATCH] Code is sent with subject and test doesn't filter out acq files --- api/download.py | 10 ++++++---- test/integration_tests/python/test_download.py | 8 ++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/api/download.py b/api/download.py index 26e947c46..99a4a3d51 100644 --- a/api/download.py +++ b/api/download.py @@ -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) diff --git a/test/integration_tests/python/test_download.py b/test/integration_tests/python/test_download.py index 3a722cfb2..94452c918 100644 --- a/test/integration_tests/python/test_download.py +++ b/test/integration_tests/python/test_download.py @@ -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