From cda49965a8f70eca2d1410eb842bd83c4f1950e0 Mon Sep 17 00:00:00 2001 From: "i.nueske" <i.nueske@indiscale.com> Date: Sun, 8 Dec 2024 21:00:19 +0100 Subject: [PATCH] TST: Add test for https://gitlab.com/linkahead/linkahead-pylib/-/issues/123 and update changelog --- CHANGELOG.md | 1 + tests/test_issues_pylib.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3fb12b..b2dfb4e 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 [linkahead-pylib#123](https://gitlab.com/linkahead/linkahead-pylib/-/issues/123) * Tests for [linkahead-server#280](https://gitlab.com/linkahead/linkahead-server/-/issues/280) * 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) diff --git a/tests/test_issues_pylib.py b/tests/test_issues_pylib.py index 32b2bdb..1065428 100644 --- a/tests/test_issues_pylib.py +++ b/tests/test_issues_pylib.py @@ -196,3 +196,25 @@ def test_gitlab_com_120(): rt1_retrieved.update() # The update and addition of a new property must not change this, either. assert len(rt1_retrieved.get_property(rt2.name).properties) == 0 + + +def test_gitlab_com_123(): + """ + Test that Entity Role is taken into account when retrieving entities with + ambiguous name. + + See https://gitlab.com/linkahead/linkahead-pylib/-/issues/123. + """ + # Create ambiguous situation + db.RecordType(name="TestUniquenessRecordType").insert() + + f = db.File(file="__init__.py", path="__init__.py") + f.insert() + f.name = "TestUniquenessRecordType" + f.update(unique=False) + + # Check that only the file is retrieved and unique retrieve works + cont = db.File("TestUniquenessRecordType").retrieve(unique=False) + assert len(cont) == 1 + file = db.File("TestUniquenessRecordType").retrieve() + assert file.role == "File" -- GitLab