diff --git a/src/linkahead/apiutils.py b/src/linkahead/apiutils.py index bef01201d39f260139440b4cb939a7c22c943a77..558266f9c0621cb1b16d38c935fafa1f655e9ba4 100644 --- a/src/linkahead/apiutils.py +++ b/src/linkahead/apiutils.py @@ -215,6 +215,9 @@ def compare_entities(old_entity: Entity, new_entity: Entity, compare_referenced_ if old_entity is new_entity: return (olddiff, newdiff) + if (isinstance(old_entity, Property) or isinstance(old_entity, Property)): + raise NotImplementedError("Comparing Properties is currently not supported.") + for attr in SPECIAL_ATTRIBUTES: try: oldattr = old_entity.__getattribute__(attr) @@ -246,7 +249,6 @@ def compare_entities(old_entity: Entity, new_entity: Entity, compare_referenced_ newdiff[attr] = newattr # properties - for prop in old_entity.properties: matching = [p for p in new_entity.properties if p.name == prop.name] diff --git a/unittests/test_apiutils.py b/unittests/test_apiutils.py index 3ed719f7b00a4c5bf25583ac6729738d3d872f57..ea13ba442bfe67ba394d9b360ae88d26ebe113bb 100644 --- a/unittests/test_apiutils.py +++ b/unittests/test_apiutils.py @@ -211,48 +211,6 @@ def test_compare_special_properties(): assert len(diff_r2["properties"]) == 0 -@pytest.mark.xfail -def test_compare_properties(): - p1 = db.Property() - p2 = db.Property() - - diff_r1, diff_r2 = compare_entities(p1, p2) - assert len(diff_r1["parents"]) == 0 - assert len(diff_r2["parents"]) == 0 - assert len(diff_r1["properties"]) == 0 - assert len(diff_r2["properties"]) == 0 - - p1.importance = "SUGGESTED" - diff_r1, diff_r2 = compare_entities(p1, p2) - assert len(diff_r1["parents"]) == 0 - assert len(diff_r2["parents"]) == 0 - assert len(diff_r1["properties"]) == 0 - assert len(diff_r2["properties"]) == 0 - assert "importance" in diff_r1 - assert diff_r1["importance"] == "SUGGESTED" - - # TODO: I'm not sure why it is not like this: - # assert diff_r2["importance"] is None - # ... but: - assert "importance" not in diff_r2 - - p2.importance = "SUGGESTED" - p1.value = 42 - p2.value = 4 - - diff_r1, diff_r2 = compare_entities(p1, p2) - assert len(diff_r1["parents"]) == 0 - assert len(diff_r2["parents"]) == 0 - assert len(diff_r1["properties"]) == 0 - assert len(diff_r2["properties"]) == 0 - - # Comparing values currently does not seem to be implemented: - assert "value" in diff_r1 - assert diff_r1["value"] == 42 - assert "value" in diff_r2 - assert diff_r2["value"] == 4 - - def test_copy_entities(): r = db.Record(name="A") r.add_parent(name="B")