diff --git a/unittests/test_sync_graph.py b/unittests/test_sync_graph.py index c53e7ad4e60388f4248838624e1aa88bcc70fab9..4c134af9810da6a34b8db4651f2f1fddc83e66c1 100644 --- a/unittests/test_sync_graph.py +++ b/unittests/test_sync_graph.py @@ -399,27 +399,6 @@ def test_set_id_of_node(simple_adapter): assert st.nodes[0].identifiable is not None 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", new=Mock(side_effect=mock_get_entity_by)) def test_merging(simple_adapter): diff --git a/unittests/test_sync_node.py b/unittests/test_sync_node.py index 54d1769af96d18161a7b3052d176dded077ac497..250d3a8ad3288d348abd95e149edf6249d265784 100644 --- a/unittests/test_sync_node.py +++ b/unittests/test_sync_node.py @@ -211,6 +211,20 @@ def test_export_node(): assert len(exp.properties) == len(rec_a.properties) 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 rec_a = (db.Record(id=101)