def test_parse(self): handler = HandlersManager.get_best_handler(".odt") myfile = handler(self.FILE, os.path.basename(self.FILE)) self.assertTrue(myfile.is_valid()) self.assertEquals(tuple(myfile.attributes), ("nb_pages", "format")) self.assertEqual("A4", myfile.format) self.assertEqual(3, myfile.nb_pages)
def test_parse(self): handler = HandlersManager.get_best_handler(".odt") myfile = handler(self.FILE, os.path.basename(self.FILE)) self.failUnless(myfile.is_valid()) self.assertEquals(tuple(myfile.attributes), ("nb_pages", "format")) self.assertEqual("A4", myfile.format) self.assertEqual(3, myfile.nb_pages)
def handle_added_file(self, doc_file): if os.path.splitext(doc_file.file.path)[1].lower() == ".odt": handler_cls = HandlersManager.get_best_handler(".odt") handler = handler_cls(doc_file.file.path, doc_file.filename) if handler.is_valid(): self.nb_pages = handler.nb_pages self.format = handler.format self.save()
def handle_added_file(self, doc_file): ext = os.path.splitext(doc_file.file.path)[1].lower() if os.path.splitext(doc_file.file.path)[1].lower() == ".pdf": handler_cls = HandlersManager.get_best_handler(".pdf") handler = handler_cls(doc_file.file.path, doc_file.filename) if handler.is_valid(): self.nb_pages = handler.nb_pages self.name = handler.title self.save()
def test_get_handler(self): handler = HandlersManager.get_best_handler(".odt") self.assertEquals(handler, ODFHandler)