Skip to content
Snippets Groups Projects
Commit 6bff9b30 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files
parent e4c6cc19
No related branches found
No related tags found
No related merge requests found
Pipeline #56293 passed
......@@ -21,8 +21,8 @@
# ** end header
#
import pytest
import caosdb as db
from caosdb import administration as admin
import linkahead as db
from linkahead import administration as admin
_ORIGINAL_EXT_ENTITY_STATE = ""
_DELETE_ROLES = ["reviewer", "team-leader", "normal"]
......@@ -863,3 +863,45 @@ def test_missing_retrieve_permission():
rec2.retrieve(raise_exception_on_error=False)
assert len(rec2.get_errors()) > 0
assert rec2.state is None
@pytest.mark.xfail(reason="https://gitlab.com/linkahead/linkahead-server/-/issues/225")
def test_rt_with_reference_with_state():
"""See issue
https://gitlab.com/linkahead/linkahead-server/-/issues/225.
"""
# Insert a RecordType with a state
rt1 = db.RecordType(name="TestReferenced").add_parent("TestRT")
rt1.state = db.State(model="Model1", name="State1")
rt1.insert()
# Inser a RecordType with a state that also references the previous record
rt2 = db.RecordType(name="TestReferencing").add_parent("TestRT")
rt2.state = db.State(model="Model1", name="State1")
rt2.add_property(name="TestReferenced")
rt2.insert()
# We should see the property but without sub-state or sub-properties
assert rt2.get_property(rt1.name) is not None
assert rt2.get_property(rt1.name).value is None
assert len(rt2.get_property(rt1.name).properties) == 0
assert rt2.get_property(rt1.name).state is None
# Now remove the state from the referencing record
rt2.state = None
rt2.update(flags={"forceFinalState": "true"})
# This should not lead to unwanted sub-states or sub-propos either:
assert rt2.get_property(rt1.name) is not None
assert rt2.get_property(rt1.name).value is None
assert len(rt2.get_property(rt1.name).properties) == 0
assert rt2.get_property(rt1.name).state is None
# Should be able to add a property without problems
other_prop = db.Property(name="TestOtherProp", datatype=db.TEXT).insert()
rt2.add_property(id=other_prop.id)
rt2.update()
# Deletion needs to work without any error:
rt2.delete()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment