mirror of
https://github.com/reconurge/flowsint.git
synced 2026-07-15 21:23:01 -05:00
- big refactor to properly use GraphService, and enforce dependency injection BREAKING CHANGE: The usage of node.label is no longer supported in the app, a specific node format is used throughout the app and for inserting in the neo4j.
39 lines
893 B
Python
39 lines
893 B
Python
from flowsint_core.utils import flatten, unflatten
|
|
|
|
my_dict = {
|
|
"root_key_1": "value 1",
|
|
"root_key_2": 2,
|
|
"root_key_3": "value 3",
|
|
"root_key_4": {
|
|
"child_key_1": "child 1",
|
|
"child_key_2": "child 2",
|
|
"child_key_3": {"grand_child_1": 0},
|
|
},
|
|
}
|
|
|
|
my_flat_dict = {
|
|
"root_key_1": "value 1",
|
|
"root_key_2": 2,
|
|
"root_key_3": "value 3",
|
|
"root_key_4.child_key_1": "child 1",
|
|
"root_key_4.child_key_2": "child 2",
|
|
"root_key_4.child_key_3.grand_child_1": 0,
|
|
}
|
|
|
|
my_flat_dict_other_separator = {
|
|
"root_key_1": "value 1",
|
|
"root_key_2": 2,
|
|
"root_key_3": "value 3",
|
|
"root_key_4_child_key_1": "child 1",
|
|
"root_key_4_child_key_2": "child 2",
|
|
"root_key_4_child_key_3_grand_child_1": 0,
|
|
}
|
|
|
|
|
|
def test_flatten():
|
|
assert flatten(my_dict) == my_flat_dict
|
|
|
|
|
|
def test_unflatten():
|
|
assert unflatten(my_flat_dict) == my_dict
|