From 2748c6dd397f3d0ac8e3bdc10183e00c5a8bd115 Mon Sep 17 00:00:00 2001 From: "i.nueske" <i.nueske@indiscale.com> Date: Tue, 3 Dec 2024 14:55:21 +0100 Subject: [PATCH] TST: Added test for https://gitlab.com/linkahead/linkahead-server/-/issues/280 and update changelog --- CHANGELOG.md | 1 + tests/test_issues_server.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03f0808..9af8794 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) +* Tests for [linkahead-server#280](https://gitlab.com/linkahead/linkahead-server/-/issues/280) * 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_server.py b/tests/test_issues_server.py index 8b73d5e..d0adc31 100644 --- a/tests/test_issues_server.py +++ b/tests/test_issues_server.py @@ -1588,3 +1588,25 @@ def test_268_insert_nonexistent_file(): with pytest.raises(TransactionError) as tre: db.File(path='IDoNotExist').insert() assert repr(tre) == "File does not exist: IDoNotExist" # TODO Replace by proper string. + + +@pytest.mark.xfail(reason="https://gitlab.com/linkahead/linkahead-server/-/issues/280") +def test_issue_280(): + """ + Test that the error message returned when an obligatory property is missing + contains information on the missing property. + + See https://gitlab.com/linkahead/linkahead-server/-/issues/280 + """ + prop = db.Property(name="TestProp", datatype=db.TEXT) + prop.insert() + + rt = db.RecordType(name="TestRT") + rt.add_property(prop, importance=db.OBLIGATORY) + rt.insert() + + # Check that error message contains name or id of missing property + rec = db.Record(name="TestRec").add_parent(rt) + with pytest.raises(TransactionError) as e: + rec.insert() + assert (prop.name in str(e.value)) or (str(prop.id) in str(e.value)) -- GitLab