From 9e12c3edd6a248ce9b7e222e53724ca56b1af8ce Mon Sep 17 00:00:00 2001 From: "i.nueske" <i.nueske@indiscale.com> Date: Sat, 30 Nov 2024 12:35:04 +0100 Subject: [PATCH] TST: Added test for https://gitlab.com/linkahead/linkahead-pylib/-/issues/119 and update changelog --- CHANGELOG.md | 1 + tests/test_issues_pylib.py | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03f0808..fe6d358 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#119](https://gitlab.com/linkahead/linkahead-pylib/-/issues/119) * Test for [caosdb-pylib#89](https://gitlab.com/linkahead/linkahead-pylib/-/issues/89) * Test for [caosdb-pylib#103](https://gitlab.com/linkahead/linkahead-pylib/-/issues/103) * Tests for entity state [caosdb-server!62](https://gitlab.com/caosdb/caosdb-server/-/merge_requests/62) diff --git a/tests/test_issues_pylib.py b/tests/test_issues_pylib.py index 94ffa89..a6e0216 100644 --- a/tests/test_issues_pylib.py +++ b/tests/test_issues_pylib.py @@ -36,6 +36,7 @@ import pytest from linkahead import administration as admin from linkahead.exceptions import (TransactionError, HTTPClientError) +from linkahead.apiutils import empty_diff, merge_entities CURATOR_ROLE = "curator" @@ -138,6 +139,29 @@ def test_gitlab_com_108(): print("deleted") +def test_gitlab_com_119(): + """ + Test that merge_entities works on properties with id but no name. + + See https://gitlab.com/linkahead/linkahead-pylib/-/issues/119 and + https://gitlab.indiscale.com/caosdb/customers/f-fit/management/-/issues/94 + """ + prop = db.Property(name="Test", datatype=db.TEXT).insert() + rt = db.RecordType(name="TestRT").insert() + + rec1 = db.Record(name="TestRec").add_parent(rt) + rec2 = db.Record(name="TestRec").add_parent(rt) + rec1.add_property(id=prop.id, value="something") + + # Ensure rec1 has prop, rec2 does not + assert not empty_diff(rec1, rec2) + assert len(rec2.properties) == 0 + + # Merge and check rec2 now has prop + merge_entities(rec2, rec1) + assert empty_diff(rec1.get_property(prop), rec2.get_property(prop)) + + def test_gitlab_com_120(): """Test that an update doesn't add unwanted subproperties. -- GitLab