Пример #1
0
 def test_flatten_x(self):
     obj = {
         "client": {
             "heart_beat": "1s",
             "metric_enabled": True,
             "transport_kafka": {
                 "broker_list": [
                     "10.0.0.1:9092",
                     "10.0.0.2:9092"
                 ]
         },
         "groups": [
             {
                 "prefix:": "oletest", 
                 "collector_win_pdh": [
                     {"interval": "15s"}, 
                     {"interval": "30s"}
                 ]
             }, {
                 "prefix:": "xxxxx", 
                 "collector_win_pdh": [
                     {"interval": "15s", "queries":["q1", "q2", "q3"]}
                 ]
             }
         ]}
     }
     for x in xrange(self.size):
         dictdiff.flatten(obj)
Пример #2
0
 def test_flatten_4(self):
     obj = {'a':{'b':[{'c': [{'d':[{'e': 1, 'f': 2}]}]}]}}
     fobj = dictdiff.flatten(obj)
     # print fobj
     self.assertEqual(len(fobj), 2)
     self.assertEqual(fobj['a.b.[0].c.[0].d.[0].e'], 1)
     self.assertEqual(fobj['a.b.[0].c.[0].d.[0].f'], 2)
Пример #3
0
    def test_flatten_2(self):
        obj = {'a': {'b': 1}}
        fobj = dictdiff.flatten(obj)
        self.assertEqual(len(fobj), 1)
        self.assertEqual(fobj.keys()[0], 'a.b')
        self.assertEqual(fobj['a.b'], 1)

        obj = {'a': {'b': 1, 'c':2}}
        fobj = dictdiff.flatten(obj)
        self.assertEqual(len(fobj), 2)
        self.assertEqual(fobj['a.c'], 2)

        obj = {'a': {'b': 1}, 'b': 2}
        fobj = dictdiff.flatten(obj)
        self.assertEqual(len(fobj), 2)
        self.assertEqual(fobj['a.b'], 1)
        self.assertEqual(fobj['b'], 2)
Пример #4
0
 def test_flatten_dot_key(self):
     obj = {'a.b.c': 1, 'a': {'b':{'c': 2}}}
     fobj = dictdiff.flatten(obj)
     self.assertEqual(len(fobj), 2)
     self.assertEqual(fobj.get('a\.b\.c'), 1)
     self.assertEqual(fobj.get('a.b.c'), 2)
Пример #5
0
 def test_flatten_5(self):
     obj = ['a', 1]
     fobj = dictdiff.flatten(obj)
     # print fobj
     self.assertEqual(fobj, {})
Пример #6
0
 def test_flatten_3(self):
     obj = {'a': ['b',1]}
     fobj = dictdiff.flatten(obj)
     self.assertEqual(len(fobj), 2)
     self.assertEqual(fobj['a.[0]'],'b')
     self.assertEqual(fobj['a.[1]'], 1)
Пример #7
0
 def test_flatten_2(self):
     obj = {'a':{'b':[{'c': [{'d':[{'e': 1, 'f': 2}]}]}]}}
     for x in xrange(self.size):
         dictdiff.flatten(obj)
Пример #8
0
 def test_flatten_1(self):
     obj = {'a': 1}
     for x in xrange(self.size):
         dictdiff.flatten(obj)
Пример #9
0
 def test_flatten_1(self):
     obj = {'a': 1}
     fobj = dictdiff.flatten(obj)
     self.assertEqual(len(fobj), 1)
     self.assertEqual(fobj['a'], 1)