Skip to content
Snippets Groups Projects
Commit 8809e683 authored by florian's avatar florian
Browse files

WIP: Update more errors

parent c99d9bc4
No related branches found
No related tags found
No related merge requests found
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
import caosdb as db import caosdb as db
import os import os
from nose.tools import nottest, assert_true, assert_raises, assert_equal, with_setup, assert_is_not_none # @UnresolvedImport from nose.tools import nottest, assert_true, assert_raises, assert_equal, with_setup, assert_is_not_none # @UnresolvedImport
from pytest import raises
def setup_module(): def setup_module():
...@@ -86,31 +87,33 @@ def test_rec_rt_is_instantiation(): ...@@ -86,31 +87,33 @@ def test_rec_rt_is_instantiation():
@with_setup(setup, teardown) @with_setup(setup, teardown)
def test_rec_prop_is_invalid(): def test_rec_prop_is_invalid():
with assert_raises(db.EntityError) as cm: with raises(db.TransactionError) as cm:
db.Record(name="TestRecordChild").add_parent(name=prop_name).insert() db.Record(name="TestRecordChild").add_parent(name=prop_name).insert()
assert_equal( assert cm.value.has_error(db.UnqualifiedParentsError)
cm.exception.get_errors()[0].msg, # TransactionError with UnqualifiedParentsError with EntityError
"Affiliation is not defined for this child-parent constellation.") # caused by wrong affiliation
ee = cm.value.get_errors()[0].get_errors()[0]
assert ee.msg == "Affiliation is not defined for this child-parent constellation."
@with_setup(setup, teardown) @with_setup(setup, teardown)
def test_rec_file_is_invalid(): def test_rec_file_is_invalid():
with assert_raises(db.EntityError) as cm: with raises(db.TransactionError) as cm:
db.Record(name="TestRecordChild").add_parent(name=file_name).insert() db.Record(name="TestRecordChild").add_parent(name=file_name).insert()
assert_equal( assert cm.value.has_error(db.UnqualifiedParentsError)
cm.exception.get_errors()[0].msg, ee = cm.value.get_errors()[0].get_errors()[0]
"Affiliation is not defined for this child-parent constellation.") assert ee.msg == "Affiliation is not defined for this child-parent constellation."
@with_setup(setup, teardown) @with_setup(setup, teardown)
def test_rt_rec_is_invalid(): def test_rt_rec_is_invalid():
with assert_raises(db.EntityError) as cm: with raises(db.TransactionError) as cm:
db.RecordType( db.RecordType(
name="TestRecordTypeChild").add_parent( name="TestRecordTypeChild").add_parent(
name=rec_name).insert() name=rec_name).insert()
assert_equal( assert cm.value.has_error(db.UnqualifiedParentsError)
cm.exception.get_errors()[0].msg, ee = cm.value.get_errors()[0].get_errors()[0]
"Affiliation is not defined for this child-parent constellation.") assert ee.msg == "Affiliation is not defined for this child-parent constellation."
@with_setup(setup, teardown) @with_setup(setup, teardown)
...@@ -122,48 +125,48 @@ def test_rt_rt_is_subtyping(): ...@@ -122,48 +125,48 @@ def test_rt_rt_is_subtyping():
@with_setup(setup, teardown) @with_setup(setup, teardown)
def test_rt_prop_is_invalid(): def test_rt_prop_is_invalid():
with assert_raises(db.EntityError) as cm: with raises(db.TransactionError) as cm:
db.RecordType( db.RecordType(
name="TestRecordTypeChild").add_parent( name="TestRecordTypeChild").add_parent(
name=prop_name).insert() name=prop_name).insert()
assert_equal( assert cm.value.has_error(db.UnqualifiedParentsError)
cm.exception.get_errors()[0].msg, ee = cm.value.get_errors()[0].get_errors()[0]
"Affiliation is not defined for this child-parent constellation.") assert ee.msg == "Affiliation is not defined for this child-parent constellation."
@with_setup(setup, teardown) @with_setup(setup, teardown)
def test_rt_file_is_invalid(): def test_rt_file_is_invalid():
with assert_raises(db.EntityError) as cm: with raises(db.TransactionError) as cm:
db.RecordType( db.RecordType(
name="TestRecordTypeChild").add_parent( name="TestRecordTypeChild").add_parent(
name=file_name).insert() name=file_name).insert()
assert_equal( assert cm.value.has_error(db.UnqualifiedParentsError)
cm.exception.get_errors()[0].msg, ee = cm.value.get_errors()[0].get_errors()[0]
"Affiliation is not defined for this child-parent constellation.") assert ee.msg == "Affiliation is not defined for this child-parent constellation."
@with_setup(setup, teardown) @with_setup(setup, teardown)
def test_prop_rec_is_invalid(): def test_prop_rec_is_invalid():
with assert_raises(db.EntityError) as cm: with raises(db.TransactionError) as cm:
db.Property( db.Property(
name="TestPropertyChild", name="TestPropertyChild",
datatype=db.TEXT).add_parent( datatype=db.TEXT).add_parent(
name=rec_name).insert() name=rec_name).insert()
assert_equal( assert cm.value.has_error(db.UnqualifiedParentsError)
cm.exception.get_errors()[0].msg, ee = cm.value.get_errors()[0].get_errors()[0]
"Affiliation is not defined for this child-parent constellation.") assert ee.msg == "Affiliation is not defined for this child-parent constellation."
@with_setup(setup, teardown) @with_setup(setup, teardown)
def test_prop_rt_is_invalid(): def test_prop_rt_is_invalid():
with assert_raises(db.EntityError) as cm: with raises(db.TransactionError) as cm:
db.Property( db.Property(
name="TestPropertyChild", name="TestPropertyChild",
datatype=db.TEXT).add_parent( datatype=db.TEXT).add_parent(
name=recty_name).insert() name=recty_name).insert()
assert_equal( assert cm.value.has_error(db.UnqualifiedParentsError)
cm.exception.get_errors()[0].msg, ee = cm.value.get_errors()[0].get_errors()[0]
"Affiliation is not defined for this child-parent constellation.") assert ee.msg == "Affiliation is not defined for this child-parent constellation."
@with_setup(setup, teardown) @with_setup(setup, teardown)
...@@ -177,14 +180,14 @@ def test_prop_prop_is_subtyping(): ...@@ -177,14 +180,14 @@ def test_prop_prop_is_subtyping():
@with_setup(setup, teardown) @with_setup(setup, teardown)
def test_prop_file_is_invalid(): def test_prop_file_is_invalid():
with assert_raises(db.EntityError) as cm: with raises(db.TransactionError) as cm:
db.Property( db.Property(
name="TestPropertyChild", name="TestPropertyChild",
datatype=db.TEXT).add_parent( datatype=db.TEXT).add_parent(
name=file_name).insert() name=file_name).insert()
assert_equal( assert cm.value.has_error(db.UnqualifiedParentsError)
cm.exception.get_errors()[0].msg, ee = cm.value.get_errors()[0].get_errors()[0]
"Affiliation is not defined for this child-parent constellation.") assert ee.msg == "Affiliation is not defined for this child-parent constellation."
@with_setup(setup, teardown) @with_setup(setup, teardown)
...@@ -209,28 +212,28 @@ def test_file_rt_is_instantiation(): ...@@ -209,28 +212,28 @@ def test_file_rt_is_instantiation():
@with_setup(setup, teardown) @with_setup(setup, teardown)
def test_file_prop_is_invalid(): def test_file_prop_is_invalid():
with assert_raises(db.EntityError) as cm: with raises(db.TransactionError) as cm:
db.File( db.File(
name="TestFileChild", name="TestFileChild",
file=file_path, file=file_path,
path="testfilechild.dat").add_parent( path="testfilechild.dat").add_parent(
name=prop_name).insert() name=prop_name).insert()
assert_equal( assert cm.value.has_error(db.UnqualifiedParentsError)
cm.exception.get_errors()[0].msg, ee = cm.value.get_errors()[0].get_errors()[0]
"Affiliation is not defined for this child-parent constellation.") assert ee.msg == "Affiliation is not defined for this child-parent constellation."
@with_setup(setup, teardown) @with_setup(setup, teardown)
def test_file_file_is_invalid(): def test_file_file_is_invalid():
with assert_raises(db.EntityError) as cm: with raises(db.TransactionError) as cm:
db.File( db.File(
name="TestFileChild", name="TestFileChild",
file=file_path, file=file_path,
path="testfilechild.dat").add_parent( path="testfilechild.dat").add_parent(
name=file_name).insert() name=file_name).insert()
assert_equal( assert cm.value.has_error(db.UnqualifiedParentsError)
cm.exception.get_errors()[0].msg, ee = cm.value.get_errors()[0].get_errors()[0]
"Affiliation is not defined for this child-parent constellation.") assert ee.msg == "Affiliation is not defined for this child-parent constellation."
@nottest @nottest
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
"""Tests for issues on gitlab.com, project caosdb-server.""" """Tests for issues on gitlab.com, project caosdb-server."""
import caosdb as db import caosdb as db
from caosdb.exceptions import EntityError from caosdb.exceptions import TransactionError
import pytest import pytest
...@@ -69,7 +69,7 @@ def test_issue_62(): ...@@ -69,7 +69,7 @@ def test_issue_62():
assert prop.datatype == rtb.name # fails; datatype not updated assert prop.datatype == rtb.name # fails; datatype not updated
# Can't use Test_RTA as datatype anymore # Can't use Test_RTA as datatype anymore
prop2 = db.Property(name="Test_Prop2", datatype="Test_RTA") prop2 = db.Property(name="Test_Prop2", datatype="Test_RTA")
with pytest.raises(EntityError): with pytest.raises(TransactionError):
prop2.insert() prop2.insert()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment