Commit f9476740 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Merge branch 'v0.7.6' into 'master'

V0.7.6

See merge request !95
parents a063d537 83f50cfe
Pipeline #69280 passed with stage
in 26 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,
......
......@@ -306,11 +306,12 @@ def mirror(
if upload_data.datasets is not None:
for dataset in upload_data.datasets.values():
fix_time(dataset, ['created'])
_Dataset._get_collection().insert(dataset)
_Dataset._get_collection().update(dict(_id=dataset['_id']), dataset, upsert=True)
if upload_data.dois is not None:
for doi in upload_data.dois.values():
fix_time(doi, ['create_time'])
DOI._get_collection().insert(doi)
if doi is not None and DOI.objects(doi=doi).first() is None:
fix_time(doi, ['create_time'])
DOI._get_collection().update(dict(_id=doi['_id']), doi, upsert=True)
for calc in upload_data.calcs:
fix_time(calc, ['create_time', 'complete_time'])
fix_time(calc['metadata'], ['upload_time', 'last_processing'])
......
......@@ -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