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

TEST for #95: Merging two entities that are referenced by a third.

parent 1813a3a4
No related branches found
No related tags found
2 merge requests!178FIX: #96 Better error output for crawl.py script.,!173ENH: Better errors for identifiables.yaml and when record type does not exist
Pipeline #52447 failed
......@@ -576,6 +576,11 @@ class CaosDBIdentifiableAdapter(IdentifiableAdapter):
"""Load identifiables defined in a yaml file"""
with open(path, "r", encoding="utf-8") as yaml_f:
identifiable_data = yaml.safe_load(yaml_f)
self.load_from_yaml_object(identifiable_data)
def load_from_yaml_object(self, identifiable_data):
"""Load identifiables defined in a yaml object.
"""
for key, value in identifiable_data.items():
rt = db.RecordType().add_parent(key)
......
......@@ -651,3 +651,28 @@ def test_set_each_scalar_value():
assert a.properties[0].value == 42
_set_each_scalar_value(a, lambda x: x == 42, lambda x: None)
assert a.properties[0].value is None
def test_merge_referenced_by():
"""Merging two entities that are referenced by a third entity.
See also https://gitlab.com/linkahead/linkahead-crawler/-/issues/95
"""
ident = CaosDBIdentifiableAdapter()
ident.load_from_yaml_object({
"RT_A": ["name"],
"RT_B": [{"is_referenced_by": "RT_A"}, "my_id"]
})
crawled_data: list = []
references: list = []
for ii in [0, 1]:
rec = db.Record().add_parent("RT_B").add_property("my_id", value=ii)
references.append(rec)
crawled_data.append(rec)
rec_a = db.Record(name="A").add_parent("RT_A")
rec_a.add_property("my_ref", value=references)
crawled_data.append(rec_a)
sync_graph = SyncGraph(crawled_data, ident)
assert sync_graph is not None
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment