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

MAINT: rename func

parent 92b6f9d6
No related branches found
No related tags found
3 merge requests!71REL: RElease v0.2.0,!56F refactor,!5FIX: use identifiable instead of record
...@@ -531,10 +531,12 @@ class Crawler(object): ...@@ -531,10 +531,12 @@ class Crawler(object):
# TODO: move inside if block? # TODO: move inside if block?
self.create_flat_list([p.value], flat) self.create_flat_list([p.value], flat)
def all_references_are_existing_already(self, record: db.Record): def no_uncached_entity_object_in_references(self, record: db.Record):
""" """
returns true if all references either have IDs or were checked remotely and not found (i.e. returns False if any property value is a db.Entity object that does not have an ID and also
they exist in the local cache) is not contained in the local cache. For example, if it was checked before whether such an
db.Entity object existed remotely and it was not found, it would have been added to the
local cache.
""" """
for p in record.properties: for p in record.properties:
# if (is_reference(p) # if (is_reference(p)
...@@ -716,7 +718,7 @@ class Crawler(object): ...@@ -716,7 +718,7 @@ class Crawler(object):
resolved_references = True resolved_references = True
# e.g. references an identifiable that does not exist remotely # e.g. references an identifiable that does not exist remotely
elif self.all_references_are_existing_already(record): elif self.no_uncached_entity_object_in_references(record):
# TODO: (for review) # TODO: (for review)
# This was the old version, but also for this case the # This was the old version, but also for this case the
......
...@@ -509,31 +509,31 @@ def test_all_references_are_existing_already(crawler): ...@@ -509,31 +509,31 @@ def test_all_references_are_existing_already(crawler):
})) }))
# one reference with id -> check # one reference with id -> check
assert crawler.all_references_are_existing_already( assert crawler.no_uncached_entity_object_in_references(
db.Record(name="C").add_parent("C").add_property('d', 123)) db.Record(name="C").add_parent("C").add_property('d', 123))
# one ref with Entity with id -> check # one ref with Entity with id -> check
assert crawler.all_references_are_existing_already(db.Record(name="C") assert crawler.no_uncached_entity_object_in_references(db.Record(name="C")
.add_property('d', db.Record(id=123))) .add_property('d', db.Record(id=123)))
# one ref with id one with Entity with id (mixed) -> check # one ref with id one with Entity with id (mixed) -> check
assert crawler.all_references_are_existing_already(db.Record(name="C").add_parent("D") assert crawler.no_uncached_entity_object_in_references(db.Record(name="C").add_parent("D")
.add_property('d', 123) .add_property('d', 123)
.add_property('b', db.Record(id=123))) .add_property('b', db.Record(id=123)))
# entity to be referenced in the following # entity to be referenced in the following
a = db.Record(name="C").add_parent("C").add_property("d", 12311) 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 # one ref with id one with Entity without id (but not identifying) -> fail
assert not crawler.all_references_are_existing_already(db.Record(name="C").add_parent("C") assert not crawler.no_uncached_entity_object_in_references(db.Record(name="C").add_parent("C")
.add_property('d', 123) .add_property('d', 123)
.add_property('e', a)) .add_property('e', a))
# one ref with id one with Entity without id (mixed) -> fail # one ref with id one with Entity without id (mixed) -> fail
assert not crawler.all_references_are_existing_already(db.Record(name="D").add_parent("D") assert not crawler.no_uncached_entity_object_in_references(db.Record(name="D").add_parent("D")
.add_property('d', 123) .add_property('d', 123)
.add_property('e', a)) .add_property('e', a))
crawler.add_identified_record_to_local_cache(a) crawler.add_identified_record_to_local_cache(a)
# one ref with id one with Entity without id but in cache -> check # one ref with id one with Entity without id but in cache -> check
assert crawler.all_references_are_existing_already(db.Record(name="D").add_parent("D") assert crawler.no_uncached_entity_object_in_references(db.Record(name="D").add_parent("D")
.add_property('d', 123) .add_property('d', 123)
.add_property('e', a)) .add_property('e', a))
# if this ever fails, the mock up may be removed # if this ever fails, the mock up may be removed
crawler.identifiableAdapter.get_registered_identifiable.assert_called() crawler.identifiableAdapter.get_registered_identifiable.assert_called()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment