diff --git a/src/caoscrawler/exceptions.py b/src/caoscrawler/exceptions.py index 8066c7f4d2197ac53280fe47d3adb82def310b62..6d08cf76fc177407154e38f0eb6aaa47bc863866 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 b3dc3a9b4d0c2893f375ea257f50a45d73a9ea7c..6c98c55d524fa1e5c275d7ba57073ab0eae0ae42 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):