Skip to content
Snippets Groups Projects
Commit 18aef0cf authored by Alexander Schlemmer's avatar Alexander Schlemmer
Browse files

TST: more tests for apiutils

parent 86311b39
No related branches found
No related tags found
2 merge requests!107ENH: add entity getters and cached functions,!103Improving the compare_entities functions
......@@ -101,15 +101,15 @@ def test_compare_entities():
r2 = db.Record()
r1.add_parent("bla")
r2.add_parent("bla")
r1.add_parent("lopp")
r1.add_parent("lopp") # r1 has one additional parent
r1.add_property("test", value=2)
r2.add_property("test", value=2)
r2.add_property("test", value=2) # a property with the same value
r1.add_property("tests", value=3)
r2.add_property("tests", value=45)
r2.add_property("tests", value=45) # a property with different value
r1.add_property("tester", value=3)
r2.add_property("tester", )
r2.add_property("tester", ) # a property where r2 has no value
r1.add_property("tests_234234", value=45)
r2.add_property("tests_TT", value=45)
r2.add_property("tests_TT", value=45) # one additional property that the other one does not have for both
diff_r1, diff_r2 = compare_entities(r1, r2)
......@@ -130,6 +130,28 @@ def test_compare_entities():
assert "tests_234234" in diff_r1["properties"]
assert "tests_TT" in diff_r2["properties"]
def test_compare_equality():
r1 = db.Record()
r2 = db.Record()
diff_r1, diff_r2 = compare_entities(r1, r2)
for i in ("parents", "properties"):
assert len(diff_r1[i]) == 0
assert len(diff_r2[i]) == 0
assert empty_diff(r1, r2)
r1.add_parent("bla")
r2.add_parent("bla")
assert empty_diff(r1, r2)
r1.add_property("test", value=2)
r2.add_property("test", value=2) # a property with the same value
diff_r1, diff_r2 = compare_entities(r1, r2)
assert empty_diff(r1, r2)
r1.add_parent("blobb")
r2.add_parent("blobb")
assert empty_diff(r1, r2)
def test_compare_entities_units():
r1 = db.Record()
......
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