Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CaosDB Python Integration Tests
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Python Integration Tests
Commits
6bff9b30
Commit
6bff9b30
authored
9 months ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Patches
Plain Diff
TST: Add test for
https://gitlab.com/linkahead/linkahead-server/-/issues/225
parent
e4c6cc19
No related branches found
No related tags found
No related merge requests found
Pipeline
#56293
passed
6 months ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Stage: deploy
Changes
1
Pipelines
410
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_state.py
+44
-2
44 additions, 2 deletions
tests/test_state.py
with
44 additions
and
2 deletions
tests/test_state.py
+
44
−
2
View file @
6bff9b30
...
...
@@ -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
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment