Skip to content
Snippets Groups Projects
Commit af9114ee authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

MAINT: cosmetics

parent 968133d4
Branches
Tags
No related merge requests found
......@@ -5,4 +5,3 @@ setup(
packages=find_packages(),
tests_require=["nose>=1.0"],
)
......@@ -26,13 +26,17 @@
@author: tf
"""
from __future__ import absolute_import, print_function, unicode_literals
import caosdb as db
from tests import test_misc
from caosdb.exceptions import CaosDBException, TransactionError, EntityError, UniqueNamesError, AmbiguityException, EntityDoesNotExistError
from nose.tools import (nottest, assert_true, assert_raises, assert_not_equals,
assert_equals, assert_false, assert_is_not_none,
assert_is_none)
from caosdb.exceptions import (AmbiguityException, CaosDBException,
EntityDoesNotExistError, EntityError,
TransactionError, UniqueNamesError)
from nose import with_setup
from nose.tools import (assert_equals, assert_false, assert_is_none,
assert_is_not_none, assert_raises, assert_true,
nottest)
from tests import test_misc
def setup_module():
......@@ -62,6 +66,7 @@ def test_ticket_103a():
for w in rt.get_warnings():
haswarnings = True
break
assert_true(haswarnings)
......@@ -73,6 +78,7 @@ def test_ticket_103a():
for w in rt.get_warnings():
haswarnings = True
break
assert_true(haswarnings)
......@@ -86,13 +92,17 @@ def test_ticket_103a():
assert_equals(128, int(exc.get_code()))
rt = exc.get_entities()[0]
assert_false(rt.is_valid())
for w in rt.get_warnings():
haswarnings = True
break
assert_true(haswarnings)
for w in rt.get_errors():
if w.get_code() == 128:
hasstricterror = True
break
assert_true(hasstricterror)
finally:
......@@ -108,13 +118,17 @@ def test_ticket_103a():
try:
rt.insert(strict=True, raise_exception_on_error=False)
assert_false(rt.is_valid())
for w in rt.get_warnings():
haswarnings = True
break
assert_true(haswarnings)
for w in rt.get_errors():
if w.get_code() == 128:
hasstricterror = True
break
assert_true(hasstricterror)
finally:
......@@ -323,7 +337,8 @@ def test_ticket_120():
assert_equals(r3.id, cr3.id)
cr3 = db.Query(
"FIND RECORD WHICH HAS A PROPERTY blabla=4 OR SimpleRT1->SimpleRT2 WHICH HAS A PROPERTY SimpleRT1->" +
"FIND RECORD WHICH HAS A PROPERTY blabla=4 OR SimpleRT1->SimpleRT2"
" WHICH HAS A PROPERTY SimpleRT1->" +
str(
r1.id) +
"").execute(
......@@ -336,7 +351,8 @@ def test_ticket_120():
assert_equals(r3.id, cr3.id)
cr3 = db.Query(
"FIND RECORD SimpleRT1 . SimpleRT1.SimpleRT1.SimpleDoubleProperty='3.14'"
"FIND RECORD SimpleRT1 . "
"SimpleRT1.SimpleRT1.SimpleDoubleProperty='3.14'"
).execute(unique=True)
assert_equals(r3.id, cr3.id)
......@@ -412,6 +428,7 @@ def test_ticket_106():
try:
rt = db.RecordType(name="test RT 2")
rt.insert()
while True:
try:
rt.insert()
......@@ -419,6 +436,7 @@ def test_ticket_106():
"2nd insert should raise an TransactionError")
except db.exceptions.TransactionError as e:
print(e)
break
finally:
rt.delete()
......@@ -608,11 +626,13 @@ def test_ticket_39():
path="testfiles/file1", from_location=testfile).insert()
except EntityError as e:
assert_equals(
"Insufficient read permission for this file. Please make it readable.",
"Insufficient read permission for this file. "
"Please make it readable.",
e.msg)
finally:
os.chmod(testfile, 0o600)
if len(db.execute_query("FIND RT1")) > 0:
rt1.delete()
try:
......@@ -804,6 +824,7 @@ def test_ticket_147():
r5 = db.Record().add_parent(bmsim).add_property(tstep, value="0.003")
c.extend([r1, r2, r3, r4, r5]).insert()
assert_true(c.is_valid())
for e in c:
assert_true(e.is_valid())
......@@ -1083,6 +1104,7 @@ def test_ticket_166():
r5 = db.Record().add_parent(bmsim).add_property(tstep, value="0.003")
c.extend([r1, r2, r3, r4, r5]).insert()
assert_true(c.is_valid())
for e in c:
assert_true(e.is_valid())
......@@ -1113,6 +1135,7 @@ def test_ticket_166():
q.putFlag("P", "0L5")
ret = q.execute()
assert_equals(5, len(ret))
for e in ret:
assert_equals(bmsim.id, e.get_parents()[0].id)
......@@ -1120,6 +1143,7 @@ def test_ticket_166():
q.putFlag("P", "5L4")
ret = q.execute()
assert_equals(4, len(ret))
for e in ret:
assert_equals(frm.id, e.get_parents()[0].id)
......@@ -1305,6 +1329,7 @@ def test_ticket_165():
c = db.Container().extend([p, rt_a, rt_b, r_a]).insert()
assert_true(c.is_valid())
for e in c:
assert_true(e.is_valid())
......@@ -1438,18 +1463,22 @@ def test_ticket_174():
assert_true(c.is_valid())
assert_true(rt1.is_valid())
for i in range(len(rt1.get_properties())):
assert_equals(i + 1.0, float(rt1.get_properties()[i].value))
assert_true(rt2.is_valid())
for i in range(len(rt2.get_properties())):
assert_equals(i + 1.0, float(rt2.get_properties()[i].value))
assert_true(rt3.is_valid())
for i in range(len(rt3.get_properties())):
assert_equals(i + 1.0, float(rt3.get_properties()[i].value))
assert_true(rt4.is_valid())
for i in range(len(rt4.get_properties())):
assert_equals(i + 1.0, float(rt4.get_properties()[i].value))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment