Пример #1
0
 def test_reuse_document_identifier(self):
     context = Context()
     context.create_document(1, 'first.txt', 'txt', '/tmp/first.txt')
     context.destroy_document(1)
     context.create_document(1, 'other.dat', 'data', '/tmp/other.dat')
     document = context.get_document(1)
     self.assertEqual(document.id, 1)
     self.assertEqual(document.name, 'other.dat')
     self.assertEqual(document.type, 'data')
     self.assertEqual(document.path, '/tmp/other.dat')
Пример #2
0
 def test_remove_relations_with_document(self):
     context = Context()
     context.create_document(1, 'python.pdf', 'pdf', '/tmp/python.pdf')
     context.create_document(2, 'rust.pdf', 'pdf', '/tmp/rust.pdf')
     context.create_document(3, 'lua.pdf', 'pdf', '/tmp/lua.pdf')
     context.create_tag(1, 'book')
     context.create_relation(1, 1)
     context.create_relation(2, 1)
     context.create_relation(3, 1)
     context.destroy_document(1)
     self.assertEqual(context.count_relations(), 2)
     context.destroy_document(3)
     self.assertEqual(context.count_relations(), 1)
     context.destroy_document(2)
     self.assertEqual(context.count_relations(), 0)
Пример #3
0
 def test_document_counting(self):
     context = Context()
     self.assertEqual(context.count_documents(), 0)
     context.create_document(1, 'first.txt', 'txt', '/tmp/first.txt')
     self.assertEqual(context.count_documents(), 1)
     context.create_document(2, 'second.csv', 'csv', '/tmp/second.csv')
     self.assertEqual(context.count_documents(), 2)
     context.create_document(3, 'other.dat', 'data', '/tmp/other.dat')
     self.assertEqual(context.count_documents(), 3)
     context.destroy_document(3)
     self.assertEqual(context.count_documents(), 2)
     context.destroy_document(1)
     self.assertEqual(context.count_documents(), 1)
     context.destroy_document(2)
     self.assertEqual(context.count_documents(), 0)
Пример #4
0
 def test_remove_missing_document(self):
     context = Context()
     context.create_document(1, 'first.txt', 'txt', '/tmp/first.txt')
     with self.assertRaises(ValueError):
         context.destroy_document(2)