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

ENH: Improved test for xml serialization. #89

parent da66ac22
Branches
Tags
No related merge requests found
Pipeline #34452 failed
...@@ -140,8 +140,6 @@ def test_container_xml(tmp_path): ...@@ -140,8 +140,6 @@ def test_container_xml(tmp_path):
For issue 89: https://gitlab.com/caosdb/caosdb-pylib/-/issues/89 For issue 89: https://gitlab.com/caosdb/caosdb-pylib/-/issues/89
""" """
with warnings.catch_warnings():
# Create XML with container with one RecordType. # Create XML with container with one RecordType.
db.RecordType(name="TestRT").insert() db.RecordType(name="TestRT").insert()
cont = db.execute_query("FIND RecordType TestRT") cont = db.execute_query("FIND RecordType TestRT")
...@@ -152,7 +150,11 @@ For issue 89: https://gitlab.com/caosdb/caosdb-pylib/-/issues/89 ...@@ -152,7 +150,11 @@ For issue 89: https://gitlab.com/caosdb/caosdb-pylib/-/issues/89
# Read from file again. # Read from file again.
with open(xml_file, "r", encoding="utf-8") as opened: with open(xml_file, "r", encoding="utf-8") as opened:
xml_str = opened.read() xml_str = opened.read()
with warnings.catch_warnings(record=True) as raised_warnings:
cont_restored = db.Container.from_xml(xml_str) cont_restored = db.Container.from_xml(xml_str)
assert not raised_warnings, (
f"Loading from xml did not run smoothly.\n{raised_warnings[0].message}"
)
# Test if the serialization and deserialization worked. # Test if the serialization and deserialization worked.
assert cont[0].id == cont_restored[0].id assert cont[0].id == cont_restored[0].id
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment