Skip to content
Snippets Groups Projects
Commit 2b7cf624 authored by Alexander Schlemmer's avatar Alexander Schlemmer
Browse files

TST: improved and expanded tests for high level api

parent aa9d1836
No related branches found
No related tags found
2 merge requests!57RELEASE 0.7.3,!52F refactor high level api
......@@ -26,6 +26,7 @@
import caosdb as db
from caosdb.high_level_api import (convert_to_entity, convert_to_python_object)
from caosdb.high_level_api import (CaosDBPythonUnresolvedParent,)
import pytest
from lxml import etree
import os
......@@ -42,8 +43,6 @@ def testrecord():
return testrecord
def test_convert_object(testrecord):
r2 = convert_to_python_object(testrecord)
assert r2.species == "Rabbit"
......@@ -71,5 +70,28 @@ def test_convert_record():
assert obj.a == 42
assert obj.b == "test"
# There is no such property
with pytest.raises(AttributeError):
assert obj.c == 18
assert obj.has_parent("bla") is True
assert obj.has_parent(CaosDBPythonUnresolvedParent(name="bla")) is True
# Check the has_parent function:
assert obj.has_parent("test") is False
assert obj.has_parent(CaosDBPythonUnresolvedParent(name="test")) is False
# duplicate parent
with pytest.raises(RuntimeError):
obj.add_parent("bla")
# add parent with just an id:
obj.add_parent(CaosDBPythonUnresolvedParent(id=225))
assert obj.has_parent(225) is True
assert obj.has_parent(CaosDBPythonUnresolvedParent(id=225)) is True
assert obj.has_parent(226) is False
assert obj.has_parent(CaosDBPythonUnresolvedParent(id=228)) is False
# same with just a name:
obj.add_parent(CaosDBPythonUnresolvedParent(name="another"))
assert obj.has_parent("another") is True
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment