Exemple #1
0
 def test_node_from_path_integer_keys(self):
     root = TreeNode()
     child1 = TreeNode(key="foo", parent=root)
     child2 = TreeNode(value=333, key=0, parent=child1)
     child3 = TreeNode(value=333, key=1, parent=child1)
     child4 = TreeNode(value=333, key=2, parent=child1)
     correct_tree = {'foo': [333, 333, 333]}
     errors = object_hierarchy_equals(root.object_hierarchy(), correct_tree)
     self.assertEqual(len(errors), 0)
Exemple #2
0
    def test_object_hierarchy(self):
        root = TreeNode(value=111)
        child1 = TreeNode(key="foo", parent=root)
        child2 = TreeNode(value=111, key=0, parent=child1)
        child3 = TreeNode(value=222, key=1, parent=child1)
        child4 = TreeNode(key=2, parent=child1)

        child5 = TreeNode(key="bar", parent=child4)
        child6 = TreeNode(key="quux", parent=child5)
        child7 = TreeNode(value=333, key="quuz", parent=child6)

        correct_tree = {'foo': [111, 222, {'bar': {'quux': {'quuz': 333}}}]}

        errors = object_hierarchy_equals(root.object_hierarchy(), correct_tree)
        self.assertEqual(len(errors), 0)