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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Python Integration Tests
Commits
ba861d12
Verified
Commit
ba861d12
authored
Feb 17, 2023
by
Daniel Hornung
Browse files
Options
Downloads
Patches
Plain Diff
Yet another test for recursive parents.
parent
6ed0398a
No related branches found
No related tags found
1 merge request
!54
Get parents recursively
Pipeline
#33720
failed
Feb 17, 2023
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+3
-1
3 additions, 1 deletion
README.md
tests/test_parents.py
+20
-0
20 additions, 0 deletions
tests/test_parents.py
with
23 additions
and
1 deletion
README.md
+
3
−
1
View file @
ba861d12
...
@@ -19,6 +19,8 @@ CaosDB project.
...
@@ -19,6 +19,8 @@ CaosDB project.
-
Run the tests with
`pytest`
or
`pytest-3`
(depending on your system).
-
Run the tests with
`pytest`
or
`pytest-3`
(depending on your system).
-
If you want to run just a single test, you can also select a single test file:
-
If you want to run just a single test, you can also select a single test file:
`pytest-3 tests/test_issues.py`
`pytest-3 tests/test_issues.py`
or a test matching a regular expression:
`pytest-3 tests/test_issues.py -k issue_123`
## Requirements ##
## Requirements ##
...
...
This diff is collapsed.
Click to expand it.
tests/test_parents.py
+
20
−
0
View file @
ba861d12
...
@@ -41,3 +41,23 @@ def test_parent_name_id_mismatch():
...
@@ -41,3 +41,23 @@ def test_parent_name_id_mismatch():
with
raises
(
db
.
TransactionError
):
with
raises
(
db
.
TransactionError
):
rt2
.
insert
()
rt2
.
insert
()
print
(
rt2
)
print
(
rt2
)
def
test_get_parents_recursively
():
"""
Test for https://gitlab.com/caosdb/caosdb-pylib/-/issues/90
> Entity.get_parents_recursively() does not work unless the full ancestry has been retrieved from
> the server.
"""
# Setup
rt_A
=
db
.
RecordType
(
name
=
"
TestA
"
)
rt_B
=
db
.
RecordType
(
name
=
"
TestB
"
).
add_parent
(
rt_A
)
rt_C
=
db
.
RecordType
(
name
=
"
TestC
"
).
add_parent
(
rt_B
)
db
.
Container
().
extend
([
rt_A
,
rt_B
,
rt_C
]).
insert
()
# Retrieve only C
retrieved_C
=
db
.
RecordType
(
name
=
"
TestC
"
).
retrieve
()
parents
=
retrieved_C
.
get_parents_recursively
()
assert
len
(
parents
)
==
2
assert
"
TestB
"
in
[
p
.
name
for
p
in
parents
]
assert
"
TestA
"
in
[
p
.
name
for
p
in
parents
]
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