diff --git a/src/caosdb/common/models.py b/src/caosdb/common/models.py index 28dc6997455d5819cee30bdbf0a95bc771d93a16..045c5002d17e55e9b9c612a5709332212dfcfae1 100644 --- a/src/caosdb/common/models.py +++ b/src/caosdb/common/models.py @@ -542,7 +542,9 @@ class Entity(object): return p else: for p in self.properties: - if p.name is not None and str(p.name) == str(key): + if (p.name is not None + and str(p.name).lower() == str(key).lower()): + return p return None diff --git a/unittests/test_entity.py b/unittests/test_entity.py index d0f4089c8990a25b1652d332e46a1e3f4d7e4d03..c3862ae253b8fa8ad5640ae79c1088a385fb752b 100644 --- a/unittests/test_entity.py +++ b/unittests/test_entity.py @@ -22,11 +22,14 @@ # ** end header # """Tests for the Entity class.""" -# pylint: disable=missing-docstring -from nose.tools import (assert_is_not_none as there, assert_true as tru, - assert_equal as eq) +import unittest + from caosdb import Entity, configure_connection from caosdb.connection.mockup import MockUpServerConnection +# pylint: disable=missing-docstring +from nose.tools import assert_equal as eq +from nose.tools import assert_is_not_none as there +from nose.tools import assert_true as tru def setup_module(): @@ -40,18 +43,21 @@ def hat(obj, attr): tru(hasattr(obj, attr)) -def test_instance_variables(): - entity = Entity() - hat(entity, "role") - hat(entity, "id") - hat(entity, "name") - hat(entity, "description") - hat(entity, "parents") - hat(entity, "properties") - - -def test_role(): - entity = Entity(role="TestRole") - eq(entity.role, "TestRole") - entity.role = "TestRole2" - eq(entity.role, "TestRole2") +class TestEntity(unittest.TestCase): + def test_instance_variables(self): + entity = Entity() + hat(entity, "role") + hat(entity, "id") + hat(entity, "name") + hat(entity, "description") + hat(entity, "parents") + hat(entity, "properties") + + def test_role(self): + entity = Entity(role="TestRole") + eq(entity.role, "TestRole") + entity.role = "TestRole2" + eq(entity.role, "TestRole2") + + def test_instanciation(self): + self.assertRaises(Exception, Entity()) diff --git a/unittests/test_record.py b/unittests/test_record.py index cd65ede6b79d6ea53643348e10e08f86be36a362..001f91a726ae8c532a35a6d4875f434bedd3bbce 100644 --- a/unittests/test_record.py +++ b/unittests/test_record.py @@ -5,6 +5,7 @@ # # Copyright (C) 2018 Research Group Biomedical Physics, # Max-Planck-Institute for Dynamics and Self-Organization Göttingen +# Copyright (C) 2019 Henrik tom Wörden # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -23,8 +24,12 @@ # """Tests for the Record class.""" # pylint: disable=missing-docstring -from nose.tools import (assert_is_not_none as there, assert_true as tru, - assert_equal as eq) +import unittest + +from nose.tools import assert_equal as eq +from nose.tools import assert_is_not_none as there +from nose.tools import assert_true as tru + from caosdb import Entity, Record, configure_connection from caosdb.connection.mockup import MockUpServerConnection @@ -48,3 +53,13 @@ def test_is_entity(): def test_role(): record = Record() eq(record.role, "Record") + + +class TestRecord(unittest.TestCase): + def test_property_access(self): + rec = Record() + rec.add_property("Prop") + self.assertIsNone(rec.get_property("Pop")) + self.assertIsNotNone(rec.get_property("Prop")) + self.assertIsNotNone(rec.get_property("prop")) + self.assertIsNotNone(rec.get_property("prOp"))