diff --git a/CHANGELOG.md b/CHANGELOG.md index aca13b7ec56f0726ccf0f85861c7319366576656..ea8d8b58c6749df317f84b8cbe5e500a5fa62d6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added (for new features) +* Test for [caosdb-pylib#89](https://gitlab.com/linkahead/linkahead-pylib/-/issues/89) * Tests for entity state [caosdb-server!62](https://gitlab.com/caosdb/caosdb-server/-/merge_requests/62) * Tests for version history * Tests for inheritance bug (caosdb/caosdb-server!54) diff --git a/tests/test_issues_pylib.py b/tests/test_issues_pylib.py index ec9e873c7b8cd2375570021672bb8eb2bc1ca5c3..49203bc2439e53616f5cd9c3867f54e5d2159d4e 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,30 @@ 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 + rt = db.RecordType(name="TestType") + rt.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()) + cont_from_xml = db.Container.from_xml(xml_str) + assert len(cont_from_xml) == len(container) + assert cont_from_xml[0].name == rt.name + + # @pytest.mark.xfail(reason="Entities with many, long, properties: " # "https://gitlab.com/linkahead/linkahead-pylib/-/issues/108") def test_gitlab_com_108():