-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: ravi_kumar_pilla <[email protected]>
- Loading branch information
1 parent
6f4fcc3
commit cdc2d7a
Showing
3 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from kedro_viz.utils import merge_dicts | ||
|
||
|
||
class TestUtils: | ||
def test_merge_dicts_flat(self): | ||
"""Test merging flat dictionaries.""" | ||
dict_one = {"a": 1, "b": 2} | ||
dict_two = {"b": 3, "c": 4} | ||
expected = {"a": 1, "b": 3, "c": 4} | ||
|
||
result = merge_dicts(dict_one, dict_two) | ||
assert result == expected | ||
|
||
def test_merge_dicts_nested(self): | ||
"""Test merging nested dictionaries.""" | ||
dict_one = {"a": {"x": 1}, "b": 2} | ||
dict_two = {"a": {"y": 2}, "c": 3} | ||
expected = {"a": {"x": 1, "y": 2}, "b": 2, "c": 3} | ||
|
||
result = merge_dicts(dict_one, dict_two) | ||
assert result == expected | ||
|
||
def test_merge_dicts_overwrite(self): | ||
"""Test merging with overwriting nested keys.""" | ||
dict_one = {"a": {"x": 1, "y": 2}} | ||
dict_two = {"a": {"x": 3}} | ||
expected = {"a": {"x": 3, "y": 2}} | ||
|
||
result = merge_dicts(dict_one, dict_two) | ||
assert result == expected | ||
|
||
def test_merge_dicts_empty(self): | ||
"""Test merging when one dictionary is empty.""" | ||
dict_one = {"a": 1} | ||
dict_two = {} | ||
expected = {"a": 1} | ||
|
||
result = merge_dicts(dict_one, dict_two) | ||
assert result == expected | ||
|
||
result = merge_dicts(dict_two, dict_one) | ||
assert result == expected |