diff --git a/tests/core/test_unflatten.py b/tests/core/test_unflatten.py index 4334942..d1931ec 100644 --- a/tests/core/test_unflatten.py +++ b/tests/core/test_unflatten.py @@ -8,5 +8,71 @@ import unittest class unflatten_test_case(unittest.TestCase): def test_unflatten(self): - # TODO - pass + d = { + 'a': 1, + 'b_c': 2, + 'd_e': 3, + } + u = _unflatten(d) + r = { + 'a': 1, + 'b': { + 'c': 2, + }, + 'd': { + 'e': 3, + }, + } + self.assertEqual(u, r) + + def test_unflatten_with_custom_separator(self): + d = { + 'a': 1, + 'b|c': 2, + 'd|e': 3, + } + u = _unflatten(d, separator='#') + self.assertEqual(u, d) + u = _unflatten(d, separator='|') + r = { + 'a': 1, + 'b': { + 'c': 2, + }, + 'd': { + 'e': 3, + }, + } + self.assertEqual(u, r) + + def test_unflatten_with_nested_dict(self): + d = { + 'a': 1, + 'b_c': { + 'u_v': 2, + }, + 'd_e': { + 'x_y_z': 3, + }, + } + u = _unflatten(d) + r = { + 'a': 1, + 'b': { + 'c': { + 'u': { + 'v': 2, + }, + }, + }, + 'd': { + 'e': { + 'x': { + 'y': { + 'z': 3, + }, + }, + }, + }, + } + self.assertEqual(u, r)