diff --git a/unittests/test_sync_node.py b/unittests/test_sync_node.py index 09eedd9f8a46327376b19abb809af115a68b628e..1fc2be6833df9774adf99b40987b1c944fbd5029 100644 --- a/unittests/test_sync_node.py +++ b/unittests/test_sync_node.py @@ -260,8 +260,9 @@ def test_export_node(): exp = SyncNode(rec_a).export_entity() assert exp.get_property('a').value.id == 1 + assert len([p for p in exp.properties if p.name == "a"]) == 1 - # different SyncNode Objects are not equal + # different SyncNode Objects (without an ID) are not equal rec_a = (db.Record(id=101) .add_parent("B") .add_property(name="a", value=SyncNode(db.Record())) @@ -270,7 +271,7 @@ def test_export_node(): with pytest.raises(ImpossibleMergeError): exp = SyncNode(rec_a).export_entity() - # different SyncNode Objects with differing are not equal + # different SyncNode Objects with differing ID are not equal rec_a = (db.Record(id=101) .add_parent("B") .add_property(name="a", value=SyncNode(db.Record(id=1))) @@ -287,6 +288,16 @@ def test_export_node(): exp = SyncNode(rec_a).export_entity() assert exp.get_property('a').value[0].id == 1 + assert len([p for p in exp.properties if p.name == "a"]) == 1 + + # SyncNodes with same ID are not equal when in different order (list) + rec_a = (db.Record(id=101) + .add_parent("B") + .add_property(name="a", value=[SyncNode(db.Record(id=1)), SyncNode(db.Record(id=2))]) + .add_property(name="a", value=[SyncNode(db.Record(id=2)), SyncNode(db.Record(id=1))])) + + with pytest.raises(ImpossibleMergeError): + exp = SyncNode(rec_a).export_entity() # same SyncNode object is obviously equal (list) sn = SyncNode(db.Record(id=1))