예제 #1
0
    def test_dict(self):
        s = {"s": 1, "w": 5, "t": {"m": 0, "x": {"y": "z"}}}

        exp = expand(s)
        _s = restore(exp)

        self.assertDictEqual(s, _s)
예제 #2
0
    def test_expand_and_restore(self):
        data = ["a", "ab", "b"] * 4
        expobj = expand(data)
        self.assertEqual(expobj["0"], "a")
        self.assertEqual(expobj["1"], "ab")

        origin = restore(expobj)
        self.assertEqual(data, origin)
예제 #3
0
    def test_expand_with_safe(self):
        data = {
            "www.a.com": {"qps": 100, "p95": 20},
            "api.a.com": {"qps": 100, "p95": 20, "p99": 100},
        }
        expobj = expand(data, safe=True)
        self.assertEqual(expobj['api.a.com\\.p95'], 20)
        self.assertEqual(expobj['api.a.com\\.p99'], 100)

        origin = restore(expobj, safe=True)
        self.assertEqual(origin, data)
예제 #4
0
    def test_complex(self):
        s = [{"s": 0}, {"t": ["2", {"x": "z"}]}, 0, "w", ["x", "g", 1]]
        exp = expand(s)
        _s = restore(exp)

        self.assertDictEqual(s[0], _s[0])
        self.assertDictEqual(s[1], _s[1])

        self.assertEqual(s[2], _s[2])
        self.assertEqual(s[3], _s[3])

        self.assertListEqual(s[4], _s[4])
예제 #5
0
    def test_dict(self):
        s = {
                "s": 1,
                "w": 5,
                "t": {
                    "m": 0,
                    "x": {
                        "y": "z"
                        }
                    }
            }

        exp = expand(s)
        _s = restore(exp)

        self.assertDictEqual(s, _s)
예제 #6
0
    def test_complex(self):
        s = [
                {"s": 0},
                {"t": ["2", {"x": "z"}]},
                0,
                "w",
                ["x", "g", 1]
            ]
        exp = expand(s)
        _s = restore(exp)

        self.assertDictEqual(s[0], _s[0])
        self.assertDictEqual(s[1], _s[1])

        self.assertEqual(s[2], _s[2])
        self.assertEqual(s[3], _s[3])

        self.assertListEqual(s[4], _s[4])
예제 #7
0
    def test_list(self):
        s = ["sss", "ttt", 1, 2, ["3"]]
        exp = expand(s)
        _s = restore(exp)

        self.assertListEqual(s, _s)
예제 #8
0
 def test_string(self):
     s = "sss"
     exp = expand(s)
     _s = restore(exp)
     self.assertEqual(s, _s)
예제 #9
0
    def test_list(self):
        s = ["sss", "ttt", 1, 2, ["3"]]
        exp = expand(s)
        _s = restore(exp)

        self.assertListEqual(s, _s)
예제 #10
0
 def test_string(self):
     s = "sss"
     exp = expand(s)
     _s = restore(exp)
     self.assertEqual(s, _s)