File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -76,6 +76,18 @@ def test_unicode(self):
7676 expobj = expand (data )
7777 assert expobj
7878
79+ def test_expand_with_safe (self ):
80+ data = {
81+ "www.a.com" :{"qps" :100 ,"p95" :20 },
82+ "api.a.com" :{"qps" :100 ,"p95" :20 ,"p99" :100 },
83+ }
84+ expobj = expand (data , safe = True )
85+ self .assertEqual (expobj ['api.a.com\\ .p95' ], 20 )
86+ self .assertEqual (expobj ['api.a.com\\ .p99' ], 100 )
87+
88+ origin = restore (expobj , safe = True )
89+ self .assertEqual (origin , data )
90+
7991
8092class TestConvertJSON (unittest .TestCase ):
8193
@@ -89,3 +101,14 @@ def test_convert_expand(self):
89101
90102 fin .close ()
91103 fout .close ()
104+
105+ def test_convert_restore (self ):
106+ fin = io .BytesIO ('{"a.b": 3}\n {"a.c": 4}\n ' )
107+ fout = io .BytesIO ()
108+
109+ convert_json (fin , fout , type = "restore" )
110+
111+ self .assertEqual ('{"a": {"b": 3}}\n {"a": {"c": 4}}\n ' , fout .getvalue ())
112+
113+ fin .close ()
114+ fout .close ()
You can’t perform that action at this time.
0 commit comments