diff --git a/README.md b/README.md index 0e37866c8c402e1ae3a5b20a4601202692ec5e58..459755632c7fa75caa08f627ce21f26ac49d4f17 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,9 @@ CaosDB project. - 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). - 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 ## diff --git a/tests/test_parents.py b/tests/test_parents.py index d038350a27cb0a9bb2db79020957dc401e1b1e10..c8ddeebc006fc1c6d7a27aa5feceb0e632614332 100644 --- a/tests/test_parents.py +++ b/tests/test_parents.py @@ -41,3 +41,23 @@ def test_parent_name_id_mismatch(): with raises(db.TransactionError): rt2.insert() 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]