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
7f99c55f
Commit
7f99c55f
authored
2 years ago
by
Daniel Hornung
Browse files
Options
Downloads
Plain Diff
Merge branch 'f-get-parents-recursively' into 'dev'
Get parents recursively See merge request
!54
parents
6ed0398a
91d86775
No related branches found
No related tags found
1 merge request
!54
Get parents recursively
Pipeline
#33992
passed
2 years ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Stage: deploy
Changes
3
Pipelines
24
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+2
-0
2 additions, 0 deletions
CHANGELOG.md
README.md
+3
-1
3 additions, 1 deletion
README.md
tests/test_recursive_parents.py
+36
-15
36 additions, 15 deletions
tests/test_recursive_parents.py
with
41 additions
and
16 deletions
CHANGELOG.md
+
2
−
0
View file @
7f99c55f
...
@@ -41,6 +41,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
...
@@ -41,6 +41,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
*
Test for
[
caosdb-server#136
](
https://gitlab.com/caosdb/caosdb-server/-/issues/136
)
*
Test for
[
caosdb-server#136
](
https://gitlab.com/caosdb/caosdb-server/-/issues/136
)
*
Test for
[
caosdb-server#141
](
https://gitlab.com/caosdb/caosdb-server/-/issues/141
)
*
Test for
[
caosdb-server#141
](
https://gitlab.com/caosdb/caosdb-server/-/issues/141
)
*
Test for
[
caosdb-server#145
](
https://gitlab.com/caosdb/caosdb-server/-/issues/145
)
*
Test for
[
caosdb-server#145
](
https://gitlab.com/caosdb/caosdb-server/-/issues/145
)
*
Tests for
[
caosdb-pylib#90
](
https://gitlab.com/caosdb/caosdb-pylib/-/issues/90
)
:
`Entity.get_parents_recursively()`
did not work for unretrieved
parents.
### Changed (for changes in existing functionality)
### Changed (for changes in existing functionality)
...
...
This diff is collapsed.
Click to expand it.
README.md
+
3
−
1
View file @
7f99c55f
...
@@ -18,7 +18,9 @@ CaosDB project.
...
@@ -18,7 +18,9 @@ CaosDB project.
-
Server-side scripting paths must be given, otherwise server-side scripting will be omitted.
-
Server-side scripting paths must be given, otherwise server-side scripting will be omitted.
-
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_recursive_parents.py
+
36
−
15
View file @
7f99c55f
...
@@ -48,7 +48,26 @@ def teardown_function(function):
...
@@ -48,7 +48,26 @@ def teardown_function(function):
setup_module
()
setup_module
()
@pytest.mark.xfail
(
reason
=
"
To be fixed in server and/or pylib
"
)
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
(
retrieve
=
True
)
assert
len
(
parents
)
==
2
assert
"
TestB
"
in
[
p
.
name
for
p
in
parents
]
assert
"
TestA
"
in
[
p
.
name
for
p
in
parents
]
def
test_recursive_parents
():
def
test_recursive_parents
():
# inheritance structure:
# inheritance structure:
# A
# A
...
@@ -66,29 +85,31 @@ def test_recursive_parents():
...
@@ -66,29 +85,31 @@ def test_recursive_parents():
parents
=
C
.
get_parents_recursively
()
parents
=
C
.
get_parents_recursively
()
assert
len
(
parents
)
==
3
assert
len
(
parents
)
==
3
assert
A
in
parents
parent_identifiers
=
[(
all_p
.
id
,
all_p
.
name
)
for
all_p
in
parents
]
assert
B
in
parents
assert
(
A
.
id
,
A
.
name
)
in
parent_identifiers
assert
B2
in
parents
assert
(
B
.
id
,
B
.
name
)
in
parent_identifiers
assert
(
B2
.
id
,
B2
.
name
)
in
parent_identifiers
parents
=
c
.
get_parents_recursively
()
parents
=
c
.
get_parents_recursively
()
assert
len
(
parents
)
==
4
assert
len
(
parents
)
==
4
assert
A
in
parents
parent_identifiers
=
[(
all_p
.
id
,
all_p
.
name
)
for
all_p
in
parents
]
assert
B
in
parents
assert
(
A
.
id
,
A
.
name
)
in
parent_identifiers
assert
B2
in
parents
assert
(
B
.
id
,
B
.
name
)
in
parent_identifiers
assert
C
in
parents
assert
(
B2
.
id
,
B2
.
name
)
in
parent_identifiers
assert
(
C
.
id
,
C
.
name
)
in
parent_identifiers
# Now do a time travel and great-grand-parentize yourself...
# Now do a time travel and great-grand-parentize yourself...
A
.
add_parent
(
C
).
update
()
A
.
add_parent
(
C
).
update
()
parents
=
C
.
get_parents_recursively
()
parents
=
C
.
get_parents_recursively
()
assert
len
(
parents
)
==
4
assert
len
(
parents
)
==
4
assert
A
in
parents
parent_identifiers
=
[(
all_p
.
id
,
all_p
.
name
)
for
all_p
in
parents
]
assert
B
in
parents
assert
(
A
.
id
,
A
.
name
)
in
parent_identifiers
assert
B2
in
parents
assert
(
B
.
id
,
B
.
name
)
in
parent_identifiers
assert
C
in
parents
assert
(
B2
.
id
,
B2
.
name
)
in
parent_identifiers
assert
(
C
.
id
,
C
.
name
)
in
parent_identifiers
@pytest.mark.xfail
(
reason
=
"
To be fixed in server and/or pylib
"
)
def
test_entity_has_parent
():
def
test_entity_has_parent
():
# inheritance structure:
# inheritance structure:
# A
# A
...
@@ -137,8 +158,8 @@ def test_entity_has_parent():
...
@@ -137,8 +158,8 @@ def test_entity_has_parent():
assert
not
c
.
has_parent
(
fake_C_id
,
check_name
=
False
,
assert
not
c
.
has_parent
(
fake_C_id
,
check_name
=
False
,
check_id
=
True
)
check_id
=
True
)
fake_B_name_id
=
RecordType
(
name
=
"
TestTypeB
"
,
id
=
B
.
id
)
fake_B_name_id
=
db
.
RecordType
(
name
=
"
TestTypeB
"
,
id
=
B
.
id
)
fake_C_name_id
=
RecordType
(
name
=
"
not C
"
,
id
=
C
.
id
*
5
)
fake_C_name_id
=
db
.
RecordType
(
name
=
"
not C
"
,
id
=
C
.
id
*
5
)
assert
c
.
has_parent
(
fake_B_name_id
,
check_name
=
True
,
assert
c
.
has_parent
(
fake_B_name_id
,
check_name
=
True
,
check_id
=
True
)
check_id
=
True
)
...
...
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