Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-pylib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-pylib
Commits
6a004836
Commit
6a004836
authored
Feb 5, 2020
by
Henrik tom Wörden
Committed by
Timm Fitschen
Feb 5, 2020
Browse files
Options
Downloads
Patches
Plain Diff
FIX: make Entity.get_property case-insensitive
parent
e7a391bd
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/caosdb/common/models.py
+3
-1
3 additions, 1 deletion
src/caosdb/common/models.py
unittests/test_entity.py
+24
-18
24 additions, 18 deletions
unittests/test_entity.py
unittests/test_record.py
+17
-2
17 additions, 2 deletions
unittests/test_record.py
with
44 additions
and
21 deletions
src/caosdb/common/models.py
+
3
−
1
View file @
6a004836
...
@@ -542,7 +542,9 @@ class Entity(object):
...
@@ -542,7 +542,9 @@ class Entity(object):
return
p
return
p
else
:
else
:
for
p
in
self
.
properties
:
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
p
return
None
return
None
...
...
This diff is collapsed.
Click to expand it.
unittests/test_entity.py
+
24
−
18
View file @
6a004836
...
@@ -22,11 +22,14 @@
...
@@ -22,11 +22,14 @@
# ** end header
# ** end header
#
#
"""
Tests for the Entity class.
"""
"""
Tests for the Entity class.
"""
# pylint: disable=missing-docstring
import
unittest
from
nose.tools
import
(
assert_is_not_none
as
there
,
assert_true
as
tru
,
assert_equal
as
eq
)
from
caosdb
import
Entity
,
configure_connection
from
caosdb
import
Entity
,
configure_connection
from
caosdb.connection.mockup
import
MockUpServerConnection
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
():
def
setup_module
():
...
@@ -40,7 +43,8 @@ def hat(obj, attr):
...
@@ -40,7 +43,8 @@ def hat(obj, attr):
tru
(
hasattr
(
obj
,
attr
))
tru
(
hasattr
(
obj
,
attr
))
def
test_instance_variables
():
class
TestEntity
(
unittest
.
TestCase
):
def
test_instance_variables
(
self
):
entity
=
Entity
()
entity
=
Entity
()
hat
(
entity
,
"
role
"
)
hat
(
entity
,
"
role
"
)
hat
(
entity
,
"
id
"
)
hat
(
entity
,
"
id
"
)
...
@@ -49,9 +53,11 @@ def test_instance_variables():
...
@@ -49,9 +53,11 @@ def test_instance_variables():
hat
(
entity
,
"
parents
"
)
hat
(
entity
,
"
parents
"
)
hat
(
entity
,
"
properties
"
)
hat
(
entity
,
"
properties
"
)
def
test_role
(
self
):
def
test_role
():
entity
=
Entity
(
role
=
"
TestRole
"
)
entity
=
Entity
(
role
=
"
TestRole
"
)
eq
(
entity
.
role
,
"
TestRole
"
)
eq
(
entity
.
role
,
"
TestRole
"
)
entity
.
role
=
"
TestRole2
"
entity
.
role
=
"
TestRole2
"
eq
(
entity
.
role
,
"
TestRole2
"
)
eq
(
entity
.
role
,
"
TestRole2
"
)
def
test_instanciation
(
self
):
self
.
assertRaises
(
Exception
,
Entity
())
This diff is collapsed.
Click to expand it.
unittests/test_record.py
+
17
−
2
View file @
6a004836
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#
#
# Copyright (C) 2018 Research Group Biomedical Physics,
# Copyright (C) 2018 Research Group Biomedical Physics,
# Max-Planck-Institute for Dynamics and Self-Organization Göttingen
# 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
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# it under the terms of the GNU Affero General Public License as
...
@@ -23,8 +24,12 @@
...
@@ -23,8 +24,12 @@
#
#
"""
Tests for the Record class.
"""
"""
Tests for the Record class.
"""
# pylint: disable=missing-docstring
# pylint: disable=missing-docstring
from
nose.tools
import
(
assert_is_not_none
as
there
,
assert_true
as
tru
,
import
unittest
assert_equal
as
eq
)
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
import
Entity
,
Record
,
configure_connection
from
caosdb.connection.mockup
import
MockUpServerConnection
from
caosdb.connection.mockup
import
MockUpServerConnection
...
@@ -48,3 +53,13 @@ def test_is_entity():
...
@@ -48,3 +53,13 @@ def test_is_entity():
def
test_role
():
def
test_role
():
record
=
Record
()
record
=
Record
()
eq
(
record
.
role
,
"
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
"
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment