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)
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)
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
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
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)
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)
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)
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)
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())
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())