Skip to content
Snippets Groups Projects
Commit bf5397c8 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

TST: add test

parent efdb10e3
Branches
Tags
2 merge requests!160STY: styling,!146ENH: allow wildcard is_referenced_by
Pipeline #46659 passed
...@@ -221,6 +221,8 @@ identifiabel, identifiable and identified record) for a Record. ...@@ -221,6 +221,8 @@ identifiabel, identifiable and identified record) for a Record.
for givenrt in prop.value: for givenrt in prop.value:
found = False found = False
if givenrt == "*": if givenrt == "*":
if id(record) not in referencing_entities:
continue
for rt, rec in referencing_entities[id(record)].items(): for rt, rec in referencing_entities[id(record)].items():
identifiable_backrefs.extend(rec) identifiable_backrefs.extend(rec)
found = True found = True
......
...@@ -133,6 +133,22 @@ def test_non_default_name(): ...@@ -133,6 +133,22 @@ def test_non_default_name():
assert identifiable.name is None assert identifiable.name is None
def test_wildcard_ref():
ident = CaosDBIdentifiableAdapter()
ident.register_identifiable(
"Person", db.RecordType()
.add_parent(name="Person")
.add_property(name="is_referenced_by", value=["*"]))
rec = (db.Record(name="don't touch it").add_parent("Person")
.add_property(name="last_name", value='Tom'))
identifiable = ident.get_identifiable(rec,
referencing_entities={
id(rec):
{'A': [db.Record(id=1).add_parent("A")]}}
)
assert identifiable.backrefs[0].id == 1
def test_convert_value(): def test_convert_value():
# test that string representation of objects stay unchanged. No stripping or so. # test that string representation of objects stay unchanged. No stripping or so.
class A(): class A():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment