diff --git a/src/caosdb/common/models.py b/src/caosdb/common/models.py index e58b57f382ffd4d14d5319aa289ce74cb8df4660..417d0556ed8c0a40d925dd96e2ce4f7240053085 100644 --- a/src/caosdb/common/models.py +++ b/src/caosdb/common/models.py @@ -541,7 +541,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 a8f96785f383b8377fa15b5ab064551567726738..3fdc6af43d3a60ed7cfb466298e4b49729203282 100644 --- a/unittests/test_entity.py +++ b/unittests/test_entity.py @@ -65,3 +65,6 @@ class TestEntity(unittest.TestCase): self.assertEqual(parent.id, -3456) self.assertEqual(p.id, -23345) self.assertEqual(rec.id, -23) + + 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"))