def test_hashing(self): doc1 = Document() doc2 = Document() doc1.description = None doc2.description = None test_map = {} test_map[doc1] = "eins" test_map[doc2] = "zwei" self.assertEqual(test_map[doc2], "zwei")
def testNoOverwriting(self): description ='Stadtzeitung vom 23.4.1975. Irgend ein Text' flyer_doc_type = DocumentType(2) flyer_doc_type.description = "Flyer" entity = Document(4711) entity.document_type = flyer_doc_type entity.description = description entity = self.post_processor.run(entity) self.assertTrue(entity.document_type != None) self.assertEqual('Flyer', entity.document_type.description)
def testJournalArticle(self): descriptions = ('Stadtzeitung vom 23.4.1975. Irgend ein Text', 'Stadtzeitung vom 23. April 1975. Irgend ein Text', 'B.Z., 3. April 2014: Noch ein Text') for description in descriptions: with self.subTest(description=description): entity = Document(4711) entity.description = description entity = self.post_processor.run(entity) self.assertTrue(entity.document_type != None) self.assertEqual('Zeitungsartikel', entity.document_type.description)
def testFlyer(self): descriptions = ('Flyer: Irgendein Flyer', ' Flyer: Irgendein Flyer', ' Flyer :Irgendein Flyer', 'Flyer:Irgendein Flyer', 'Flyer :\tIrgendein Flyer') for description in descriptions: with self.subTest(description): entity = Document(4711) entity.description = description entity = self.post_processor.run(entity) self.assertTrue(entity.document_type != None) self.assertEqual('Flyer', entity.document_type.description) self.assertEqual('Irgendein Flyer', entity.description)
def testSaveNewDocument(self): document = Document() document.description = "My description" document.keywords = "My keywords" document.condition = "My document state" document.erfasser = self.injector.get(CreatorDao).get_by_id(2) document.document_type = self.injector.get(DocumentTypeDao).get_by_id( 5) self.dao.save(document) document = self.dao.get_last() self.assertEqual(15, document.id) self.assertEqual("My description", document.description) self.assertEqual("My keywords", document.keywords) self.assertEqual("My document state", document.condition) self.assertEqual(3, document.erfasser.id) self.assertEqual("Flugblatt", document.document_type.description) self.assertTrue(document.change_date) self.assertTrue(document.creation_date)
def test_string_generation(self): document = Document(4711) document.description = "My document" self.assertEqual("%s" % document, "4711: My document")