diff --git a/unittests/test_sync_graph.py b/unittests/test_sync_graph.py index ab0a46bc1cb98cd9349037ce5cdbe7ed2ace7dab..8dbceadb654caac88248e4fec83b4316c8c5abd0 100644 --- a/unittests/test_sync_graph.py +++ b/unittests/test_sync_graph.py @@ -29,7 +29,7 @@ from caoscrawler.exceptions import (ImpossibleMergeError, MissingIdentifyingProperty) from caoscrawler.identifiable import Identifiable from caoscrawler.identifiable_adapters import CaosDBIdentifiableAdapter -from caoscrawler.sync_graph import SyncGraph +from caoscrawler.sync_graph import SyncGraph, _set_each_scalar_value from caoscrawler.sync_node import SyncNode, parent_in_list, property_in_list from itertools import product @@ -604,3 +604,15 @@ def test_detect_circular_dependency(crawler_mocked_identifiable_retrieve, caplog assert "Found circular dependency" in caplog.text assert "\n--------\n\n> Parent: C\n\n>> Name: a\n[\'C\']" in caplog.text caplog.clear() + + +def test_set_each_scalar_value(): + """Test whether properties with None as value are treated appropriately.""" + a = SyncNode(db.Record().add_parent("RT1").add_property(name="bla"), + db.RecordType().add_property("is_referenced_by", ["RT2"])) + _set_each_scalar_value(a, lambda x: False, None) + _set_each_scalar_value(a, lambda x: isinstance(x, SyncNode), None) + _set_each_scalar_value(a, lambda x: x is None, lambda x: 42) + assert a.properties[0].value == 42 + _set_each_scalar_value(a, lambda x: x == 42, lambda x: None) + assert a.properties[0].value is None