Commit 841dedee authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Turned pids from int to str. Fixed linting.

parent 921e7be5
Pipeline #71544 passed with stages
in 13 minutes and 45 seconds
......@@ -57,7 +57,7 @@ proc_model = api.model('Processing', {
calc_metadata_model = api.inherit('CalcMetaData', metadata_model, {
'mainfile': fields.String(description='The calculation main output file is used to identify the calculation in the upload.'),
'_pid': fields.Integer(description='Assign a specific pid. It must be unique.'),
'_pid': fields.String(description='Assign a specific pid. It must be unique.'),
'external_id': fields.String(description='External user provided id. Does not have to be unique necessarily.')
})
......
......@@ -88,9 +88,12 @@ def v0Dot7(upload_data):
''' Inplace transforms v0.7.x upload data into v0.8.x upload data. '''
print(__mongo_properties)
for calc in upload_data['calcs']:
calc_metadata = calc['metadata']
if 'pid' in calc_metadata:
calc_metadata['pid'] = str(calc_metadata['pid'])
metadata = {
key: value
for key, value in calc['metadata'].items()
for key, value in calc_metadata.items()
if key in __mongo_properties
}
entry_metadata = EntryMetadata(**metadata)
......
......@@ -281,7 +281,7 @@ class EntryMetadata(metainfo.MSection):
many_or='append', name='files', search_field='files.keyword')])
pid = metainfo.Quantity(
type=int,
type=str,
description='The unique, sequentially enumerated, integer persistent identifier',
categories=[MongoMetadata],
a_search=Search(many_or='append'))
......
......@@ -270,7 +270,7 @@ class TestUploads:
'references': lambda e: e.references,
'coauthors': lambda e: [u.user_id for u in e.coauthors],
'_uploader': lambda e: e.uploader.user_id,
'_pid': lambda e: e.pid,
'_pid': lambda e: str(e.pid),
'external_id': lambda e: e.external_id}.items():
if key in metadata:
assert transform(entry) == metadata[key], key
......@@ -451,7 +451,7 @@ class TestUploads:
rv = api.post(
'/uploads/%s' % upload['upload_id'],
headers=test_user_auth,
data=json.dumps(dict(operation='publish', metadata=dict(_pid=256))),
data=json.dumps(dict(operation='publish', metadata=dict(_pid='256'))),
content_type='application/json')
assert rv.status_code == 401
......@@ -732,7 +732,7 @@ class TestRepo():
entry_metadata.m_update(
calc_id='2', uploader=other_test_user.user_id, published=True,
with_embargo=False, pid=2, upload_time=today_datetime - datetime.timedelta(days=5),
with_embargo=False, pid='2', upload_time=today_datetime - datetime.timedelta(days=5),
external_id='external_2')
entry_metadata.m_update(
atoms=['Fe'], comment='this is a specific word', formula='AAA')
......@@ -741,12 +741,12 @@ class TestRepo():
entry_metadata.m_update(
calc_id='3', uploader=other_test_user.user_id, published=False,
with_embargo=False, pid=3, external_id='external_3')
with_embargo=False, pid='3', external_id='external_3')
entry_metadata.a_elastic.index(refresh=True)
entry_metadata.m_update(
calc_id='4', uploader=other_test_user.user_id, published=True,
with_embargo=True, pid=4, external_id='external_4')
with_embargo=True, pid='4', external_id='external_4')
entry_metadata.a_elastic.index(refresh=True)
yield
......
......@@ -513,7 +513,7 @@ def example_user_metadata(other_test_user, test_user) -> dict:
'_uploader': other_test_user.user_id,
'coauthors': [test_user.user_id],
'_upload_time': datetime.datetime.utcnow(),
'_pid': 256,
'_pid': '256',
'external_id': 'external_test_id'
}
......
......@@ -601,7 +601,8 @@ class TestM1:
section = TestSection()
assert section.int_quantity == 0
assert section.float_quantity == 0.0
assert section.bool_quantity == False
assert section.bool_quantity is False
class TestDatatypes:
......
......@@ -75,7 +75,7 @@ def generate_calc(pid: int = 0, calc_id: str = None, upload_id: str = None) -> d
entry.upload_time = datetime.datetime.utcnow()
entry.calc_hash = utils.create_uuid()
entry.pid = pid
entry.pid = str(pid)
entry.mainfile = random.choice(filepaths)
entry.files = list([entry.mainfile] + random.choices(filepaths, k=random.choice(low_numbers_for_files)))
entry.uploader = _gen_user()
......
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