Skip to content
Snippets Groups Projects
Commit 95316aef authored by Harsha Kethineni's avatar Harsha Kethineni
Browse files

added tests and fixed up typos

parent 9eed0356
No related branches found
No related tags found
No related merge requests found
......@@ -339,7 +339,7 @@ class Download(base.RequestHandler):
# for each type of container below it will have a slightly modified match query
cont_query = {
'projects': {'_id': {'project': req['_id']}},
'projects': {'_id': req['_id']},
'sessions': {'project': req['_id']},
'acquisitions': {'session': {'$in': session_ids}},
'analyses': {'parent.id': {'$in': parent_ids}}
......@@ -382,8 +382,7 @@ class Download(base.RequestHandler):
try:
result = config.db.command('aggregate', cont_name, pipeline=pipeline)
except Exception as e: # pylint: disable=broad-except
result = e
return result
return e
if result.get("ok"):
for doc in result.get("result"):
......
......@@ -399,3 +399,38 @@ def test_filters(data_builder, file_form, as_admin):
})
assert r.ok
assert r.json()['file_cnt'] == 1
def test_summary(data_builder, as_admin, file_form):
project = data_builder.create_project(label='project1')
session = data_builder.create_session(label='session1')
session2 = data_builder.create_session(label='session1')
acquisition = data_builder.create_acquisition(session=session)
acquisition2 = data_builder.create_acquisition(session=session2)
# upload the same file to each container created and use different tags to
# facilitate download filter tests:
# acquisition: [], session: ['plus'], project: ['plus', 'minus']
file_name = 'test.csv'
as_admin.post('/acquisitions/' + acquisition + '/files', files=file_form(
file_name, meta={'name': file_name, 'type': 'csv'}))
as_admin.post('/acquisitions/' + acquisition2 + '/files', files=file_form(
file_name, meta={'name': file_name, 'type': 'csv'}))
as_admin.post('/sessions/' + session + '/files', files=file_form(
file_name, meta={'name': file_name, 'type': 'csv', 'tags': ['plus']}))
as_admin.post('/projects/' + project + '/files', files=file_form(
file_name, meta={'name': file_name, 'type': 'csv', 'tags': ['plus', 'minus']}))
missing_object_id = '000000000000000000000000'
r = as_admin.post('/download/summary', json={"level":"projects", "_id":project})
assert r.ok
assert len(r.json()) == 1
assert r.json().get("csv", {}).get("count",0) == 4
r = as_admin.post('/download/summary', json={"level":"sessions", "_id":session})
assert r.ok
assert len(r.json()) == 1
assert r.json().get("csv", {}).get("count",0) == 2
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