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

TST: refactor tests for new _parse_value implementation

parent 49780fd0
No related branches found
No related tags found
No related merge requests found
...@@ -99,14 +99,14 @@ def test_record(): ...@@ -99,14 +99,14 @@ def test_record():
assert_equal( assert_equal(
rec1.get_property("SimpleBooleanProperty").datatype, rec1.get_property("SimpleBooleanProperty").datatype,
h.BOOLEAN) h.BOOLEAN)
assert_equal(rec1.get_property("SimpleBooleanProperty").value, "TRUE") assert_equal(rec1.get_property("SimpleBooleanProperty").value, True)
rec1c = h.Record(id=rec1.id).retrieve() rec1c = h.Record(id=rec1.id).retrieve()
assert_true(rec1c.is_valid()) assert_true(rec1c.is_valid())
assert_equal(rec1c.get_property( assert_equal(rec1c.get_property(
"SimpleBooleanProperty").datatype, h.BOOLEAN) "SimpleBooleanProperty").datatype, h.BOOLEAN)
assert_equal(rec1c.get_property( assert_equal(rec1c.get_property(
"SimpleBooleanProperty").value, "TRUE") "SimpleBooleanProperty").value, True)
rec2 = h.Record(name="SimpleRecord2").add_parent( rec2 = h.Record(name="SimpleRecord2").add_parent(
rt).add_property(p, value=True).insert() rt).add_property(p, value=True).insert()
...@@ -114,18 +114,18 @@ def test_record(): ...@@ -114,18 +114,18 @@ def test_record():
assert_equal( assert_equal(
rec2.get_property("SimpleBooleanProperty").datatype, rec2.get_property("SimpleBooleanProperty").datatype,
h.BOOLEAN) h.BOOLEAN)
assert_equal(rec2.get_property("SimpleBooleanProperty").value, "TRUE") assert_equal(rec2.get_property("SimpleBooleanProperty").value, True)
rec2c = h.Record(id=rec2.id).retrieve() rec2c = h.Record(id=rec2.id).retrieve()
assert_true(rec2c.is_valid()) assert_true(rec2c.is_valid())
assert_equal(rec2c.get_property( assert_equal(rec2c.get_property(
"SimpleBooleanProperty").datatype, h.BOOLEAN) "SimpleBooleanProperty").datatype, h.BOOLEAN)
assert_equal(rec2c.get_property( assert_equal(rec2c.get_property(
"SimpleBooleanProperty").value, "TRUE") "SimpleBooleanProperty").value, True)
rec3 = h.Record( rec3 = h.Record(
name="SimpleRecord3").add_parent(rt).add_property( name="SimpleRecord3").add_parent(rt).add_property(
p, value="BLABLA") p.name, value="BLABLA")
assert_raises(EntityError, rec3.insert) assert_raises(EntityError, rec3.insert)
assert_false(rec3.is_valid()) assert_false(rec3.is_valid())
......
...@@ -35,6 +35,7 @@ def test_parse_xml(): ...@@ -35,6 +35,7 @@ def test_parse_xml():
from caosdb.common.models import Parent from caosdb.common.models import Parent
from caosdb.common.models import Property from caosdb.common.models import Property
from caosdb.common.models import Message from caosdb.common.models import Message
from caosdb import INTEGER
# define test file xml # define test file xml
tmp_name = 'filename' tmp_name = 'filename'
...@@ -68,15 +69,16 @@ def test_parse_xml(): ...@@ -68,15 +69,16 @@ def test_parse_xml():
tmp_prop_id = "103" tmp_prop_id = "103"
tmp_prop_desc = "prop desc" tmp_prop_desc = "prop desc"
tmp_prop_unit = "meter" tmp_prop_unit = "meter"
tmp_prop_exp = 9
tmp_prop_value = 10 tmp_prop_value = 10
tmp_prop_imp = "recommended" tmp_prop_imp = "recommended"
tmp_prop_dtype = INTEGER
prop = etree.Element("Property") prop = etree.Element("Property")
prop.set("id", str(tmp_prop_id)) prop.set("id", str(tmp_prop_id))
prop.set("importance", str(tmp_prop_imp)) prop.set("importance", str(tmp_prop_imp))
prop.set("name", str(tmp_prop_name)) prop.set("name", str(tmp_prop_name))
prop.set("description", str(tmp_prop_desc)) prop.set("description", str(tmp_prop_desc))
prop.set("unit", str(tmp_prop_unit)) prop.set("unit", str(tmp_prop_unit))
prop.set("datatype", tmp_prop_dtype)
prop.text = str(tmp_prop_value) prop.text = str(tmp_prop_value)
elem.append(prop) elem.append(prop)
...@@ -88,8 +90,6 @@ def test_parse_xml(): ...@@ -88,8 +90,6 @@ def test_parse_xml():
elem.append(msg) elem.append(msg)
xml = etree.tostring(elem, pretty_print=True) xml = etree.tostring(elem, pretty_print=True)
print("========= Testing =========")
print(xml)
filerec = parse_xml(xml) filerec = parse_xml(xml)
assert isinstance(filerec, File) assert isinstance(filerec, File)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment