Skip to content
Snippets Groups Projects
Verified Commit af843d65 authored by Daniel Hornung's avatar Daniel Hornung
Browse files

TEST: Added unit test for high level api serialization.

parent 49382a8f
Branches
Tags
2 merge requests!189ENH: add convenience functions,!185High level API serialization
Pipeline #62589 passed
......@@ -322,6 +322,7 @@ def test_wrong_entity_for_file():
def test_serialization():
# With ID
r = db.Record(id=5, name="test", description="ok")
r.add_property(name="v", value=15, datatype=db.INTEGER, unit="kpx",
importance="RECOMMENDED")
......@@ -333,6 +334,22 @@ def test_serialization():
for teststr in teststrs:
assert teststr in text
serialized = convert_to_python_object(r).serialize()
assert serialized == {'role': 'Record',
'name': 'test',
'id': 5,
'description': 'ok',
'properties': {'v': 15},
'parents': [],
'metadata': {'v': {'unit': 'kpx',
'datatype': 'INTEGER',
'importance': 'RECOMMENDED'}}}
serialized_plain = convert_to_python_object(r).serialize(plain_json=True)
assert serialized_plain == {'id': 5, 'name': 'test', 'v': 15}
# Without ID
r = db.Record(description="ok")
r.add_property(name="v", value=15, datatype=db.INTEGER, unit="kpx",
importance="RECOMMENDED")
......@@ -341,6 +358,18 @@ def test_serialization():
assert "name" not in text
assert "id" not in text
serialized = convert_to_python_object(r).serialize()
assert serialized == {'role': 'Record',
'description': 'ok',
'properties': {'v': 15},
'parents': [],
'metadata': {'v': {'unit': 'kpx',
'datatype': 'INTEGER',
'importance': 'RECOMMENDED'}}}
serialized_plain = convert_to_python_object(r).serialize(plain_json=True)
assert serialized_plain == {'id': None, 'name': None, 'v': 15}
def test_files():
# empty file:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment