diff --git a/CHANGELOG.md b/CHANGELOG.md index fc813ab948d33b00981a519f920215fac4298001..0027b3fa813fbab623e2da696ef8cd38da47c784 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added (for new features) +- Tests for [#62](https://gitlab.com/caosdb/caosdb-server/-/issues/62) + in caosdb-server-project, i.e., renaming of a RecordType that should + be reflected in properties with that RT as datatype. + ### Changed (for changes in existing functionality) ### Deprecated (for soon-to-be removed features) diff --git a/tests/test_issues_server.py b/tests/test_issues_server.py index 3b24e1fcfc553617f2cd178970eefab8da507c41..88f9134068921aeffb12c5d7ebf6d15866a68937 100644 --- a/tests/test_issues_server.py +++ b/tests/test_issues_server.py @@ -3,8 +3,9 @@ # ** header v3.0 # This file is a part of the CaosDB Project. # -# Copyright (c) 2020 IndiScale GmbH (www.indiscale.com) -# Copyright (c) 2020 Daniel Hornung (d.hornung@indiscale.com) +# Copyright (c) 2020 IndiScale GmbH <info@indiscale.com> +# Copyright (c) 2020 Daniel Hornung <d.hornung@indiscale.com> +# Copyright (c) 2020 Florian Spreckelsen <f.spreckelsen@indiscale.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -21,9 +22,11 @@ # # ** end header -"""Tests for issues on gitlab.com, project caosdb-mysqlbackend.""" +"""Tests for issues on gitlab.com, project caosdb-server.""" import caosdb as db +from caosdb.exceptions import EntityError +import pytest def setup_module(): @@ -45,6 +48,31 @@ def teardown(): # ########################### Issue tests start here ########################### +@pytest.mark.xfail(reason="to be fixed in server repo") +def test_issue_62(): + """datatype is not changed when recordtype name changes + + Tests for https://gitlab.com/caosdb/caosdb-server/-/issues/62 + """ + db.RecordType(name="Test_RTA").insert() + db.Property(name="Test_Prop", datatype="Test_RTA").insert() + db.Record(name="Test_Record").add_parent( + name="Test_RTA").add_property(name="Test_Prop").insert() + # rename Test_RTA to Test_RTB + rtb = db.execute_query("FIND RecordType Test_RTA", unique=True) + rtb.name = "Test_RTB" + rtb.update() + # renaming has to be reflected in Test_Record and Test_Prop + rec = db.execute_query("FIND Record Test_Record", unique=True) + assert rec.parents[0].name == rtb.name + prop = db.execute_query("FIND Property Test_Prop", unique=True) + assert prop.datatype == rtb.name # fails; datatype not updated + # Can't use Test_RTA as datatype anymore + prop2 = db.Property(name="Test_Prop2", datatype="Test_RTA") + with pytest.raises(EntityError): + prop2.insert() + + def test_issue_85_a(): """SQLIntegrityConstraintViolationException for special inheritance patterns.