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

test

parent 28f222af
Branches
Tags
2 merge requests!178FIX: #96 Better error output for crawl.py script.,!167Sync Graph
Pipeline #50897 passed with warnings
...@@ -399,27 +399,6 @@ def test_set_id_of_node(simple_adapter): ...@@ -399,27 +399,6 @@ def test_set_id_of_node(simple_adapter):
assert st.nodes[0].identifiable is not None assert st.nodes[0].identifiable is not None
assert len(st.nodes) == 2 assert len(st.nodes) == 2
# Test for meaningful exception when having unmergeable properties.
ent_list = [
db.Record().add_parent("RT3").add_property('a', value=1).add_property('b', value=1),
db.Record().add_parent("RT3").add_property('a', value=1).add_property('b', value=2),
]
st = SyncGraph(ent_list, simple_adapter)
with pytest.raises(ImpossibleMergeError):
st.export_record_lists()
ent_list = [
db.Record().add_parent("RT3").add_property('a', value=1)
.add_property('b', value=db.Record(name='b').add_parent("RT5")),
db.Record().add_parent("RT3").add_property('a', value=1)
.add_property('b', value=db.Record(name='a').add_parent("RT5")),
]
st = SyncGraph(ent_list, simple_adapter)
with pytest.raises(ImpossibleMergeError):
st.export_record_lists()
@patch("caoscrawler.sync_graph.cached_get_entity_by", @patch("caoscrawler.sync_graph.cached_get_entity_by",
new=Mock(side_effect=mock_get_entity_by)) new=Mock(side_effect=mock_get_entity_by))
def test_merging(simple_adapter): def test_merging(simple_adapter):
......
...@@ -211,6 +211,20 @@ def test_export_node(): ...@@ -211,6 +211,20 @@ def test_export_node():
assert len(exp.properties) == len(rec_a.properties) assert len(exp.properties) == len(rec_a.properties)
assert len(exp.parents) == len(rec_a.parents) assert len(exp.parents) == len(rec_a.parents)
# ---------------------------------------------------------------------------------------------
# NOTE: in the following we create a SyncNode object with twice the same Property as a short
# hand for a SyncNode that was created from one Entity with such a Property and then updating
# it with another SyncNode that also has the Property
# ---------------------------------------------------------------------------------------------
# same property name, different values
rec_a = (db.Record(id=101)
.add_parent("B")
.add_property(name="a", value='b')
.add_property(name="a", value='a'))
with pytest.raises(ImpossibleMergeError):
exp = SyncNode(rec_a).export_entity()
# SyncNodes with same ID are considered equal # SyncNodes with same ID are considered equal
rec_a = (db.Record(id=101) rec_a = (db.Record(id=101)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment