Exemplo n.º 1
0
 def test_retrieve_value_traverse_down(self):
     v = VyattaJSONParser({}, {})
     node = {'protocols': {'ospf': {'timers': "timerVal"}}}
     steps = ['protocols', 'ospf', 'timers', TEXT_LEAF_LABEL]
     actual = v.retrieve_value(node, steps)
     expected = "timerVal"
     self.assertEqual(actual, expected)
Exemplo n.º 2
0
 def test_retreive_multi_OrderedDict_from_list(self):
     v = VyattaJSONParser({}, {})
     node = OrderedDict(
         [('protocols', [OrderedDict([('ospf', OrderedDict([('timers', 'timerVal')]))])])])
     steps = ['protocols', DICT_ELEM_LABEL]
     actual = v.retrieve_value(node, steps)
     print(actual)
     expected = "[{'ospf':{'timers':'timerVal'}}]"
     self.assertEqual(actual, expected)
Exemplo n.º 3
0
 def test_retrieve_value_traverse_up_simple(self):
     v = VyattaJSONParser({}, {})
     l3 = {'timers': "timerVal"}
     l2 = {'ospf': l3}
     node = {'protocols': l2, 'key': 'value'}
     v.parent_stack = [node, l2]
     steps = [DIR_TRAVERSE_UP_LABEL,
              DIR_TRAVERSE_UP_LABEL, 'key', TEXT_LEAF_LABEL]
     actual = v.retrieve_value(l3, steps)
     expected = "value"
     self.assertEqual(actual, expected)