diff --git a/tests/test_issues_pylib.py b/tests/test_issues_pylib.py index ec9e873c7b8cd2375570021672bb8eb2bc1ca5c3..eeae1a4d1831d1f9fa59f240575993c9d89903d5 100644 --- a/tests/test_issues_pylib.py +++ b/tests/test_issues_pylib.py @@ -28,8 +28,10 @@ import math import os import tempfile import time +import warnings import linkahead as db +import linkahead.common.utils import pytest from linkahead import administration as admin @@ -66,6 +68,27 @@ def teardown_function(function): # ########################### Issue tests start here ##################### +def test_gitlab_com_89(): + """ + Test that after retrieving an entity from the server, generating an xml + string and subsequently recreating the container from xml does not + generate any errors. + + See https://gitlab.com/linkahead/linkahead-pylib/-/issues/89 and + https://gitlab.indiscale.com/caosdb/customers/f-fit/management/-/issues/81 + """ + # We need a container generated with data from the server + db.RecordType(id=1, name="1").insert() + container = db.execute_query("FIND RECORDTYPE *") + + # With this container, to_xml, xml2str, and from_xml should not generate + # warnings - the simplefilter means that any warning fails the test + with warnings.catch_warnings(): + warnings.simplefilter("error") + xml_str = linkahead.common.utils.xml2str(container.to_xml()) + db.Container.from_xml(xml_str) + + # @pytest.mark.xfail(reason="Entities with many, long, properties: " # "https://gitlab.com/linkahead/linkahead-pylib/-/issues/108") def test_gitlab_com_108():