Commit 83f50cfe authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Minor fixes to mirror API.

parent cc1c1e00
Pipeline #69329 passed with stages
in 32 minutes and 30 seconds
......@@ -103,7 +103,9 @@ class MirrorUploadResource(Resource):
datasets[dataset] = _Dataset._get_collection().find_one(dict(_id=dataset))
doi = datasets[dataset].get('doi', None)
if doi is not None:
dois[doi] = DOI._get_collection().find_one(dict(_id=doi))
doi_obj = DOI._get_collection().find_one(dict(_id=doi))
if doi_obj is not None:
dois[doi] = doi_obj
return {
'upload_id': upload_id,
......
......@@ -1624,7 +1624,8 @@ class TestMirror:
data = json.loads(rv.data)
assert data[0]['upload_id'] == published.upload_id
def test_dataset(self, api, published_wo_user_metadata, admin_user_auth, test_user_auth):
@pytest.mark.parametrize('with_doi', [False, True])
def test_dataset(self, api, published_wo_user_metadata, admin_user_auth, test_user_auth, with_doi):
rv = api.post(
'/repo/edit', headers=test_user_auth, content_type='application/json',
data=json.dumps({
......@@ -1636,8 +1637,9 @@ class TestMirror:
}))
assert rv.status_code == 200
rv = api.post('/datasets/test_dataset', headers=test_user_auth)
assert rv.status_code == 200
if with_doi:
rv = api.post('/datasets/test_dataset', headers=test_user_auth)
assert rv.status_code == 200
rv = api.post(
'/mirror/',
......@@ -1651,8 +1653,12 @@ class TestMirror:
assert len(data['datasets']) == 1
dataset = data['calcs'][0]['metadata']['datasets'][0]
assert dataset in data['datasets']
assert data['datasets'][dataset]['doi'] is not None
assert data['datasets'][dataset]['doi'] in data['dois']
if with_doi:
assert len(data['dois']) == 1
assert data['datasets'][dataset]['doi'] is not None
assert data['datasets'][dataset]['doi'] in data['dois']
else:
assert 'dois' not in data
class TestDataset:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment