Skip to content
Snippets Groups Projects
Commit 9e055a93 authored by florian's avatar florian
Browse files

TST: Add test for ambiguous retrieval

... and mark it as xfail until dealt with on server side
parent 611d48f7
Branches
Tags
No related merge requests found
...@@ -31,7 +31,8 @@ Created on 19.02.2015. ...@@ -31,7 +31,8 @@ Created on 19.02.2015.
""" """
import caosdb as h import caosdb as h
from caosdb.exceptions import (EntityDoesNotExistError, EntityError, from caosdb.exceptions import (AmbiguousEntityError,
EntityDoesNotExistError, EntityError,
EntityHasNoDatatypeError, EntityHasNoDatatypeError,
TransactionError, UniqueNamesError, TransactionError, UniqueNamesError,
UnqualifiedParentsError, UnqualifiedParentsError,
...@@ -86,6 +87,23 @@ def test_retrieval_exception_raised(): ...@@ -86,6 +87,23 @@ def test_retrieval_exception_raised():
assert ee.entity.has_errors() assert ee.entity.has_errors()
@pytest.mark.xfail(reason=("Error treatment on server-side"
"has to be implemented first."))
def test_ambiguous_retrieval():
"""Test if a TransactionError containing an AmbiguousEntityError is
raised correctly if there are two possible candidates.
"""
h.RecordType(name="TestType").insert()
h.Record(name="TestRec").add_parent(name="TestType").insert()
# Insert twice, so unique=False
h.Record(name="TestRec").add_parent(name="TestType").insert(unique=False)
with pytest.raises(TransactionError) as te:
h.Record(name="TestRec").retrieve()
assert te.value.has_error(AmbiguousEntityError)
assert te.value.errors[0].entity.name == "TestRec"
def test_insertion_no_exception_raised(): def test_insertion_no_exception_raised():
"""Test whether insertion fails but no error is raised.""" """Test whether insertion fails but no error is raised."""
p = h.Property(name="TestNoTypeProperty").insert( p = h.Property(name="TestNoTypeProperty").insert(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment