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

FIX test

parent 12a41936
Branches
Tags
2 merge requests!160STY: styling,!131Accept references of children
Pipeline #40918 failed
......@@ -40,6 +40,12 @@ from .utils import has_parent
logger = logging.getLogger(__name__)
def get_children_of_rt(rtname):
"""Supply the name of a recordtype. This name and the name of all children RTs are returned in
a list"""
return [p.name for p in db.execute_query(f"FIND RECORDTYPE {givenrt}")]
def convert_value(value: Any):
""" Returns a string representation of the value that is suitable
to be used in the query
......@@ -213,8 +219,7 @@ identifiabel, identifiable and identified record) for a Record.
# separate class too
if prop.name.lower() == "is_referenced_by":
for givenrt in prop.value:
rt_and_children = [p.name
for p in db.execute_query(f"FIND RECORDTYPE {givenrt}")]
rt_and_children = get_children_of_rt(givenrt)
found = False
for rtname in rt_and_children:
if (id(record) in referencing_entities
......
......@@ -685,6 +685,8 @@ def test_split_into_inserts_and_updates_backref(crawler_mocked_for_backref_test)
assert insert[0].name == "B"
@patch("caoscrawler.identifiable_adapters.get_children_of_rt",
new=Mock(side_effect=id()))
def test_split_into_inserts_and_updates_mult_backref(crawler_mocked_for_backref_test):
# test whether multiple references of the same record type are correctly used
crawler = crawler_mocked_for_backref_test
......@@ -705,6 +707,8 @@ def test_split_into_inserts_and_updates_mult_backref(crawler_mocked_for_backref_
assert len(insert) == 2
@patch("caoscrawler.identifiable_adapters.get_children_of_rt",
new=Mock(side_effect=id()))
def test_split_into_inserts_and_updates_diff_backref(crawler_mocked_for_backref_test):
# test whether multiple references of the different record types are correctly used
crawler = crawler_mocked_for_backref_test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment