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)
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)
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)
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])
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)
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])
def test_list(self): s = ["sss", "ttt", 1, 2, ["3"]] exp = expand(s) _s = restore(exp) self.assertListEqual(s, _s)
def test_string(self): s = "sss" exp = expand(s) _s = restore(exp) self.assertEqual(s, _s)
def test_list(self): s = ["sss", "ttt", 1, 2, ["3"]] exp = expand(s) _s = restore(exp) self.assertListEqual(s, _s)
def test_string(self): s = "sss" exp = expand(s) _s = restore(exp) self.assertEqual(s, _s)