def test_save_document_with_root_node(): '''Save a document with a root node.''' document = Document() node = Node('root') document.add(node) document.save() assert node.node_id == 1 assert node.parent_id is None
def test_save_document_with_child_node(): '''Save a document with a child node.''' document = Document() root = Node('root') child = Node('child', parent=root) document.add(root) document.save() assert root.parent is None assert child.parent is root assert root.node_id == 1 assert child.node_id == 2 assert root.parent_id is None assert child.parent_id == root.node_id
def test_remove_subtree_from_document(): '''Remove a subtree from the document.''' document = Document() root = Node('root') node = Node('node') root.children.append(node) document.add(root) document.save() assert root in document.roots assert node in root.children document.remove(root) document.save() assert root not in document.roots assert node in root.children