Skip to content
Snippets Groups Projects
Commit bb672942 authored by florian's avatar florian
Browse files

MAINT: Revert renaming of variable and use better RT names in test

parent d8546bf6
Branches
Tags
2 merge requests!71REL: RElease v0.2.0,!5FIX: use identifiable instead of record
Pipeline #29511 passed
......@@ -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:
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment