From 3bebbf917d6e17187264df740936949ceb75920f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com>
Date: Sun, 13 Nov 2022 14:25:50 +0100
Subject: [PATCH] WIP passing tests

---
 src/caoscrawler/crawl.py |  38 +++---
 unittests/records.xml    | 266 +++++++++++++++++++--------------------
 unittests/test_tool.py   |  13 +-
 3 files changed, 157 insertions(+), 160 deletions(-)

diff --git a/src/caoscrawler/crawl.py b/src/caoscrawler/crawl.py
index dcc3a5e2..2cefcf76 100644
--- a/src/caoscrawler/crawl.py
+++ b/src/caoscrawler/crawl.py
@@ -495,7 +495,7 @@ class Crawler(object):
         Returns False otherwise.
         """
         if ident is None:
-            return True
+            raise ValueError("Identifiable has to be given as argument")
         for pname, pvalue in ident.properties.items():
             if isinstance(pvalue, list):
                 for el in pvalue:
@@ -536,17 +536,19 @@ class Crawler(object):
         whether it exists remotely and it was not found.
         """
         if ident is None:
-            return True
+            raise ValueError("Identifiable has to be given as argument")
         for pname, pvalue in ident.properties.items():
             # if (is_reference(p)
             # Entity instead of ID and not cached locally
             if (isinstance(pvalue, list)):
                 for el in pvalue:
                     if (isinstance(el, db.Entity)
-                            and self.get_from_remote_missing_cache(el) is not None):
+                            and self.get_from_remote_missing_cache(
+                                self.identifiableAdapter.get_identifiable(el)) is not None):
                         return True
             if (isinstance(pvalue, db.Entity)
-                    and self.get_from_remote_missing_cache(pvalue) is not None):
+                    and self.get_from_remote_missing_cache(
+                        self.identifiableAdapter.get_identifiable(pvalue)) is not None):
                 # might be checked when reference is resolved
                 return True
         return False
@@ -562,7 +564,8 @@ class Crawler(object):
                 lst = []
                 for el in p.value:
                     if (isinstance(el, db.Entity) and el.id is None):
-                        cached = self.get_from_any_cache(el)
+                        cached = self.get_from_any_cache(
+                            self.identifiableAdapter.get_identifiable(el))
                         if cached is None:
                             raise RuntimeError("Not in cache.")
                         if not check_identical(cached, el, True):
@@ -576,7 +579,8 @@ class Crawler(object):
                         lst.append(el)
                 p.value = lst
             if (isinstance(p.value, db.Entity) and p.value.id is None):
-                cached = self.get_from_any_cache(p.value)
+                cached = self.get_from_any_cache(
+                    self.identifiableAdapter.get_identifiable(p.value))
                 if cached is None:
                     raise RuntimeError("Not in cache.")
                 if not check_identical(cached, p.value, True):
@@ -587,15 +591,12 @@ class Crawler(object):
                         raise RuntimeError("Not identical.")
                 p.value = cached
 
-    def get_from_remote_missing_cache(self, record: db.Record):
+    def get_from_remote_missing_cache(self, identifiable: Identifiable):
         """
         returns the identifiable if an identifiable with the same values already exists locally
         (Each identifiable that is not found on the remote server, is 'cached' locally to prevent
         that the same identifiable exists twice)
         """
-        if self.identifiableAdapter is None:
-            raise RuntimeError("Should not happen.")
-        identifiable = self.identifiableAdapter.get_identifiable(record)
         if identifiable is None:
             # TODO: check whether the same idea as below works here
             identifiable = record
@@ -606,15 +607,12 @@ class Crawler(object):
         else:
             return None
 
-    def get_from_any_cache(self, record: db.Record):
+    def get_from_any_cache(self, identifiable: Identifiable):
         """
         returns the identifiable if an identifiable with the same values already exists locally
         (Each identifiable that is not found on the remote server, is 'cached' locally to prevent
         that the same identifiable exists twice)
         """
-        if self.identifiableAdapter is None:
-            raise RuntimeError("Should not happen.")
-        identifiable = self.identifiableAdapter.get_identifiable(record)
         if identifiable is None:
             return None
 
@@ -713,15 +711,16 @@ class Crawler(object):
 
             for i in reversed(range(len(flat))):
                 record = flat[i]
+                identifiable = self.identifiableAdapter.get_identifiable(record)
 
                 # TODO remove if the exception is never raised
                 if (record.id is not None or record in to_be_inserted):
                     raise RuntimeError("This should not be reached since treated elements"
                                        "are removed from the list")
                 # Check whether this record is a duplicate that can be removed
-                elif self.get_from_any_cache(record) is not None:
+                elif self.get_from_any_cache(identifiable) is not None:
                     # We merge the two in order to prevent loss of information
-                    newrecord = self.get_from_any_cache(record)
+                    newrecord = self.get_from_any_cache(identifiable)
                     merge_entities(newrecord, record)
                     Crawler.bend_references_to_new_object(
                         old=record, new=newrecord, entities=flat + to_be_updated + to_be_inserted)
@@ -730,9 +729,7 @@ class Crawler(object):
                     resolved_references = True
 
                 # can we check whether the record(identifiable) exists on the remote server?
-                elif not self.has_reference_value_without_id(
-                    # TODO move get_identifiable above if else?
-                        self.identifiableAdapter.get_identifiable(record)):
+                elif not self.has_reference_value_without_id(identifiable):
                     # TODO: remove deepcopy?
                     identified_record = (
                         self.identifiableAdapter.retrieve_identified_record_for_record(
@@ -757,8 +754,7 @@ class Crawler(object):
 
                 # is it impossible to check this record because an identifiable references a
                 # missing record?
-                elif self.has_missing_object_in_references(
-                        self.identifiableAdapter.get_identifiable(record)):
+                elif self.has_missing_object_in_references(identifiable):
                     to_be_inserted.append(record)
                     self.add_to_remote_missing_cache(record)
                     del flat[i]
diff --git a/unittests/records.xml b/unittests/records.xml
index f7455ec6..964d7d7e 100644
--- a/unittests/records.xml
+++ b/unittests/records.xml
@@ -1,157 +1,157 @@
 <Entities>
-  <Record id="281">
-    <Version id="291faf0ae67b0437d5ab8dd0c6c60cf43c8cc027" head="true"/>
-    <Parent id="250" name="Project"/>
-    <Property id="247" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">2020</Property>
-    <Property id="248" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX">climate-model-predict</Property>
-  </Record>
-  <Record id="282">
-    <Version id="59f41d5ebba6f6d7c881452386c3bd76e03a6871" head="true"/>
-    <Parent id="259" name="Person"/>
-    <Property id="261" name="first_name" description="First name of a Person." datatype="TEXT" importance="FIX" flag="inheritance:FIX"/>
-    <Property id="262" name="last_name" description="LastName of a Person." datatype="TEXT" importance="FIX" flag="inheritance:FIX">AuthorE</Property>
-  </Record>
-  <Record id="283">
-    <Version id="58c553e40002e184c32ea062993701237fc21934" head="true"/>
-    <Parent id="259" name="Person"/>
-    <Property id="261" name="first_name" description="First name of a Person." datatype="TEXT" importance="FIX" flag="inheritance:FIX"/>
-    <Property id="262" name="last_name" description="LastName of a Person." datatype="TEXT" importance="FIX" flag="inheritance:FIX">AuthorD</Property>
-  </Record>
-  <Record id="284" description="Average temperatures of the years 2000-2009 as obtained from wheatherdata.example">
-    <Version id="f9dbd861ccffff0c9a08df41a82ca60a374a92bb" head="true"/>
-    <Parent id="278" name="Measurement"/>
-    <Property id="247" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">2000-01-01</Property>
-    <Property id="248" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX"/>
-    <Property id="250" name="project" datatype="Project" importance="FIX" flag="inheritance:FIX">281</Property>
-    <Property id="249" name="responsible" datatype="LIST&lt;Person&gt;" importance="FIX" flag="inheritance:FIX">
-      <Value>283</Value>
+  <Record id="6224">
+    <Version id="3a1a1e3ff801c1973f42d10f306fa1ee260382b1" head="true"/>
+    <Parent id="6193" name="Project"/>
+    <Property id="6190" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">2020</Property>
+    <Property id="6191" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX">climate-model-predict</Property>
+  </Record>
+  <Record id="6225" description="Code for fitting the predictive model to the training data and for predicting the average annual temperature for all measurement stations for the years 2010 to 2019">
+    <Version id="8b93fa1c562f75090de8328ed3d60c42fad1e455" head="true"/>
+    <Parent id="6221" name="Measurement"/>
+    <Property id="6190" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">2020-02-01</Property>
+    <Property id="6191" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX"/>
+    <Property id="6193" name="project" datatype="Project" importance="FIX" flag="inheritance:FIX">6224</Property>
+    <Property id="6192" name="responsible" datatype="LIST&lt;Person&gt;" importance="FIX" flag="inheritance:FIX">
+      <Value>6226</Value>
     </Property>
   </Record>
-  <Record id="285" description="Average temperatures of the years 1990-1999 as obtained from wheatherdata.example">
-    <Version id="561a29c3b200f47a0c8cd1d43b3430f9ae4bbbb4" head="true"/>
-    <Parent id="278" name="Measurement"/>
-    <Property id="247" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">1990-01-01</Property>
-    <Property id="248" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX"/>
-    <Property id="250" name="project" datatype="Project" importance="FIX" flag="inheritance:FIX">281</Property>
-    <Property id="249" name="responsible" datatype="LIST&lt;Person&gt;" importance="FIX" flag="inheritance:FIX">
-      <Value>283</Value>
+  <Record id="6226">
+    <Version id="de8df2e71a7c0c2bf83ba60bd513bd944b3a7a31" head="true"/>
+    <Parent id="6202" name="Person"/>
+    <Property id="6204" name="first_name" description="First name of a Person." datatype="TEXT" importance="FIX" flag="inheritance:FIX"/>
+    <Property id="6205" name="last_name" description="LastName of a Person." datatype="TEXT" importance="FIX" flag="inheritance:FIX">AuthorE</Property>
+  </Record>
+  <Record id="6227" description="Average temperatures of the years 2010-2019 as obtained from wheatherdata.example">
+    <Version id="62ba2f5b3404504d024c9d2b0c1e2bab767cad5b" head="true"/>
+    <Parent id="6221" name="Measurement"/>
+    <Property id="6190" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">2010-01-01</Property>
+    <Property id="6191" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX"/>
+    <Property id="6193" name="project" datatype="Project" importance="FIX" flag="inheritance:FIX">6224</Property>
+    <Property id="6192" name="responsible" datatype="LIST&lt;Person&gt;" importance="FIX" flag="inheritance:FIX">
+      <Value>6228</Value>
     </Property>
   </Record>
-  <Record id="286" description="Average temperatures of the years 1980-1989 as obtained from wheatherdata.example">
-    <Version id="8ec5f56b96a0e60130f909ab6b4a035f1579e856" head="true"/>
-    <Parent id="278" name="Measurement"/>
-    <Property id="247" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">1980-01-01</Property>
-    <Property id="248" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX"/>
-    <Property id="250" name="project" datatype="Project" importance="FIX" flag="inheritance:FIX">281</Property>
-    <Property id="249" name="responsible" datatype="LIST&lt;Person&gt;" importance="FIX" flag="inheritance:FIX">
-      <Value>283</Value>
+  <Record id="6228">
+    <Version id="8ef17723704149e6df345b86e8021718d5711029" head="true"/>
+    <Parent id="6202" name="Person"/>
+    <Property id="6204" name="first_name" description="First name of a Person." datatype="TEXT" importance="FIX" flag="inheritance:FIX"/>
+    <Property id="6205" name="last_name" description="LastName of a Person." datatype="TEXT" importance="FIX" flag="inheritance:FIX">AuthorD</Property>
+  </Record>
+  <Record id="6229" description="Average temperatures of the years 2000-2009 as obtained from wheatherdata.example">
+    <Version id="03938d48e3fa031dd8ee2cd36d71033aefea9c85" head="true"/>
+    <Parent id="6221" name="Measurement"/>
+    <Property id="6190" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">2000-01-01</Property>
+    <Property id="6191" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX"/>
+    <Property id="6193" name="project" datatype="Project" importance="FIX" flag="inheritance:FIX">6224</Property>
+    <Property id="6192" name="responsible" datatype="LIST&lt;Person&gt;" importance="FIX" flag="inheritance:FIX">
+      <Value>6228</Value>
     </Property>
   </Record>
-  <Record id="287">
-    <Version id="b967d4ba9a333fd37b723d2b4c6f7e18ee0d41e3" head="true"/>
-    <Parent id="250" name="Project"/>
-    <Property id="247" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">2020</Property>
-    <Property id="248" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX">SpeedOfLight</Property>
-  </Record>
-  <Record id="288">
-    <Version id="18a8c4200597bf745391829c6cb9c04c747264fb" head="true"/>
-    <Parent id="259" name="Person"/>
-    <Property id="261" name="first_name" description="First name of a Person." datatype="TEXT" importance="FIX" flag="inheritance:FIX"/>
-    <Property id="262" name="last_name" description="LastName of a Person." datatype="TEXT" importance="FIX" flag="inheritance:FIX">AuthorB</Property>
-  </Record>
-  <Record id="289">
-    <Version id="799b41948bde740f37e202a5bab70e3d8829b3f6" head="true"/>
-    <Parent id="259" name="Person"/>
-    <Property id="261" name="first_name" description="First name of a Person." datatype="TEXT" importance="FIX" flag="inheritance:FIX"/>
-    <Property id="262" name="last_name" description="LastName of a Person." datatype="TEXT" importance="FIX" flag="inheritance:FIX">AuthorA</Property>
-  </Record>
-  <Record id="290">
-    <Version id="905f204d9bdc58890b59367338be038383f4dcf9" head="true"/>
-    <Parent id="259" name="Person"/>
-    <Property id="261" name="first_name" description="First name of a Person." datatype="TEXT" importance="FIX" flag="inheritance:FIX"/>
-    <Property id="262" name="last_name" description="LastName of a Person." datatype="TEXT" importance="FIX" flag="inheritance:FIX">AuthorC</Property>
-  </Record>
-  <Record id="291" description="Time-of-flight measurements to determine the speed of light">
-    <Version id="2d2f795a165fe1401ed0270f5b0bee9e6781e2c9" head="true"/>
-    <Parent id="278" name="Measurement"/>
-    <Property id="247" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">2020-01-01</Property>
-    <Property id="248" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX">TimeOfFlight</Property>
-    <Property id="250" name="project" datatype="Project" importance="FIX" flag="inheritance:FIX">287</Property>
-    <Property id="249" name="responsible" datatype="LIST&lt;Person&gt;" importance="FIX" flag="inheritance:FIX">
-      <Value>289</Value>
-      <Value>288</Value>
+  <Record id="6230" description="Average temperatures of the years 1990-1999 as obtained from wheatherdata.example">
+    <Version id="3c07d9f8e1b7b943dc4a7cedecf7067b51bb07cd" head="true"/>
+    <Parent id="6221" name="Measurement"/>
+    <Property id="6190" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">1990-01-01</Property>
+    <Property id="6191" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX"/>
+    <Property id="6193" name="project" datatype="Project" importance="FIX" flag="inheritance:FIX">6224</Property>
+    <Property id="6192" name="responsible" datatype="LIST&lt;Person&gt;" importance="FIX" flag="inheritance:FIX">
+      <Value>6228</Value>
     </Property>
   </Record>
-  <Record id="292" description="comparison between predicted and measured temperatures for 2010 to 2019">
-    <Version id="454be377ae35e44d89b7d28fc44d518b7e9321a3" head="true"/>
-    <Parent id="278" name="Measurement"/>
-    <Property id="247" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">2020-02-08</Property>
-    <Property id="248" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX">prediction-errors</Property>
-    <Property id="250" name="project" datatype="Project" importance="FIX" flag="inheritance:FIX">281</Property>
-    <Property id="249" name="responsible" datatype="LIST&lt;Person&gt;" importance="FIX" flag="inheritance:FIX">
-      <Value>283</Value>
+  <Record id="6231" description="Average temperatures of the years 1980-1989 as obtained from wheatherdata.example">
+    <Version id="b436049333159c2cafa2be46a3a701648465ae02" head="true"/>
+    <Parent id="6221" name="Measurement"/>
+    <Property id="6190" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">1980-01-01</Property>
+    <Property id="6191" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX"/>
+    <Property id="6193" name="project" datatype="Project" importance="FIX" flag="inheritance:FIX">6224</Property>
+    <Property id="6192" name="responsible" datatype="LIST&lt;Person&gt;" importance="FIX" flag="inheritance:FIX">
+      <Value>6228</Value>
     </Property>
   </Record>
-  <Record id="293" description="Average over all data of each type of experiment separately and comined.">
-    <Version id="12f3cd8eb6ba7a264ecc2d296c6e8d3a9f7ffc95" head="true"/>
-    <Parent id="278" name="Measurement"/>
-    <Property id="247" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">2020-01-05</Property>
-    <Property id="248" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX">average-all-exp-corr</Property>
-    <Property id="250" name="project" datatype="Project" importance="FIX" flag="inheritance:FIX">287</Property>
-    <Property id="249" name="responsible" datatype="LIST&lt;Person&gt;" importance="FIX" flag="inheritance:FIX">
-      <Value>289</Value>
+  <Record id="6232">
+    <Version id="83ce2862516d844686edeac9bbd14c56463f8bd8" head="true"/>
+    <Parent id="6193" name="Project"/>
+    <Property id="6190" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">2020</Property>
+    <Property id="6191" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX">SpeedOfLight</Property>
+  </Record>
+  <Record id="6233" description="Radio interferometry measurements to determine the speed of light">
+    <Version id="bc44aa56ba30d69a63ec8812624e5df3014b0824" head="true"/>
+    <Parent id="6221" name="Measurement"/>
+    <Property id="6190" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">2020-01-03</Property>
+    <Property id="6191" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX"/>
+    <Property id="6193" name="project" datatype="Project" importance="FIX" flag="inheritance:FIX">6232</Property>
+    <Property id="6192" name="responsible" datatype="LIST&lt;Person&gt;" importance="FIX" flag="inheritance:FIX">
+      <Value>6235</Value>
+      <Value>6234</Value>
     </Property>
   </Record>
-  <Record id="294" description="Average over all data of each type of experiment separately and comined.">
-    <Version id="4b513be5a2dbad332a3442eabe45ac7b1eae3b22" head="true"/>
-    <Parent id="278" name="Measurement"/>
-    <Property id="247" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">2020-01-04</Property>
-    <Property id="248" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX">average-all-exp</Property>
-    <Property id="250" name="project" datatype="Project" importance="FIX" flag="inheritance:FIX">287</Property>
-    <Property id="249" name="responsible" datatype="LIST&lt;Person&gt;" importance="FIX" flag="inheritance:FIX">
-      <Value>289</Value>
+  <Record id="6234">
+    <Version id="432ba6a860d0bbb2968c45151876ac5c00fcb903" head="true"/>
+    <Parent id="6202" name="Person"/>
+    <Property id="6204" name="first_name" description="First name of a Person." datatype="TEXT" importance="FIX" flag="inheritance:FIX"/>
+    <Property id="6205" name="last_name" description="LastName of a Person." datatype="TEXT" importance="FIX" flag="inheritance:FIX">AuthorB</Property>
+  </Record>
+  <Record id="6235">
+    <Version id="2d9b37614df38ca23b989dc81b1380b4b2954752" head="true"/>
+    <Parent id="6202" name="Person"/>
+    <Property id="6204" name="first_name" description="First name of a Person." datatype="TEXT" importance="FIX" flag="inheritance:FIX"/>
+    <Property id="6205" name="last_name" description="LastName of a Person." datatype="TEXT" importance="FIX" flag="inheritance:FIX">AuthorA</Property>
+  </Record>
+  <Record id="6236" description="Cavity resonance measurements for determining the speed of light">
+    <Version id="7dcb25469b2f4a8b70ea0e6a00ddc364db0a1b68" head="true"/>
+    <Parent id="6221" name="Measurement"/>
+    <Property id="6190" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">2020-01-02</Property>
+    <Property id="6191" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX">Cavity</Property>
+    <Property id="6193" name="project" datatype="Project" importance="FIX" flag="inheritance:FIX">6232</Property>
+    <Property id="6192" name="responsible" datatype="LIST&lt;Person&gt;" importance="FIX" flag="inheritance:FIX">
+      <Value>6235</Value>
+      <Value>6237</Value>
     </Property>
   </Record>
-  <Record id="295" description="Code for fitting the predictive model to the training data and for predicting the average annual temperature for all measurement stations for the years 2010 to 2019">
-    <Version id="e08fb3f41d0d2ab505f68795d4ee85c8235ef794" head="true"/>
-    <Parent id="278" name="Measurement"/>
-    <Property id="247" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">2020-02-01</Property>
-    <Property id="248" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX"/>
-    <Property id="250" name="project" datatype="Project" importance="FIX" flag="inheritance:FIX">281</Property>
-    <Property id="249" name="responsible" datatype="LIST&lt;Person&gt;" importance="FIX" flag="inheritance:FIX">
-      <Value>282</Value>
+  <Record id="6237">
+    <Version id="54cd067dcdf7b0175a582ff8eb4d86fa43b49450" head="true"/>
+    <Parent id="6202" name="Person"/>
+    <Property id="6204" name="first_name" description="First name of a Person." datatype="TEXT" importance="FIX" flag="inheritance:FIX"/>
+    <Property id="6205" name="last_name" description="LastName of a Person." datatype="TEXT" importance="FIX" flag="inheritance:FIX">AuthorC</Property>
+  </Record>
+  <Record id="6238" description="Time-of-flight measurements to determine the speed of light">
+    <Version id="2b51061fa3ad2a234d51518140f698216c59adb6" head="true"/>
+    <Parent id="6221" name="Measurement"/>
+    <Property id="6190" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">2020-01-01</Property>
+    <Property id="6191" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX">TimeOfFlight</Property>
+    <Property id="6193" name="project" datatype="Project" importance="FIX" flag="inheritance:FIX">6232</Property>
+    <Property id="6192" name="responsible" datatype="LIST&lt;Person&gt;" importance="FIX" flag="inheritance:FIX">
+      <Value>6235</Value>
+      <Value>6234</Value>
     </Property>
   </Record>
-  <Record id="296" description="Average temperatures of the years 2010-2019 as obtained from wheatherdata.example">
-    <Version id="81b7dae68df569f9fbf65e75448446093f816ab1" head="true"/>
-    <Parent id="278" name="Measurement"/>
-    <Property id="247" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">2010-01-01</Property>
-    <Property id="248" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX"/>
-    <Property id="250" name="project" datatype="Project" importance="FIX" flag="inheritance:FIX">281</Property>
-    <Property id="249" name="responsible" datatype="LIST&lt;Person&gt;" importance="FIX" flag="inheritance:FIX">
-      <Value>283</Value>
+  <Record id="6239" description="comparison between predicted and measured temperatures for 2010 to 2019">
+    <Version id="fdaea3343ae504d1ef8bb97d995f564135520375" head="true"/>
+    <Parent id="6221" name="Measurement"/>
+    <Property id="6190" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">2020-02-08</Property>
+    <Property id="6191" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX">prediction-errors</Property>
+    <Property id="6193" name="project" datatype="Project" importance="FIX" flag="inheritance:FIX">6224</Property>
+    <Property id="6192" name="responsible" datatype="LIST&lt;Person&gt;" importance="FIX" flag="inheritance:FIX">
+      <Value>6228</Value>
     </Property>
   </Record>
-  <Record id="297" description="Radio interferometry measurements to determine the speed of light">
-    <Version id="f3553ee9660b43b6a7598614de8eb17f40cf9782" head="true"/>
-    <Parent id="278" name="Measurement"/>
-    <Property id="247" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">2020-01-03</Property>
-    <Property id="248" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX"/>
-    <Property id="250" name="project" datatype="Project" importance="FIX" flag="inheritance:FIX">287</Property>
-    <Property id="249" name="responsible" datatype="LIST&lt;Person&gt;" importance="FIX" flag="inheritance:FIX">
-      <Value>289</Value>
-      <Value>288</Value>
+  <Record id="6240" description="Average over all data of each type of experiment separately and comined.">
+    <Version id="d14c013835ca8662f8b1aea363f34329e27ddd8e" head="true"/>
+    <Parent id="6221" name="Measurement"/>
+    <Property id="6190" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">2020-01-05</Property>
+    <Property id="6191" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX">average-all-exp-corr</Property>
+    <Property id="6193" name="project" datatype="Project" importance="FIX" flag="inheritance:FIX">6232</Property>
+    <Property id="6192" name="responsible" datatype="LIST&lt;Person&gt;" importance="FIX" flag="inheritance:FIX">
+      <Value>6235</Value>
     </Property>
   </Record>
-  <Record id="298" description="Cavity resonance measurements for determining the speed of light">
-    <Version id="06ddcf6f8a8c30761912c3752139acc3f6c610eb" head="true"/>
-    <Parent id="278" name="Measurement"/>
-    <Property id="247" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">2020-01-02</Property>
-    <Property id="248" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX">Cavity</Property>
-    <Property id="250" name="project" datatype="Project" importance="FIX" flag="inheritance:FIX">287</Property>
-    <Property id="249" name="responsible" datatype="LIST&lt;Person&gt;" importance="FIX" flag="inheritance:FIX">
-      <Value>289</Value>
-      <Value>290</Value>
+  <Record id="6241" description="Average over all data of each type of experiment separately and comined.">
+    <Version id="6676e9597c9459af941b2cf76cd4cc066c608b94" head="true"/>
+    <Parent id="6221" name="Measurement"/>
+    <Property id="6190" name="date" description="date of the experiment" datatype="DATETIME" importance="FIX" flag="inheritance:FIX">2020-01-04</Property>
+    <Property id="6191" name="identifier" description="identifier of the experiment" datatype="TEXT" importance="FIX" flag="inheritance:FIX">average-all-exp</Property>
+    <Property id="6193" name="project" datatype="Project" importance="FIX" flag="inheritance:FIX">6232</Property>
+    <Property id="6192" name="responsible" datatype="LIST&lt;Person&gt;" importance="FIX" flag="inheritance:FIX">
+      <Value>6235</Value>
     </Property>
   </Record>
 </Entities>
diff --git a/unittests/test_tool.py b/unittests/test_tool.py
index fc61a4f4..6344c223 100755
--- a/unittests/test_tool.py
+++ b/unittests/test_tool.py
@@ -362,17 +362,18 @@ def test_split_into_inserts_and_updates_trivial(crawler):
 
 def test_split_into_inserts_and_updates_single(crawler_mocked_identifiable_retrieve):
     crawler = crawler_mocked_identifiable_retrieve
+    identlist = [Identifiable(name="A", record_type="C"), Identifiable(name="B", record_type="C")]
     entlist = [db.Record(name="A").add_parent(
         "C"), db.Record(name="B").add_parent("C")]
 
-    assert crawler.get_from_any_cache(entlist[0]) is None
-    assert crawler.get_from_any_cache(entlist[1]) is None
-    #assert not crawler.has_reference_value_without_id(entlist[0])
-    #assert not crawler.has_reference_value_without_id(entlist[1])
+    assert crawler.get_from_any_cache(identlist[0]) is None
+    assert crawler.get_from_any_cache(identlist[1]) is None
+    assert not crawler.has_reference_value_without_id(identlist[0])
+    assert not crawler.has_reference_value_without_id(identlist[1])
     assert crawler.identifiableAdapter.retrieve_identified_record_for_record(
-        entlist[0]).id == 1111
+        identlist[0]).id == 1111
     assert crawler.identifiableAdapter.retrieve_identified_record_for_record(
-        entlist[1]) is None
+        identlist[1]) is None
 
     insert, update = crawler.split_into_inserts_and_updates(deepcopy(entlist))
     assert len(insert) == 1
-- 
GitLab