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