예제 #1
0
    def test_collapse__function_arg(self):
        a = NestedDict({"k1": {"k2": {"$foo": {"k3": {"k4": "v"}}}}})

        def detect_operator(key, *args):
            return key[0] == "$"

        b = a.collapse(func=detect_operator)
        self.assertEqual(b, {("k1", "k2"): {"$foo": {("k3", "k4"): "v"}}})
예제 #2
0
    def test_collapse__function_arg__stop_at_root(self):
        a = NestedDict({"k1": {"k2": {"$foo": {"k3": {"k4": "v"}}}}})

        def detect_operator(key, *args):
            return key == "k1"

        b = a.collapse(func=detect_operator)
        self.assertEqual(b, {"k1": {("k2", "$foo", "k3", "k4"): "v"}})
예제 #3
0
 def test__expand(self):
     a = NestedDict({"k1": {"k2": {"k3": "v"}}})
     b = a._expand(a.collapse())
     self.assertEqual(b, a.get())
예제 #4
0
 def test_collapse(self):
     a = NestedDict({"k1": {"k2": {"k3": "v"}}})
     b = a.collapse()
     self.assertEqual(b, {("k1", "k2", "k3"): "v"})