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