Ejemplo n.º 1
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)
Ejemplo n.º 2
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)
Ejemplo n.º 3
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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
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())
Ejemplo n.º 6
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())