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
becd143c
Commit
becd143c
authored
4 years ago
by
Florian Spreckelsen
Committed by
Henrik tom Wörden
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix and update test_recursive_parents
parent
551db7ce
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+6
-1
6 additions, 1 deletion
CHANGELOG.md
tests/test_recursive_parents.py
+77
-53
77 additions, 53 deletions
tests/test_recursive_parents.py
with
83 additions
and
54 deletions
CHANGELOG.md
+
6
−
1
View file @
becd143c
...
...
@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added (for new features)
*
Tests for deeply nested SELECT queries
-
Tests for
[
#62
](
https://gitlab.com/caosdb/caosdb-server/-/issues/62
)
*
Tests for
[
#62
](
https://gitlab.com/caosdb/caosdb-server/-/issues/62
)
*
Tests for One-time Authentication Tokens
*
Test for
[
caosdb-pylib#31
](
https://gitlab.com/caosdb/caosdb-pylib/-/issues/31
)
*
Tests for
[
caosdb-server#62
](
https://gitlab.com/caosdb/caosdb-server/-/issues/62
)
...
...
@@ -18,6 +18,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed (for changes in existing functionality)
*
`test_recursive_parents.py`
now tests inserted entities; set to
xfail until
[
caosdb-pylib#34
](
https://gitlab.com/caosdb/caosdb-pylib/-/issues/34
)
is fixed.
### Deprecated (for soon-to-be removed features)
### Removed (for now removed features)
...
...
This diff is collapsed.
Click to expand it.
tests/test_recursive_parents.py
+
77
−
53
View file @
becd143c
...
...
@@ -5,6 +5,8 @@
#
# Copyright (C) 2018 Research Group Biomedical Physics,
# Max-Planck-Institute for Dynamics and Self-Organization Göttingen
# Copyright (C) 2020 IndiScale GmbH <info@inidscale.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
...
...
@@ -22,11 +24,31 @@
# ** end header
#
"""
Created on 2016-01-14.
Test if recursive parents are found correctly.
"""
from
nose.tools
import
(
ok_
,
eq_
)
from
caosdb.common.models
import
(
Record
,
RecordType
)
import
caosdb
as
db
import
pytest
def
setup_module
():
"""
Delete all test entities
"""
db
.
execute_query
(
"
FIND Test*
"
).
delete
(
raise_exception_on_error
=
False
)
def
setup
():
"""
No further setup required
"""
setup_module
()
def
teardown
():
"""
Delete again
"""
setup_module
()
@pytest.mark.xfail
(
reason
=
"
To be fixed in server and/or pylib
"
)
def
test_recursive_parents
():
# inheritance structure:
# A
...
...
@@ -36,36 +58,37 @@ def test_recursive_parents():
# C
# |
# c
A
=
RecordType
(
name
=
"
A
"
)
B
=
RecordType
(
name
=
"
B
"
).
add_parent
(
A
)
B2
=
RecordType
(
name
=
"
B2
"
).
add_parent
(
A
)
C
=
RecordType
(
name
=
"
C
"
).
add_parent
(
B
).
add_parent
(
B2
)
c
=
Record
(
name
=
"
c
"
).
add_parent
(
C
)
A
=
db
.
RecordType
(
name
=
"
TestTypeA
"
).
insert
(
)
B
=
db
.
RecordType
(
name
=
"
TestType
B
"
).
add_parent
(
A
)
.
insert
()
B2
=
db
.
RecordType
(
name
=
"
TestType
B2
"
).
add_parent
(
A
)
.
insert
()
C
=
db
.
RecordType
(
name
=
"
TestType
C
"
).
add_parent
(
B
).
add_parent
(
B2
)
.
insert
()
c
=
db
.
Record
(
name
=
"
TestRecord
"
).
add_parent
(
C
)
.
insert
()
parents
=
C
.
get_parents_recursively
()
eq_
(
len
(
parents
)
,
3
)
ok_
(
A
in
parents
)
ok_
(
B
in
parents
)
ok_
(
B2
in
parents
)
assert
len
(
parents
)
==
3
assert
A
in
parents
assert
B
in
parents
assert
B2
in
parents
parents
=
c
.
get_parents_recursively
()
eq_
(
len
(
parents
)
,
4
)
ok_
(
A
in
parents
)
ok_
(
B
in
parents
)
ok_
(
B2
in
parents
)
ok_
(
C
in
parents
)
assert
len
(
parents
)
==
4
assert
A
in
parents
assert
B
in
parents
assert
B2
in
parents
assert
C
in
parents
# Now do a time travel and great-grand-parentize yourself...
A
.
add_parent
(
C
)
A
.
add_parent
(
C
)
.
update
()
parents
=
C
.
get_parents_recursively
()
eq_
(
len
(
parents
)
,
4
)
ok_
(
A
in
parents
)
ok_
(
B
in
parents
)
ok_
(
B2
in
parents
)
ok_
(
C
in
parents
)
assert
len
(
parents
)
==
4
assert
A
in
parents
assert
B
in
parents
assert
B2
in
parents
assert
C
in
parents
@pytest.mark.xfail
(
reason
=
"
To be fixed in server and/or pylib
"
)
def
test_entity_has_parent
():
# inheritance structure:
# A
...
...
@@ -75,48 +98,49 @@ def test_entity_has_parent():
# C
# |
# c
A
=
RecordType
(
name
=
"
A
"
)
B
=
RecordType
(
name
=
"
B
"
).
add_parent
(
A
)
B2
=
RecordType
(
name
=
"
B2
"
,
id
=
42
).
add_parent
(
A
)
C
=
RecordType
(
name
=
"
C
"
).
add_parent
(
B
).
add_parent
(
B2
)
c
=
Record
(
name
=
"
c
"
).
add_parent
(
C
)
A
=
db
.
RecordType
(
name
=
"
TestTypeA
"
).
insert
(
)
B
=
db
.
RecordType
(
name
=
"
TestType
B
"
).
add_parent
(
A
)
.
insert
()
B2
=
db
.
RecordType
(
name
=
"
TestTypeB2
"
).
add_parent
(
A
)
.
insert
()
C
=
db
.
RecordType
(
name
=
"
TestType
C
"
).
add_parent
(
B
).
add_parent
(
B2
)
.
insert
()
c
=
db
.
Record
(
name
=
"
TestRecord
"
).
add_parent
(
C
)
.
insert
()
ok_
(
C
.
has_parent
(
B
)
)
ok_
(
c
.
has_parent
(
B
)
)
ok_
(
c
.
has_parent
(
A
)
)
assert
C
.
has_parent
(
B
)
assert
c
.
has_parent
(
B
)
assert
c
.
has_parent
(
A
)
ok_
(
not
C
.
has_parent
(
C
)
)
ok_
(
not
A
.
has_parent
(
C
)
)
ok_
(
not
B
.
has_parent
(
C
)
)
assert
not
C
.
has_parent
(
C
)
assert
not
A
.
has_parent
(
C
)
assert
not
B
.
has_parent
(
C
)
# Now do a time travel and great-grand-parentize yourself...
A
.
add_parent
(
C
)
A
.
add_parent
(
C
)
.
update
()
ok_
(
C
.
has_parent
(
C
)
)
assert
C
.
has_parent
(
C
)
# Non-recursive tests
ok_
(
C
.
has_parent
(
B
,
recursive
=
False
)
)
ok_
(
not
c
.
has_parent
(
B
,
recursive
=
False
)
)
ok_
(
not
c
.
has_parent
(
A
,
recursive
=
False
)
)
ok_
(
not
C
.
has_parent
(
C
,
recursive
=
False
)
)
assert
C
.
has_parent
(
B
,
recursive
=
False
)
assert
not
c
.
has_parent
(
B
,
recursive
=
False
)
assert
not
c
.
has_parent
(
A
,
recursive
=
False
)
assert
not
C
.
has_parent
(
C
,
recursive
=
False
)
# Works by name or ID
fake_B_name
=
RecordType
(
name
=
"
B
"
)
fake_C_name
=
RecordType
(
name
=
"
not C
"
)
fake_B_name
=
db
.
RecordType
(
name
=
"
TestType
B
"
)
fake_C_name
=
db
.
RecordType
(
name
=
"
not C
"
)
ok_
(
c
.
has_parent
(
fake_B_name
,
check_name
=
True
)
)
ok_
(
not
c
.
has_parent
(
fake_C_name
,
check_name
=
True
)
)
assert
c
.
has_parent
(
fake_B_name
,
check_name
=
True
)
assert
not
c
.
has_parent
(
fake_C_name
,
check_name
=
True
)
fake_B_id
=
RecordType
(
id
=
42
)
fake_C_id
=
RecordType
(
id
=
23
)
fake_B_id
=
db
.
RecordType
(
id
=
B
.
id
)
fake_C_id
=
db
.
RecordType
(
id
=
C
.
id
*
5
)
ok_
(
c
.
has_parent
(
fake_B_id
,
check_name
=
False
,
check_id
=
True
))
ok_
(
not
c
.
has_parent
(
fake_C_id
,
check_name
=
False
,
check_id
=
True
))
assert
c
.
has_parent
(
fake_B_id
,
check_name
=
False
,
check_id
=
True
)
assert
not
c
.
has_parent
(
fake_C_id
,
check_name
=
False
,
check_id
=
True
)
fake_B_name_id
=
RecordType
(
name
=
"
B
"
,
id
=
42
)
fake_C_name_id
=
RecordType
(
name
=
"
not C
"
,
id
=
23
)
fake_B_name_id
=
RecordType
(
name
=
"
TestType
B
"
,
id
=
B
.
id
)
fake_C_name_id
=
RecordType
(
name
=
"
not C
"
,
id
=
C
.
id
*
5
)
ok_
(
c
.
has_parent
(
fake_B_name_id
,
check_name
=
True
,
check_id
=
True
)
)
ok_
(
not
c
.
has_parent
(
fake_C_name_id
,
check_name
=
True
,
check_id
=
True
)
)
assert
c
.
has_parent
(
fake_B_name_id
,
check_name
=
True
,
check_id
=
True
)
assert
not
c
.
has_parent
(
fake_C_name_id
,
check_name
=
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