From 9599b06590af9853f184f32aa1a2ba290435a882 Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Sun, 1 Aug 2021 21:30:15 +0200
Subject: [PATCH] REVIEW: integrated reviewer's comments

---
 src/caosdb/common/models.py | 22 +++++++++++++++++++++-
 unittests/test_entity.py    | 12 +++++++++++-
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/src/caosdb/common/models.py b/src/caosdb/common/models.py
index 89397a6e..b3109fc7 100644
--- a/src/caosdb/common/models.py
+++ b/src/caosdb/common/models.py
@@ -2325,6 +2325,26 @@ class _Messages(dict):
 
 
 def _basic_sync(e_local, e_remote):
+    '''Copy all state from a one entity to another.
+
+    This method is used to syncronize an entity with a remote (i.e. a newly
+    retrieved) one.
+
+    Any entity state of the local one will be overriden.
+
+    Parameters
+    ----------
+    e_local : Entity
+        Destination of the copy.
+    e_local : Entity
+        Source of the copy.
+
+
+    Returns
+    -------
+    e_local : Entity
+        The syncronized entity.
+        '''
     if e_local is None or e_remote is None:
         return None
     if type(e_local) is Entity:
@@ -2335,7 +2355,7 @@ def _basic_sync(e_local, e_remote):
     e_local.path = e_remote.path
     e_local._checksum = e_remote._checksum
     e_local._size = e_remote._size
-    e_local.datatype = e_remote.datatype  # @ReservedAssignment
+    e_local.datatype = e_remote.datatype
     e_local.unit = e_remote.unit
     e_local.value = e_remote.value
     e_local.properties = e_remote.properties
diff --git a/unittests/test_entity.py b/unittests/test_entity.py
index 0195f24b..0a0b5efa 100644
--- a/unittests/test_entity.py
+++ b/unittests/test_entity.py
@@ -42,6 +42,8 @@ class TestEntity(unittest.TestCase):
 
     def test_instance_variables(self):
         entity = Entity()
+        self.assertTrue(hasattr(entity, "role"))
+        self.assertIsNone(entity.role)
         self.assertTrue(hasattr(entity, "id"))
         self.assertTrue(hasattr(entity, "name"))
         self.assertTrue(hasattr(entity, "description"))
@@ -70,7 +72,13 @@ class TestEntity(unittest.TestCase):
         self.assertEqual(entity.role, "RecordType")
         self.assertEqual(entity.to_xml().tag, "RecordType")
 
-    def test_instanciation(self):
+    def test_recordtype_role(self):
+        entity = Property()
+
+        self.assertEqual(entity.role, "Property")
+        self.assertEqual(entity.to_xml().tag, "Property")
+
+    def test_instantiation(self):
         self.assertRaises(Exception, Entity())
 
     def test_parse_role(self):
@@ -83,4 +91,6 @@ class TestEntity(unittest.TestCase):
                                               parser).getroot())
 
         self.assertEqual(entity.role, "Record")
+        # test whether the __role property of this object has explicitely been
+        # set.
         self.assertEqual(getattr(entity, "_Entity__role"), "Record")
-- 
GitLab