Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/handlers/containerhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ def get_jobs(self, cid):
# 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)
Expand Down
2 changes: 2 additions & 0 deletions test/integration_tests/python/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand Down
53 changes: 53 additions & 0 deletions test/integration_tests/python/test_queue.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

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']))