Skip to content
Snippets Groups Projects
Verified Commit ba861d12 authored by Daniel Hornung's avatar Daniel Hornung
Browse files

Yet another test for recursive parents.

parent 6ed0398a
No related branches found
No related tags found
1 merge request!54Get parents recursively
Pipeline #33720 failed
...@@ -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 ##
......
...@@ -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]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment