From 7986866e089f68ec640bf6ecd164c8f22101089e Mon Sep 17 00:00:00 2001
From: "i.nueske" <i.nueske@indiscale.com>
Date: Fri, 22 Nov 2024 08:48:36 +0100
Subject: [PATCH] TST: Added test for
 https://gitlab.com/linkahead/linkahead-pylib/-/issues/89

---
 tests/test_issues_pylib.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/tests/test_issues_pylib.py b/tests/test_issues_pylib.py
index ec9e873..eeae1a4 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():
-- 
GitLab