Exemplo n.º 1
0
 def test_from_list_multiple_roots(self):
     """Verify an error occurs when the tree has multiple roots."""
     a = MockDocumentSkip(EMPTY)
     a.prefix = 'A'
     b = MockDocumentSkip(EMPTY)
     b.prefix = 'B'
     docs = [a, b]
     self.assertRaises(DoorstopError, Tree.from_list, docs)
Exemplo n.º 2
0
    def test_place_no_parent(self):
        """Verify an error occurs when a node is missing a parent."""

        a = MockDocumentSkip(EMPTY)
        a.prefix = 'A'
        b = MockDocumentSkip(EMPTY)
        b.prefix = 'B'
        tree = Tree(a)
        self.assertRaises(DoorstopError, tree._place, b)  # pylint: disable=W0212
Exemplo n.º 3
0
 def test_palce_empty(self):
     """Verify a document can be placed in an empty tree."""
     tree = build(EMPTY)
     doc = MockDocumentSkip.new(tree, os.path.join(EMPTY, 'temp'), EMPTY,
                                'TEMP')
     tree._place(doc)  # pylint: disable=W0212
     self.assertEqual(1, len(tree))
Exemplo n.º 4
0
 def test_palce_empty_no_parent(self):
     """Verify a document with parent cannot be placed in an empty tree."""
     tree = build(EMPTY)
     doc = MockDocumentSkip.new(tree,
                                os.path.join(EMPTY, 'temp'), EMPTY, 'TEMP',
                                parent='REQ')
     self.assertRaises(DoorstopError, tree._place, doc)  # pylint: disable=W0212
Exemplo n.º 5
0
 def test_palce_empty(self):
     """Verify a document can be placed in an empty tree."""
     tree = build(EMPTY)
     doc = MockDocumentSkip.new(tree,
                                os.path.join(EMPTY, 'temp'), EMPTY, 'TEMP')
     tree._place(doc)  # pylint: disable=W0212
     self.assertEqual(1, len(tree))
Exemplo n.º 6
0
 def test_from_list_no_root(self):
     """Verify an error occurs when the tree has no root."""
     a = MockDocumentSkip(EMPTY)
     a.prefix = 'A'
     a.parent = 'B'
     b = MockDocumentSkip(EMPTY)
     b.prefix = 'B'
     b.parent = 'A'
     docs = [a, b]
     self.assertRaises(DoorstopError, Tree.from_list, docs)
Exemplo n.º 7
0
 def test_palce_empty_no_parent(self):
     """Verify a document with parent cannot be placed in an empty tree."""
     tree = build(EMPTY)
     doc = MockDocumentSkip.new(tree,
                                os.path.join(EMPTY, 'temp'),
                                EMPTY,
                                'TEMP',
                                parent='REQ')
     self.assertRaises(DoorstopError, tree._place, doc)  # pylint: disable=W0212
Exemplo n.º 8
0
    def test_from_list_missing_parent(self):
        """Verify an error occurs when a node has a missing parent."""

        a = MockDocumentSkip(EMPTY)
        a.prefix = 'A'
        b = MockDocumentSkip(EMPTY)
        b.prefix = 'B'
        b.parent = 'A'
        c = MockDocumentSkip(EMPTY)
        c.prefix = 'C'
        c.parent = '?'
        docs = [a, b, c]
        self.assertRaises(DoorstopError, Tree.from_list, docs)
Exemplo n.º 9
0
 def test_from_list(self):
     """Verify a tree can be created from a list."""
     a = MockDocumentSkip(EMPTY)
     a.prefix = 'A'
     b = MockDocumentSkip(EMPTY)
     b.prefix = 'B'
     b.parent = 'A'
     c = MockDocumentSkip(EMPTY)
     c.prefix = 'C'
     c.parent = 'B'
     docs = [a, b, c]
     tree = Tree.from_list(docs)
     self.assertEqual(3, len(tree))
     self.assertTrue(tree.validate())
Exemplo n.º 10
0
 def test_from_list_multiple_roots(self):
     """Verify an error occurs when the tree has multiple roots."""
     a = MockDocumentSkip(EMPTY)
     a.prefix = 'A'
     b = MockDocumentSkip(EMPTY)
     b.prefix = 'B'
     docs = [a, b]
     self.assertRaises(DoorstopError, Tree.from_list, docs)
Exemplo n.º 11
0
    def test_place_no_parent(self):
        """Verify an error occurs when a node is missing a parent."""

        a = MockDocumentSkip(EMPTY)
        a.prefix = 'A'
        b = MockDocumentSkip(EMPTY)
        b.prefix = 'B'
        tree = Tree(a)
        self.assertRaises(DoorstopError, tree._place, b)  # pylint: disable=W0212
Exemplo n.º 12
0
 def test_from_list_no_root(self):
     """Verify an error occurs when the tree has no root."""
     a = MockDocumentSkip(EMPTY)
     a.prefix = 'A'
     a.parent = 'B'
     b = MockDocumentSkip(EMPTY)
     b.prefix = 'B'
     b.parent = 'A'
     docs = [a, b]
     self.assertRaises(DoorstopError, Tree.from_list, docs)
Exemplo n.º 13
0
    def test_from_list_missing_parent(self):
        """Verify an error occurs when a node has a missing parent."""

        a = MockDocumentSkip(EMPTY)
        a.prefix = 'A'
        b = MockDocumentSkip(EMPTY)
        b.prefix = 'B'
        b.parent = 'A'
        c = MockDocumentSkip(EMPTY)
        c.prefix = 'C'
        c.parent = '?'
        docs = [a, b, c]
        self.assertRaises(DoorstopError, Tree.from_list, docs)
Exemplo n.º 14
0
 def test_from_list(self):
     """Verify a tree can be created from a list."""
     a = MockDocumentSkip(EMPTY)
     a.prefix = 'A'
     b = MockDocumentSkip(EMPTY)
     b.prefix = 'B'
     b.parent = 'A'
     c = MockDocumentSkip(EMPTY)
     c.prefix = 'C'
     c.parent = 'B'
     docs = [a, b, c]
     tree = Tree.from_list(docs)
     self.assertEqual(3, len(tree))
     self.assertTrue(tree.validate())