Skip to content
Snippets Groups Projects
Unverified Commit 3b28d68e authored by Nathaniel Kofalt's avatar Nathaniel Kofalt Committed by GitHub
Browse files

Merge pull request #979 from scitran/unique-checks-are-hard

Correct match_ids in containerhandler.get_jobs
parents 34ba2bb4 629c9286
No related branches found
Tags 1.0.77
No related merge requests found
......@@ -271,9 +271,9 @@ class ContainerHandler(base.RequestHandler):
# Stateful closure to remove search duplicates
# Eventually, this code should not call Queue.search and should instead do its own work.
def match_ids(x):
should_add = str(x['_id']) in match_ids.unique_job_ids
in_set = str(x['_id']) in match_ids.unique_job_ids
match_ids.unique_job_ids.add(str(x['_id']))
return should_add
return not in_set
match_ids.unique_job_ids = set()
results = filter(match_ids, results)
......
......@@ -21,6 +21,8 @@ def test_jobs_access(as_user):
def test_jobs(data_builder, default_payload, as_public, as_user, as_admin, as_root, api_db, file_form):
# Dupe of test_queue.py
gear_doc = default_payload['gear']['gear']
gear_doc['inputs'] = {
'dicom': {
......
def test_queue_search(data_builder, default_payload, as_admin, file_form):
# Dupe of test_jobs.py
gear_doc = default_payload['gear']['gear']
gear_doc['inputs'] = {
'dicom': {
'base': 'file'
}
}
gear = data_builder.create_gear(gear=gear_doc, category='utility')
project = data_builder.create_project()
session = data_builder.create_session()
acquisition = data_builder.create_acquisition()
assert as_admin.post('/acquisitions/' + acquisition + '/files', files=file_form('test.zip')).ok
job_data = {
'gear_id': gear,
'inputs': {
'dicom': {
'type': 'acquisition',
'id': acquisition,
'name': 'test.zip'
}
},
'config': { 'two-digit multiple of ten': 20 },
'destination': {
'type': 'acquisition',
'id': acquisition
},
'tags': [ 'test-tag' ]
}
r = as_admin.post('/jobs/add', json=job_data)
assert r.ok
utility_id = r.json()['_id']
r = as_admin.get('/sessions/' + session + '/jobs?join=gears')
assert r.ok
assert(any(x['id'] == utility_id for x in r.json()['jobs']))
ana_gear_id = data_builder.create_gear(gear=gear_doc, category='analysis')
job_data['gear_id'] = ana_gear_id
r = as_admin.post('/jobs/add', json=job_data)
assert r.ok
ana_id = r.json()['_id']
r = as_admin.get('/sessions/' + session + '/jobs?join=gears')
assert r.ok
assert(any(x['id'] == utility_id for x in r.json()['jobs']))
assert(any(x['id'] == ana_id for x in r.json()['jobs']))
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