From d6af005e7490065ccbd3b7fd033e9ac162190ba4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com>
Date: Fri, 24 May 2024 21:54:23 +0200
Subject: [PATCH] up

---
 src/caoscrawler/exceptions.py | 13 +++++++++++++
 unittests/test_sync_graph.py  | 12 +++++++-----
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/caoscrawler/exceptions.py b/src/caoscrawler/exceptions.py
index 8066c7f4..6d08cf76 100644
--- a/src/caoscrawler/exceptions.py
+++ b/src/caoscrawler/exceptions.py
@@ -21,16 +21,26 @@
 #
 
 class ForbiddenTransaction(Exception):
+    """Thrown if an transactions is needed that is not allowed.
+    For example an update of an entity if the security level is INSERT
+    """
     pass
 
 
 class MissingReferencingEntityError(Exception):
+    """Thrown if the identifiable requires that some entity references the given entity but there
+    is no such reference """
+
     def __init__(self, *args, rts=None, **kwargs):
         self.rts = rts
         super().__init__(self, *args, **kwargs)
 
 
 class ImpossibleMergeError(Exception):
+    """Thrown if due to identifying information, two SyncNodes  or two Properties of SyncNodes
+    should be merged, but there is conflicting information that prevents this.
+    """
+
     def __init__(self, *args, pname, values, **kwargs):
         self.pname = pname
         self.values = values
@@ -38,4 +48,7 @@ class ImpossibleMergeError(Exception):
 
 
 class MissingIdentifyingProperty(Exception):
+    """Thrown if a SyncNode does not have the properties required by the corresponding registered
+    identifiable
+    """
     pass
diff --git a/unittests/test_sync_graph.py b/unittests/test_sync_graph.py
index b3dc3a9b..6c98c55d 100644
--- a/unittests/test_sync_graph.py
+++ b/unittests/test_sync_graph.py
@@ -37,8 +37,7 @@ from itertools import product
 
 @pytest.fixture
 def simple_adapter():
-    # We use the reference as identifying reference in both directions. Thus the map is the same
-    # for all three categories: references, id_references and id_referenced_by
+    # different RTs with different registered identifiables to allow to test various behavior
     ident_adapter = CaosDBIdentifiableAdapter()
     ident_adapter.register_identifiable(
         "RT1",
@@ -166,9 +165,12 @@ def test_SyncGraph_init():
     for el in st.nodes:
         if el.identifiable is not None:
             assert st._identifiable_look_up[el.identifiable.get_representation()] is el
-    # node without ID but with identifiable was merged with other node with ID
-    assert len([el for el in st.nodes if len(el.properties) > 0
-                and el.properties[0].value == "MERGEME"]) == 1
+    # The node, which has no ID but has an identifiable,  was merged with another node with ID (due
+    # to the shared identifiable)
+    new_one = [el for el in st.nodes if len(el.properties) > 0
+               and el.properties[0].value == "MERGEME"]
+    assert len(new_one) == 1
+    assert new_one[0].id == 104
     # every node that does not rely on something unchecked has an identifiable or an ID
     for el in st.nodes:
         if not st._identity_relies_on_unchecked_entity(el):
-- 
GitLab