From f4369e4f6c481c0573e4b2f1a4cea14313cfb07d Mon Sep 17 00:00:00 2001 From: Alexander Schlemmer <a.schlemmer@indiscale.com> Date: Wed, 22 May 2024 15:11:47 +0200 Subject: [PATCH] TST: added a test for order of sync nodes in lists --- unittests/test_sync_node.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/unittests/test_sync_node.py b/unittests/test_sync_node.py index 09eedd9f..1fc2be68 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)) -- GitLab