Beispiel #1
0
 def test_find_document(self):
     """Verify documents can be found using a convenience function."""
     # Cache miss
     document = core.find_document('req')
     self.assertIsNot(None, document)
     # Cache hit
     document2 = core.find_document('req')
     self.assertIs(document2, document)
Beispiel #2
0
 def test_find_document(self):
     """Verify documents can be found using a convenience function."""
     # Cache miss
     document = core.find_document('req')
     self.assertIsNot(None, document)
     # Cache hit
     document2 = core.find_document('req')
     self.assertIs(document2, document)
Beispiel #3
0
 def test_create_document_with_unknown_parent(self):
     """Verify a new document can be created with an unknown parent."""
     # Verify the document does not already exist
     self.assertRaises(DoorstopError, core.find_document, self.prefix)
     # Import a document
     document = core.importer.create_document(self.prefix, self.path,
                                              parent=self.parent)
     # Verify the imported document's attributes are correct
     self.assertEqual(self.prefix, document.prefix)
     self.assertEqual(self.path, document.path)
     self.assertEqual(self.parent, document.parent)
     # Verify the imported document can be found
     document2 = core.find_document(self.prefix)
     self.assertIs(document, document2)
Beispiel #4
0
 def test_create_document_with_unknown_parent(self):
     """Verify a new document can be created with an unknown parent."""
     # Verify the document does not already exist
     self.assertRaises(DoorstopError, core.find_document, self.prefix)
     # Import a document
     document = core.importer.create_document(self.prefix, self.path,
                                              parent=self.parent)
     # Verify the imported document's attributes are correct
     self.assertEqual(self.prefix, document.prefix)
     self.assertEqual(self.path, document.path)
     self.assertEqual(self.parent, document.parent)
     # Verify the imported document can be found
     document2 = core.find_document(self.prefix)
     self.assertIs(document, document2)
Beispiel #5
0
 def test_add_item(self):
     """Verify an item can be imported into a document."""
     # Create a document
     core.importer.create_document(self.prefix, self.path)
     # Verify the item does not already exist
     self.assertRaises(DoorstopError, core.find_item, self.uid)
     # Import an item
     item = core.importer.add_item(self.prefix, self.uid)
     # Verify the item's attributes are correct
     self.assertEqual(self.uid, item.uid)
     # Verify the item can be found
     item2 = core.find_item(self.uid)
     self.assertIs(item, item2)
     # Verify the item is contained in the document
     document = core.find_document(self.prefix)
     self.assertIn(item, document.items)
Beispiel #6
0
 def test_add_item(self):
     """Verify an item can be imported into a document."""
     # Create a document
     core.importer.create_document(self.prefix, self.path)
     # Verify the item does not already exist
     self.assertRaises(DoorstopError, core.find_item, self.uid)
     # Import an item
     item = core.importer.add_item(self.prefix, self.uid)
     # Verify the item's attributes are correct
     self.assertEqual(self.uid, item.uid)
     # Verify the item can be found
     item2 = core.find_item(self.uid)
     self.assertIs(item, item2)
     # Verify the item is contained in the document
     document = core.find_document(self.prefix)
     self.assertIn(item, document.items)