From fa098c97fc00b9fc2f2a4e62a43debc95ee2596b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com>
Date: Thu, 16 May 2024 11:26:35 +0200
Subject: [PATCH] MAINT: replace asserts with raised errors

---
 src/caoscrawler/sync_graph.py | 6 ++++--
 src/caoscrawler/sync_node.py  | 5 ++++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/caoscrawler/sync_graph.py b/src/caoscrawler/sync_graph.py
index 36ed36d7..08b38be5 100644
--- a/src/caoscrawler/sync_graph.py
+++ b/src/caoscrawler/sync_graph.py
@@ -301,9 +301,11 @@ class SyncGraph():
         equivalent_se = self.get_equivalent(node)
         if equivalent_se is not None and equivalent_se is not node:
             self._merge_into(node, equivalent_se)
-            assert equivalent_se.identifiable is not None
+            if equivalent_se.identifiable is None:
+                raise ValueError("Identifiable is missing")
         else:
-            assert node.identifiable.get_representation() not in self._identifiable_look_up
+            if node.identifiable.get_representation() in self._identifiable_look_up:
+                raise RuntimeError("Identifiable is already in the look up")
             self._identifiable_look_up[node.identifiable.get_representation()] = node
 
     @staticmethod
diff --git a/src/caoscrawler/sync_node.py b/src/caoscrawler/sync_node.py
index 5dd8baf7..1d07351b 100644
--- a/src/caoscrawler/sync_node.py
+++ b/src/caoscrawler/sync_node.py
@@ -108,7 +108,10 @@ class SyncNode:
                 if self.__getattribute__(attr) is None:
                     self.__setattr__(attr, other.__getattribute__(attr))
                 else:
-                    assert self.__getattribute__(attr) == other.__getattribute__(attr)
+                    if self.__getattribute__(attr) != other.__getattribute__(attr):
+                        raise ValueError(f"Trying to update {attr} but this would lead to an "
+                                         f"override of the value '{self.__getattribute__(attr)}' "
+                                         f"by the value '{other.__getattribute__(attr)}'")
         for p in other.parents:
             if not parent_in_list(p, self.parents):
                 self.parents.append(p)
-- 
GitLab