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

TST: added a small test for the treatement of None values

parent 1c2f2393
No related branches found
No related tags found
2 merge requests!178FIX: #96 Better error output for crawl.py script.,!167Sync Graph
Pipeline #51439 passed with warnings
......@@ -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
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