diff --git a/src/caoscrawler/crawl.py b/src/caoscrawler/crawl.py index b9251f9958ce5c1478c96da8039829cd63d48bdb..57b2735c8d2ec590822c0a1bf1ebf40cf6208f2c 100644 --- a/src/caoscrawler/crawl.py +++ b/src/caoscrawler/crawl.py @@ -482,16 +482,16 @@ class Crawler(object): return self._synchronize(self.target_data, commit_changes, unique_names=unique_names) - def has_reference_value_without_id(self, identifiable: db.Record): + def has_reference_value_without_id(self, record: db.Record): """ - Returns True if there is at least one property in `identifiable` which: + Returns True if there is at least one property in `record` which: a) is a reference property AND b) where the value is set to a db.Entity (instead of an ID) AND c) where the ID of the value (the db.Entity object in b)) is not set (to an integer) Returns False otherwise. """ - for p in identifiable.properties: + for p in record.properties: if isinstance(p.value, list): for el in p.value: if isinstance(el, db.Entity) and el.id is None: diff --git a/unittests/test_tool.py b/unittests/test_tool.py index e4c64d8881cf5fc0b102c8ca13822fd0245d0434..f08f8061728e2819b70079cabc0a10796154f619 100755 --- a/unittests/test_tool.py +++ b/unittests/test_tool.py @@ -502,39 +502,39 @@ def test_has_missing_object_in_references(crawler): # Simulate remote server content by using the names to identify records # There are only two known Records with name A and B crawler.identifiableAdapter.get_registered_identifiable = Mock(side_effect=partial( - basic_retrieve_by_name_mock_up, known={"C": db.Record(name="C").add_parent("C") + basic_retrieve_by_name_mock_up, known={"C": db.Record(name="C").add_parent("RTC") .add_property("d"), - "D": db.Record(name="D").add_parent("D") + "D": db.Record(name="D").add_parent("RTD") .add_property("d").add_property("e"), })) # one reference with id -> check assert not crawler.has_missing_object_in_references(db.Record(name="C") - .add_parent("C").add_property('d', 123)) + .add_parent("RTC").add_property('d', 123)) # one ref with Entity with id -> check assert not crawler.has_missing_object_in_references(db.Record(name="C") - .add_parent("C") + .add_parent("RTC") .add_property('d', db.Record(id=123) .add_parent("C"))) # one ref with id one with Entity with id (mixed) -> check - assert not crawler.has_missing_object_in_references(db.Record(name="C").add_parent("D") + assert not crawler.has_missing_object_in_references(db.Record(name="C").add_parent("RTD") .add_property('d', 123) .add_property('b', db.Record(id=123) - .add_parent("C"))) + .add_parent("RTC"))) # entity to be referenced in the following a = db.Record(name="C").add_parent("C").add_property("d", 12311) # one ref with id one with Entity without id (but not identifying) -> fail - assert not crawler.has_missing_object_in_references(db.Record(name="C").add_parent("C") + assert not crawler.has_missing_object_in_references(db.Record(name="C").add_parent("RTC") .add_property('d', 123) .add_property('e', a)) # one ref with id one with Entity without id (mixed) -> fail - assert not crawler.has_missing_object_in_references(db.Record(name="D").add_parent("D") + assert not crawler.has_missing_object_in_references(db.Record(name="D").add_parent("RTD") .add_property('d', 123) .add_property('e', a)) crawler.add_to_remote_missing_cache(a) # one ref with id one with Entity without id but in cache -> check - assert crawler.has_missing_object_in_references(db.Record(name="D").add_parent("D") + assert crawler.has_missing_object_in_references(db.Record(name="D").add_parent("RTD") .add_property('d', 123) .add_property('e', a)) # if this ever fails, the mock up may be removed