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

clean up

parent 04bcb680
No related branches found
No related tags found
2 merge requests!71REL: RElease v0.2.0,!5FIX: use identifiable instead of record
Pipeline #29353 failed
......@@ -505,35 +505,6 @@ def test_split_into_inserts_and_updates_with_copy_attr(crawler_mocked_identifiab
crawler.identifiableAdapter.retrieve_identified_record_for_record.assert_called()
def test_all_references_are_existing_already2(crawler):
registered_identifiables = {
"C": db.Record().add_parent("C").add_property("a"),
"D": db.Record().add_parent("D").add_property("a").add_property("b")}
crawler.identifiableAdapter.get_registered_identifiable = Mock(side_effect=partial(
basic_ident_lookup, idents=registered_identifiables))
# one reference with id
assert crawler.all_references_are_existing_already(
db.Record().add_parent("C").add_property('a', 123))
# one ref with id one with Entity with id
assert crawler.all_references_are_existing_already(db.Record().add_parent("D")
.add_property('a', 123)
.add_property('b', db.Record(id=123)))
a = db.Record(name="A").add_parent("C").add_property("a", 12311)
# one ref with id one with Entity without id
assert not crawler.all_references_are_existing_already(db.Record().add_parent("D")
.add_property('a', 123)
.add_property('b', a))
crawler.add_identified_record_to_local_cache(a)
# one ref with id one with Entity which is cached
# (RT C has a as identifying prop which is given in this example)
assert crawler.all_references_are_existing_already(db.Record().add_parent("D")
.add_property('a', 123)
.add_property('b', a))
# if this ever fails, the mock up may be removed
crawler.identifiableAdapter.get_registered_identifiable.assert_called()
def test_all_references_are_existing_already(crawler):
# Simulate remote server content by using the names to identify records
# There are only two known Records with name A and B
......@@ -544,18 +515,29 @@ def test_all_references_are_existing_already(crawler):
.add_property("d").add_property("e"),
}))
# one reference with id -> check
assert crawler.all_references_are_existing_already(
db.Record(name="C").add_parent("C").add_property('d', 123))
# one ref with Entity with id -> check
assert crawler.all_references_are_existing_already(db.Record(name="C")
.add_property('d', db.Record(id=123)))
# 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")
.add_property('d', 123)
.add_property('b', db.Record(id=123)))
# 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) -> check
assert crawler.all_references_are_existing_already(db.Record(name="C").add_parent("C")
.add_property('d', 123)
.add_property('e', a))
# 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")
.add_property('d', 123)
.add_property('e', a))
crawler.add_identified_record_to_local_cache(a)
# 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")
.add_property('d', 123)
.add_property('e', a))
......@@ -563,34 +545,20 @@ def test_all_references_are_existing_already(crawler):
crawler.identifiableAdapter.get_registered_identifiable.assert_called()
def test_can_be_checked_externally2(crawler):
registered_identifiables = {
"C": db.Record().add_parent("C").add_property("a"),
"D": db.Record().add_parent("D").add_property("a").add_property("b")}
crawler.identifiableAdapter.get_registered_identifiable = Mock(side_effect=partial(
basic_ident_lookup, idents=registered_identifiables))
assert crawler.can_be_checked_externally(db.Record().add_parent("C").add_property('a', 123))
assert crawler.can_be_checked_externally(db.Record().add_parent("C")
.add_property('a', db.Record(id=123)))
assert crawler.can_be_checked_externally(db.Record().add_parent("D")
.add_property('a', 123)
.add_property('b', db.Record(id=123)))
assert not crawler.can_be_checked_externally(db.Record().add_parent("D")
.add_property('a', 123)
.add_property('b', db.Record()))
def test_can_be_checked_externally(crawler, ident):
assert crawler.can_be_checked_externally(
db.Record().add_parent("Person").add_property('last_name', 123).add_property('first_name', 123))
# id and rec with id
assert crawler.can_be_checked_externally(db.Record().add_parent("Person")
.add_property('first_name', 123)
.add_property('last_name', db.Record(id=123)))
# id and rec with id and one unneeded prop
assert crawler.can_be_checked_externally(db.Record().add_parent("Person")
.add_property('first_name', 123)
.add_property('stuff', db.Record())
.add_property('last_name', db.Record(id=123)))
# one identifying prop is missing
assert not crawler.can_be_checked_externally(db.Record().add_parent("Person")
.add_property('first_name', 123)
.add_property('last_name', db.Record()))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment