From a43920b9d6743adc468f77f0478fed3ff1a47626 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver <thomas@kluyver.me.uk> Date: Thu, 5 Jan 2023 16:56:02 +0000 Subject: [PATCH] Add test for recursive_update() --- tests/test_cal_tools.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test_cal_tools.py b/tests/test_cal_tools.py index 7343c6f5b..edf08193a 100644 --- a/tests/test_cal_tools.py +++ b/tests/test_cal_tools.py @@ -19,6 +19,7 @@ from cal_tools.tools import ( map_seq_files, module_index_to_qm, send_to_db, + recursive_update, ) # AGIPD operating conditions. @@ -471,3 +472,15 @@ def test_module_index_to_qm(): with pytest.raises(AssertionError): module_index_to_qm(7, 5) + + +def test_recursive_update(): + tgt = {"a": {"b": 1}, "c": 2} + src = {"a": {"d": 3}, "e": 4} + assert recursive_update(tgt, src) is False + assert tgt == {"a": {"b": 1, "d": 3}, "c": 2, "e": 4} + + tgt = {"a": {"b": 1}, "c": 2} + src = {"a": {"b": 3}, "e": 4} + assert recursive_update(tgt, src) is True + assert tgt == {"a": {"b": 1}, "c": 2, "e": 4} -- GitLab