Skip to content
Snippets Groups Projects
Verified Commit 429d3d2f authored by Timm Fitschen's avatar Timm Fitschen
Browse files

STY: formatting pep8

parent 4cf39b3f
Branches
Tags
No related merge requests found
...@@ -23,6 +23,7 @@ import pytest ...@@ -23,6 +23,7 @@ import pytest
import caosdb as db import caosdb as db
def setup(): def setup():
teardown() teardown()
rt = db.RecordType("TestRT") rt = db.RecordType("TestRT")
...@@ -30,12 +31,14 @@ def setup(): ...@@ -30,12 +31,14 @@ def setup():
p = db.Property("TestProp", datatype=db.TEXT) p = db.Property("TestProp", datatype=db.TEXT)
p.insert() p.insert()
def teardown(): def teardown():
try: try:
db.execute_query("FIND Test*").delete() db.execute_query("FIND Test*").delete()
except Exception as e: except Exception as e:
print(e) print(e)
def test_empty_string(): def test_empty_string():
r1 = db.Record() r1 = db.Record()
r1.add_parent("TestRT") r1.add_parent("TestRT")
...@@ -43,21 +46,27 @@ def test_empty_string(): ...@@ -43,21 +46,27 @@ def test_empty_string():
r1.insert() r1.insert()
# value was stored correctly # value was stored correctly
assert db.execute_query("FIND Record TestRT", unique=True).get_property("TestProp").value == "" assert db.execute_query("FIND Record TestRT", unique=True).get_property(
"TestProp").value == ""
# query language works for empty string # query language works for empty string
assert db.execute_query("FIND TestRT with TestProp=''", unique=True).id == r1.id assert db.execute_query(
assert db.execute_query('FIND TestRT with TestProp=""', unique=True).get_property("TestProp").value == "" "FIND TestRT with TestProp=''", unique=True).id == r1.id
assert db.execute_query('FIND TestRT with TestProp=""',
unique=True).get_property("TestProp").value == ""
r2 = db.Record() r2 = db.Record()
r2.add_parent("TestRT") r2.add_parent("TestRT")
r2.add_property("TestProp", value="not empty") r2.add_property("TestProp", value="not empty")
r2.insert() r2.insert()
assert db.execute_query("FIND TestRT with TestProp='not empty'", unique=True).id == r2.id assert db.execute_query(
"FIND TestRT with TestProp='not empty'", unique=True).id == r2.id
# query language work while other records with non empty values are present # query language work while other records with non empty values are present
assert db.execute_query("FIND TestRT with TestProp=''", unique=True).id == r1.id assert db.execute_query(
"FIND TestRT with TestProp=''", unique=True).id == r1.id
assert len(db.execute_query("FIND Record TestRT")) == 2 assert len(db.execute_query("FIND Record TestRT")) == 2
def test_null_value(): def test_null_value():
r1 = db.Record() r1 = db.Record()
r1.add_parent("TestRT") r1.add_parent("TestRT")
...@@ -68,7 +77,8 @@ def test_null_value(): ...@@ -68,7 +77,8 @@ def test_null_value():
assert db.execute_query("FIND Record TestRT", assert db.execute_query("FIND Record TestRT",
unique=True).get_property("TestProp").value == None unique=True).get_property("TestProp").value == None
# query language works with null value # query language works with null value
assert db.execute_query("FIND TestRT WHERE TestProp IS NULL", unique=True).id == r1.id assert db.execute_query(
"FIND TestRT WHERE TestProp IS NULL", unique=True).id == r1.id
# add a bit of noise # add a bit of noise
r2 = db.Record() r2 = db.Record()
...@@ -76,11 +86,14 @@ def test_null_value(): ...@@ -76,11 +86,14 @@ def test_null_value():
r2.add_property("TestProp", value="null") r2.add_property("TestProp", value="null")
r2.insert() r2.insert()
assert db.execute_query("FIND TestRT with TestProp='null'", unique=True).id == r2.id assert db.execute_query(
"FIND TestRT with TestProp='null'", unique=True).id == r2.id
# query language works while other record with non-null values are present # query language works while other record with non-null values are present
assert db.execute_query("FIND TestRT WHERE TestProp IS NULL", unique=True).id == r1.id assert db.execute_query(
"FIND TestRT WHERE TestProp IS NULL", unique=True).id == r1.id
assert len(db.execute_query("FIND Record TestRT")) == 2 assert len(db.execute_query("FIND Record TestRT")) == 2
def test_list_with_empty_string(): def test_list_with_empty_string():
r1 = db.Record() r1 = db.Record()
r1.add_parent("TestRT") r1.add_parent("TestRT")
...@@ -91,7 +104,8 @@ def test_list_with_empty_string(): ...@@ -91,7 +104,8 @@ def test_list_with_empty_string():
assert db.execute_query("FIND Record TestRT", assert db.execute_query("FIND Record TestRT",
unique=True).get_property("TestProp").value == [""] unique=True).get_property("TestProp").value == [""]
# query language works # query language works
assert db.execute_query("FIND TestRT with TestProp=''", unique=True).id == r1.id assert db.execute_query(
"FIND TestRT with TestProp=''", unique=True).id == r1.id
r2 = db.Record() r2 = db.Record()
r2.add_parent("TestRT") r2.add_parent("TestRT")
...@@ -99,8 +113,11 @@ def test_list_with_empty_string(): ...@@ -99,8 +113,11 @@ def test_list_with_empty_string():
r2.insert() r2.insert()
assert db.execute_query("FIND Record TestRT with TestProp='leer'", assert db.execute_query("FIND Record TestRT with TestProp='leer'",
unique=True).get_property("TestProp").value == ["leer"] unique=True).get_property("TestProp").value == ["leer"]
assert db.execute_query("FIND TestRT with TestProp='leer'", unique=True).id == r2.id assert db.execute_query(
assert db.execute_query("FIND TestRT with TestProp=''", unique=True).id == r1.id "FIND TestRT with TestProp='leer'", unique=True).id == r2.id
assert db.execute_query(
"FIND TestRT with TestProp=''", unique=True).id == r1.id
def test_null_list(): def test_null_list():
r1 = db.Record() r1 = db.Record()
...@@ -111,7 +128,8 @@ def test_null_list(): ...@@ -111,7 +128,8 @@ def test_null_list():
# null list was stored correctly # null list was stored correctly
assert db.execute_query("FIND Record TestRT", assert db.execute_query("FIND Record TestRT",
unique=True).get_property("TestProp").value == None unique=True).get_property("TestProp").value == None
assert db.execute_query("FIND TestRT WHERE TestProp IS NULL", unique=True).id == r1.id assert db.execute_query(
"FIND TestRT WHERE TestProp IS NULL", unique=True).id == r1.id
@pytest.mark.skip(reason="""this is the confirmation for @pytest.mark.skip(reason="""this is the confirmation for
...@@ -145,4 +163,3 @@ def test_list_with_null_value(): ...@@ -145,4 +163,3 @@ def test_list_with_null_value():
unique=True).get_property("TestProp").value == [None] unique=True).get_property("TestProp").value == [None]
# assert db.execute_query("FIND TestRT WHERE TestProp IS NULL", unique=True).id == r.id # assert db.execute_query("FIND TestRT WHERE TestProp IS NULL", unique=True).id == r.id
r.delete() r.delete()
...@@ -860,7 +860,6 @@ def test_stored_at_wildcards(): ...@@ -860,7 +860,6 @@ def test_stored_at_wildcards():
assert c.get_entity_by_id(file8.id) is not None assert c.get_entity_by_id(file8.id) is not None
@with_setup(setup, teardown) @with_setup(setup, teardown)
def test_int(): def test_int():
pint = h.Property(name="TestIntegerProperty", datatype=h.INTEGER).insert() pint = h.Property(name="TestIntegerProperty", datatype=h.INTEGER).insert()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment