Skip to content
Snippets Groups Projects
Commit 69b7bd25 authored by florian's avatar florian
Browse files

WIP: Update test_tickets_300

parent 0ab9db18
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,8 @@
#
# Copyright (C) 2018 Research Group Biomedical Physics,
# Max-Planck-Institute for Dynamics and Self-Organization Göttingen
# Copyright (C) 2020 Indiscale GmbH <info@indiscale.com>
# Copyright (C) 2020 Florian Spreckelsen <f.spreckelsen@indiscale.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
......@@ -25,12 +27,12 @@
from __future__ import unicode_literals, print_function
import caosdb as db
from nose.tools import with_setup, assert_raises as raiz, assert_equal as eq
from pytest import raises
def _delete_test_entities():
try:
db.execute_query("FIND Entity WITH id >= 100").delete()
db.execute_query("FIND Test*").delete()
except Exception as e:
print(e)
......@@ -43,14 +45,23 @@ def teardown_module():
_delete_test_entities()
@with_setup(_delete_test_entities, _delete_test_entities)
def setup():
setup_module()
def teardown():
teardown_module()
def test_ticket_350_insert_with_invalid_ref():
c = db.Container()
e = db.Entity(name="SomeName")
rt1 = db.RecordType(name="RT1")
rt2 = db.RecordType(name="RT2").add_property(name="RT1", value="SomeName")
e = db.Entity(name="TestEnt")
rt1 = db.RecordType(name="TestRT1")
rt2 = db.RecordType(name="TestRT2").add_property(
name="TestRT1", value="TestEnt")
c.extend([e, rt1, rt2])
with raiz(db.TransactionError) as cm:
with raises(db.TransactionError) as cm:
c.insert()
eq(cm.exception.errors[0].msg, "There is no such role 'Entity'.")
eq(cm.exception.errors[1].msg, "Entity has unqualified properties.")
assert any(
[x.msg == "There is no such role 'Entity'." for x in cm.value.get_errors()])
assert cm.value.has_error(db.UnqualifiedPropertiesError)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment