Пример #1
0
    def test_insert_children_default_fail_tuple(self):
        '''Validate failure of insert of tuple of children with bad element'''
        # Create tuple
        new_do_list = (SimpleDataObject("child_1"),
                       SimpleDataObject("child_2"),
                       SimpleDataObject("child_3"),
                       SimpleDataObject("child_4"), object())

        self.assertRaises(TypeError, self.data_obj.insert_children,
                          new_do_list)
Пример #2
0
    def test_insert_children_default_fail_list(self):
        '''Validate failure of insert of list of children with bad element'''
        new_do_list = list()
        new_do_list.append(SimpleDataObject("child_1"))
        new_do_list.append(SimpleDataObject("child_2"))
        new_do_list.append(SimpleDataObject("child_3"))
        new_do_list.append(SimpleDataObject("child_4"))
        new_do_list.append(object())

        self.assertRaises(TypeError, self.data_obj.insert_children,
                          new_do_list)
Пример #3
0
    def test_insert_children_after_list(self):
        '''Validate insertion of children list with after value'''
        # Populate existing children first.
        new_do_list = list()
        new_do_list.append(SimpleDataObject("child_1"))
        new_do_list.append(SimpleDataObject("child_2"))
        child_3 = SimpleDataObject("child_3")
        new_do_list.append(child_3)
        new_do_list.append(SimpleDataObject("child_4"))
        new_do_list.append(SimpleDataObject("child_5"))

        self.data_obj.insert_children(new_do_list)

        #Now for the real test, to insert something after child_3
        to_insert = list()
        to_insert.append(SimpleDataObject("after_child_3 - A"))
        to_insert.append(SimpleDataObject("after_child_3 - B"))
        to_insert.append(SimpleDataObject("after_child_3 - C"))

        self.data_obj.insert_children(to_insert, after=child_3)

        i = 0
        j = 0
        for child in self.data_obj.children:
            if i >= 3:
                self.assertEqual(
                    child, to_insert[j],
                    "child = %s ; compared_to = %s" % (child, to_insert[j]))
                j += 1
                if j >= len(to_insert):
                    break
            i += 1
Пример #4
0
    def test_insert_children_after_last_list(self):
        '''Validate insertion of children list with after == last child'''
        # Populate existing children first.
        new_do_list = list()
        new_do_list.append(SimpleDataObject("child_2"))
        new_do_list.append(SimpleDataObject("child_3"))
        new_do_list.append(SimpleDataObject("child_4"))
        new_do_list.append(SimpleDataObject("child_5"))
        child_5 = SimpleDataObject("child_5")
        new_do_list.append(child_5)

        self.data_obj.insert_children(new_do_list)

        #Now for the real test, to insert something after child_5
        to_insert = list()
        to_insert.append(SimpleDataObject("after_child_3 - A"))
        to_insert.append(SimpleDataObject("after_child_3 - B"))
        to_insert.append(SimpleDataObject("after_child_3 - C"))

        self.data_obj.insert_children(to_insert, after=child_5)

        children = self.data_obj.children
        num_children = len(children)
        offset = num_children - len(to_insert)
        for i in range(len(to_insert)):
            self.assertEqual(
                children[offset + i], to_insert[i],
                "child = %s ; compared_to = %s" %
                (children[offset + i], to_insert[i]))
Пример #5
0
    def test_insert_children_before_first_list(self):
        '''Validate insertion of children with before == first child'''
        # Populate existing children first.
        new_do_list = list()
        child_1 = SimpleDataObject("child_1")
        new_do_list.append(child_1)
        new_do_list.append(SimpleDataObject("child_2"))
        new_do_list.append(SimpleDataObject("child_3"))
        new_do_list.append(SimpleDataObject("child_4"))
        new_do_list.append(SimpleDataObject("child_5"))

        self.data_obj.insert_children(new_do_list)

        #Now for the real test, to insert something before child_1
        to_insert = list()
        to_insert.append(SimpleDataObject("before_child_1 - A"))
        to_insert.append(SimpleDataObject("before_child_1 - B"))
        to_insert.append(SimpleDataObject("before_child_1 - C"))

        self.data_obj.insert_children(to_insert, before=child_1)

        i = 0
        for child in self.data_obj.children:
            self.assertEqual(
                child, to_insert[i],
                "child = %s ; compared_to = %s" % (child, to_insert[i]))
            i += 1
            if not (i < len(to_insert)):
                break
Пример #6
0
    def test_insert_children_default_list(self):
        '''Validate insert of list of children'''
        new_do_list = list()
        new_do_list.append(SimpleDataObject("child_1"))
        new_do_list.append(SimpleDataObject("child_2"))
        new_do_list.append(SimpleDataObject("child_3"))
        new_do_list.append(SimpleDataObject("child_4"))
        new_do_list.append(SimpleDataObject("child_5"))

        self.data_obj.insert_children(new_do_list)
        i = 0
        for child in self.data_obj.children:
            self.assertEqual(child, new_do_list[i])
            i += 1
        self.assertEqual(i, len(new_do_list))
Пример #7
0
 def test_data_object_cache_children_insertion(self):
     '''Validate that DOC doesn't allow insertion of direct children'''
     simple = SimpleDataObject("Test Child")
     try:
         self.doc.insert_children(simple)
         self.fail("Managed to insert child when expected exception")
     except AttributeError:
         pass
    def test_data_object_delete_by_children_not_exist_tuple(self):
        '''Validate deletion of a tuple containing non-existant ref'''
        not_a_child_list = (self.child_5, SimpleDataObject("Not A Child 1"))

        self.assertRaises(ObjectNotFoundError,
                          self.data_obj.delete_children,
                          not_a_child_list,
                          not_found_is_err=True)
    def test_data_object_delete_by_children_not_exist_list(self):
        '''Validate failure when deleting a list of non-existant children'''
        not_a_child_list = [self.child_5, SimpleDataObject("Not A Child 1")]

        self.assertRaises(ObjectNotFoundError,
                          self.data_obj.delete_children,
                          not_a_child_list,
                          not_found_is_err=True)
    def test_data_object_delete_by_children_not_exist_single(self):
        '''Validate failure if asked to delete non-existant child reference'''
        not_a_child = SimpleDataObject("Not A Child 1")

        self.assertRaises(ObjectNotFoundError,
                          self.data_obj.delete_children,
                          not_a_child,
                          not_found_is_err=True)
Пример #11
0
    def test_doc_registration_simple_data_object(self):
        '''Validate registration and selection of a single class'''
        try:
            DataObjectCache.register_class(SimpleDataObject)
        except (TypeError, ValueError):
            self.fail("Failed to register SimpleDataObject!")

        # Test that it's actually registered and will correclty return class.
        simple = SimpleDataObject("TestSimple")
        xml_elem = simple.to_xml()
        class_obj = DataObjectCache.find_class_to_handle(xml_elem)
        self.assertEqual(class_obj, SimpleDataObject, str(class_obj))
    def setUp(self):
        '''Create simple tree and references to children'''
        # Create root node
        self.data_obj = SimpleDataObject("root")
        # Add some children
        self.child_1 = SimpleDataObject2("child_1")
        self.child_2 = SimpleDataObject("child_2")
        self.child_3 = SimpleDataObject("child_3")
        self.child_4 = SimpleDataObject2("child_4")
        self.child_5 = SimpleDataObject("child_5")

        # Add a child to child_2
        self.child_2_1 = SimpleDataObject("child_2_1")
        self.child_2.insert_children(self.child_2_1)

        self.do_list = list()
        self.do_list.append(self.child_1)
        self.do_list.append(self.child_2)
        self.do_list.append(self.child_3)
        self.do_list.append(self.child_4)
        self.do_list.append(self.child_5)

        self.data_obj.insert_children(self.do_list)
    def setUp(self):
        '''Create small set of objects and references to them'''
        self.doc = DataObjectCache()
        self.persistent_child_1 = SimpleDataObject("persistent_child_1")
        self.persistent_child_2 = SimpleDataObject("persistent_child_2")
        self.persistent_child_3 = SimpleDataObject("persistent_child_3")
        self.doc.persistent.insert_children([self.persistent_child_1,
            self.persistent_child_2, self.persistent_child_3])

        self.volatile_child_1 = SimpleDataObject("volatile_child_1")
        self.volatile_child_2 = SimpleDataObject("volatile_child_2")
        self.volatile_child_3 = SimpleDataObject("volatile_child_3")
        self.doc.volatile.insert_children([self.volatile_child_1,
            self.volatile_child_2, self.volatile_child_3])
Пример #14
0
    def test_insert_children_after_doesnt_exist(self):
        '''Validate failure on insertion with non-existant 'after' obj'''
        # Populate existing children first.
        new_do_list = list()
        new_do_list.append(SimpleDataObject("child_1"))
        new_do_list.append(SimpleDataObject("child_2"))
        new_do_list.append(SimpleDataObject("child_3"))
        new_do_list.append(SimpleDataObject("child_4"))
        new_do_list.append(SimpleDataObject("child_5"))

        self.data_obj.insert_children(new_do_list)

        not_in_list = SimpleDataObject("child_not_in_list")

        new_do = SimpleDataObject("after_child_3")
        #Now for the real test, to insert something after non-existant child
        self.assertRaises(ObjectNotFoundError,
                          self.data_obj.insert_children,
                          new_do,
                          after=not_in_list)
Пример #15
0
    def test_insert_children_before_first_single(self):
        '''Validate insertion of child with before == first child'''
        # Populate existing children first.
        new_do_list = list()
        child_1 = SimpleDataObject("child_1")
        new_do_list.append(child_1)
        new_do_list.append(SimpleDataObject("child_2"))
        new_do_list.append(SimpleDataObject("child_3"))
        new_do_list.append(SimpleDataObject("child_4"))
        new_do_list.append(SimpleDataObject("child_5"))

        self.data_obj.insert_children(new_do_list)

        #Now for the real test, to insert something before child_1
        new_do = SimpleDataObject("before_child_1")
        self.data_obj.insert_children(new_do, before=child_1)

        self.assertEqual(self.data_obj.children[0], new_do, str(self.data_obj))
Пример #16
0
    def test_insert_children_after_last_single(self):
        '''Validate insertion of children with after == last child'''
        # Populate existing children first.
        new_do_list = list()
        new_do_list.append(SimpleDataObject("child_2"))
        new_do_list.append(SimpleDataObject("child_3"))
        new_do_list.append(SimpleDataObject("child_4"))
        new_do_list.append(SimpleDataObject("child_5"))
        child_5 = SimpleDataObject("child_5")
        new_do_list.append(child_5)

        self.data_obj.insert_children(new_do_list)

        #Now for the real test, to insert something after child_5
        new_do = SimpleDataObject("after_child_5")
        self.data_obj.insert_children(new_do, after=child_5)

        children = self.data_obj.children
        self.assertEqual(children[len(children) - 1], new_do,
                         str(self.data_obj))
Пример #17
0
    def test_insert_children_after_single(self):
        '''Validate insertion of children with after value'''
        # Populate existing children first.
        new_do_list = list()
        new_do_list.append(SimpleDataObject("child_1"))
        new_do_list.append(SimpleDataObject("child_2"))
        child_3 = SimpleDataObject("child_3")
        new_do_list.append(child_3)
        new_do_list.append(SimpleDataObject("child_4"))
        new_do_list.append(SimpleDataObject("child_5"))

        self.data_obj.insert_children(new_do_list)

        #Now for the real test, to insert something before child_3
        new_do = SimpleDataObject("after_child_5")
        self.data_obj.insert_children(new_do, after=child_3)

        i = 0
        for child in self.data_obj.children:
            if i == 3:
                self.assertEqual(child, new_do, str(self.data_obj))
                break
            i += 1
    def setUp(self):
        '''Create an XML tree for testing and references to them.

        The tree will look like the following:

            root
                child_1
                    child_1_1
                    child_1_2
                child_2
                    child_2_1
                        child_2_1_1
                            child_2_1_1_1
                            child_2_1_1_2
                child_3
                    child_3_1
                        child_3_1_2
                        child_3_1_2
                        child_3_1_2_same_name
                child_4
                child_5
                    child_5_1
                    child_5_2
                        child_5_2_1
                        child_5_2_2
                        child_5_2_3
                            child_5_2_3_1
                            child_5_2_3_2
                            child_5_2_3_3
                            child_5_2_3_3_same_name
                child_5_same_name
        '''

        # Create root node
        self.data_obj = SimpleDataObject("root")
        # Add some children, used by most tests.
        self.child_1 = SimpleDataObject2("child_1")
        self.child_2 = SimpleDataObject("child_2")
        self.child_3 = SimpleDataObject("child_3")
        self.child_4 = SimpleDataObject2("child_4")
        self.child_5 = SimpleDataObject3("child_5")

        self.do_list = list()
        self.do_list.append(self.child_1)
        self.do_list.append(self.child_2)
        self.do_list.append(self.child_3)
        self.do_list.append(self.child_4)
        self.do_list.append(self.child_5)

        self.data_obj.insert_children(self.do_list)

        # Now let's add the children of children, etc. for use by
        # get_descendants() tests.
        # child_1 children
        self.child_1_1 = SimpleDataObject("child_1_1")
        self.child_1_2 = SimpleDataObject("child_1_2")
        self.child_1.insert_children([self.child_1_1, self.child_1_2])

        # child_2 tree
        self.child_2_1 = SimpleDataObject2("child_2_1")
        self.child_2.insert_children(self.child_2_1)
        self.child_2_1_1 = SimpleDataObject2("child_2_1_1")
        self.child_2_1.insert_children(self.child_2_1_1)
        self.child_2_1_1_1 = SimpleDataObject2("child_2_1_1_1")
        self.child_2_1_1_2 = SimpleDataObject2("child_2_1_1_2")
        self.child_2_1_1.insert_children(
            [self.child_2_1_1_1, self.child_2_1_1_2])

        # child_3 tree
        self.child_3_1 = SimpleDataObject("child_3_1")
        self.child_3.insert_children(self.child_3_1)
        self.child_3_1_1 = SimpleDataObject("child_3_1_1")
        self.child_3_1_2 = SimpleDataObject("child_3_1_2")
        self.child_3_1_2_same_name = SimpleDataObject("child_3_1_2")
        self.child_3_1.insert_children(
            [self.child_3_1_1, self.child_3_1_2, self.child_3_1_2_same_name])

        # child_5 tree
        self.child_5_1 = SimpleDataObject("child_5_1")
        self.child_5_2 = SimpleDataObject("child_5_2")
        self.child_5.insert_children([self.child_5_1, self.child_5_2])
        self.child_5_2_1 = SimpleDataObject("child_5_2_1")
        self.child_5_2_2 = SimpleDataObject("child_5_2_2")
        self.child_5_2_3 = SimpleDataObjectHandlesChildren("child_5_2_3")
        self.child_5_2.insert_children(
            [self.child_5_2_1, self.child_5_2_2, self.child_5_2_3])

        self.child_5_2_3_1 = SimpleDataObject("child_5_2_3_1")
        self.child_5_2_3_2 = SimpleDataObject("child_5_2_3_2")
        self.child_5_2_3_3 = SimpleDataObject("child_5_2_3_3")
        self.child_5_2_3_3_same_name = SimpleDataObject("child_5_2_3_3")
        self.child_5_2_3.insert_children([
            self.child_5_2_3_1, self.child_5_2_3_2, self.child_5_2_3_3,
            self.child_5_2_3_3_same_name
        ])
 def test_data_object_dict_can_insert_to_doc(self):
     '''Validate DataObjectDict can be inserted as child of DataObject'''
     data_obj = SimpleDataObject("test_obj")
     data_dict = {'key1': 'value1', 'key2': 'value2'}
     data_dict_obj = DataObjectDict("TestChild", data_dict)
     data_obj.insert_children(data_dict_obj)
Пример #20
0
    def test_insert_children_default_fail_both_before_and_after(self):
        '''Validate failure on insert with invalid before and after'''
        new_do = SimpleDataObject("child_1")

        self.assertRaises(ValueError, self.data_obj.insert_children, new_do,
                          new_do, new_do)
Пример #21
0
    def test_insert_children_default_single(self):
        '''Validate insertion of single child'''
        new_do = SimpleDataObject("child_1")

        self.data_obj.insert_children(new_do)
        self.assertEqual(self.data_obj.children[0], new_do)
Пример #22
0
 def setUp(self):
     '''Create simple data object reference'''
     self.data_obj = SimpleDataObject("root")
 def test_data_object_simple_can_insert_to_doc(self):
     '''Validate SimpleXmlHandlerBase can be inserted as child of DataObject
     '''
     data_obj = SimpleDataObject("test_obj")
     data_obj.insert_children(SimpleXmlHandlerTag("test"))
Пример #24
0
    def setUp(self):
        '''Create DOC, and empty registry of classes, some children and refs'''

        # Hack to ensure that registry is empty before we use it,
        self.orig_registry = DOC._CACHE_CLASS_REGISTRY
        DOC._CACHE_CLASS_REGISTRY = dict()

        DataObjectCache.register_class([SimpleDataObject, SimpleDataObject2,
                SimpleDataObject3, SimpleDataObjectHandlesChildren])

        # Create a tree that looks like:
        #
        #    root
        #        child_1
        #            child_1_1
        #            child_1_2
        #        child_2
        #            child_2_1
        #                child_2_1_1
        #                    child_2_1_1_1
        #                    child_2_1_1_2
        #        child_3
        #            child_3_1
        #                child_3_1_2
        #                child_3_1_2
        #        child_4
        #        child_5
        #            child_5_1
        #            child_5_2
        #                child_5_2_1
        #                child_5_2_2
        #                child_5_2_3
        #                    child_5_2_3_1
        #                    child_5_2_3_2
        #                    child_5_2_3_3
        #        child_5_same_name

        # Create root node
        self.doc = DataObjectCache()

        # Create some persistent content
        self.persistent_root = SimpleDataObject("persistent_root")

        # Add some children, used by most tests.
        self.child_1 = SimpleDataObject2("child_1")
        self.child_2 = SimpleDataObject("child_2")
        self.child_3 = SimpleDataObject("child_3")
        self.child_4 = SimpleDataObject2("child_4")
        self.child_5 = SimpleDataObject3("child_5")

        self.do_list = list()
        self.do_list.append(self.child_1)
        self.do_list.append(self.child_2)
        self.do_list.append(self.child_3)
        self.do_list.append(self.child_4)
        self.do_list.append(self.child_5)

        self.persistent_root.insert_children(self.do_list)

        self.doc.persistent.insert_children(self.persistent_root)

       # Now let's add the children of children, etc. for use by
        # get_descendants() tests.
        # child_1 children
        self.child_1_1 = SimpleDataObject("child_1_1")
        self.child_1_2 = SimpleDataObject("child_1_2")
        self.child_1.insert_children([self.child_1_1, self.child_1_2])

        # child_2 tree
        self.child_2_1 = SimpleDataObject2("child_2_1")
        self.child_2.insert_children(self.child_2_1)
        self.child_2_1_1 = SimpleDataObject2("child_2_1_1")
        self.child_2_1.insert_children(self.child_2_1_1)
        self.child_2_1_1_1 = SimpleDataObject2("child_2_1_1_1")
        self.child_2_1_1_2 = SimpleDataObject2("child_2_1_1_2")
        self.child_2_1_1.insert_children([self.child_2_1_1_1,
            self.child_2_1_1_2])

        # child_3 tree
        self.child_3_1 = SimpleDataObject("child_3_1")
        self.child_3.insert_children(self.child_3_1)
        self.child_3_1_1 = SimpleDataObject("child_3_1_1")
        self.child_3_1_2 = SimpleDataObject("child_3_1_2")
        self.child_3_1_2_same_name = SimpleDataObject("child_3_1_2")
        self.child_3_1.insert_children([self.child_3_1_1, self.child_3_1_2,
        self.child_3_1_2_same_name])

        # child_5 tree
        self.child_5_1 = SimpleDataObject("child_5_1")
        self.child_5_2 = SimpleDataObject("child_5_2")
        self.child_5.insert_children([self.child_5_1, self.child_5_2])
        self.child_5_2_1 = SimpleDataObject("child_5_2_1")
        self.child_5_2_2 = SimpleDataObject("child_5_2_2")
        self.child_5_2_3 = SimpleDataObjectHandlesChildren("child_5_2_3")
        self.child_5_2.insert_children([self.child_5_2_1, self.child_5_2_2,
            self.child_5_2_3])

        self.child_5_2_3_1 = SimpleDataObject("child_5_2_3_1")
        self.child_5_2_3_2 = SimpleDataObject("child_5_2_3_2")
        self.child_5_2_3_3 = SimpleDataObject("child_5_2_3_3")
        self.child_5_2_3_3_same_name = SimpleDataObject("child_5_2_3_3")
        self.child_5_2_3.insert_children([self.child_5_2_3_1,
            self.child_5_2_3_2, self.child_5_2_3_3,
            self.child_5_2_3_3_same_name])

        # Create some volatile content, not much, just enough to test that it's
        # not overwritten on loading of snapshot.
        self.volatile_root = SimpleDataObject2("volatile_root")
        self.doc.volatile.insert_children(self.volatile_root)
    def setUp(self):
        '''Set up correct environment for tests.

        Creates reference to a temp dir and file and StringIO buffer.

        Creates a tree of elements in the DOC to validate before/after.
        '''

        # Create temporary work directory
        self.temp_dir = mkdtemp(prefix="doc_test-")
        self.temp_file = mktemp(prefix="snapshot-", dir=self.temp_dir)

        # Create StringIO memory buffer for I/O test
        self.buffer = StringIO()

        # Create a tree that looks like:
        #  DOC
        #    volatile
        #      volatile_root
        #    persistent
        #      persistent_root
        #        child_1
        #            child_1_1
        #            child_1_2
        #        child_2
        #            child_2_1
        #                child_2_1_1
        #                    child_2_1_1_1
        #                    child_2_1_1_2
        #        child_3
        #            child_3_1
        #                child_3_1_2
        #                child_3_1_2
        #                child_3_1_2_same_name
        #        child_4
        #        child_5
        #            child_5_1
        #            child_5_2
        #                child_5_2_1
        #                child_5_2_2
        #                child_5_2_3
        #                    child_5_2_3_1
        #                    child_5_2_3_2
        #                    child_5_2_3_3
        #                    child_5_2_3_3_same_name
        #        child_5_same_name

        # Create DOC node
        self.doc = DataObjectCache()

        # Create some persistent content
        self.persistent_root = SimpleDataObject("persistent_root")
        # Add some children, used by most tests.
        self.child_1 = SimpleDataObject2("child_1")
        self.child_2 = SimpleDataObject("child_2")
        self.child_3 = SimpleDataObject("child_3")
        self.child_4 = SimpleDataObject2("child_4")
        self.child_5 = SimpleDataObject3("child_5")
        self.child_5_same_name = SimpleDataObject("child_5")

        self.do_list = list()
        self.do_list.append(self.child_1)
        self.do_list.append(self.child_2)
        self.do_list.append(self.child_3)
        self.do_list.append(self.child_4)
        self.do_list.append(self.child_5)
        self.do_list.append(self.child_5_same_name)

        self.persistent_root.insert_children(self.do_list)

        self.doc.persistent.insert_children(self.persistent_root)

        # Now let's add the children of children, etc. for use by
        # get_descendants() tests.
        # child_1 children
        self.child_1_1 = SimpleDataObject("child_1_1")
        self.child_1_2 = SimpleDataObject("child_1_2")
        self.child_1.insert_children([self.child_1_1, self.child_1_2])

        # child_2 tree
        self.child_2_1 = SimpleDataObject2("child_2_1")
        self.child_2.insert_children(self.child_2_1)
        self.child_2_1_1 = SimpleDataObject2("child_2_1_1")
        self.child_2_1.insert_children(self.child_2_1_1)
        self.child_2_1_1_1 = SimpleDataObject2("child_2_1_1_1")
        self.child_2_1_1_2 = SimpleDataObject2("child_2_1_1_2")
        self.child_2_1_1.insert_children(
            [self.child_2_1_1_1, self.child_2_1_1_2])

        # child_3 tree
        self.child_3_1 = SimpleDataObject("child_3_1")
        self.child_3.insert_children(self.child_3_1)
        self.child_3_1_1 = SimpleDataObject("child_3_1_1")
        self.child_3_1_2 = SimpleDataObject("child_3_1_2")
        self.child_3_1_2_same_name = SimpleDataObject("child_3_1_2")
        self.child_3_1.insert_children(
            [self.child_3_1_1, self.child_3_1_2, self.child_3_1_2_same_name])

        # child_5 tree
        self.child_5_1 = SimpleDataObject("child_5_1")
        self.child_5_2 = SimpleDataObject("child_5_2")
        self.child_5.insert_children([self.child_5_1, self.child_5_2])
        self.child_5_2_1 = SimpleDataObject("child_5_2_1")
        self.child_5_2_2 = SimpleDataObject("child_5_2_2")
        self.child_5_2_3 = SimpleDataObject4("child_5_2_3")
        self.child_5_2.insert_children(
            [self.child_5_2_1, self.child_5_2_2, self.child_5_2_3])

        self.child_5_2_3_1 = SimpleDataObject("child_5_2_3_1")
        self.child_5_2_3_2 = SimpleDataObject("child_5_2_3_2")
        self.child_5_2_3_3 = SimpleDataObject("child_5_2_3_3")
        self.child_5_2_3_3_same_name = SimpleDataObject("child_5_2_3_3")
        self.child_5_2_3.insert_children([
            self.child_5_2_3_1, self.child_5_2_3_2, self.child_5_2_3_3,
            self.child_5_2_3_3_same_name
        ])

        # Create some volatile content, not much, just enough to test that it's
        # not overwritten on loading of snapshot.
        self.volatile_root = SimpleDataObject2("volatile_root")
        self.doc.volatile.insert_children(self.volatile_root)