def test_file_extensions(self): for ext in [".pdf", ".jpe", ".jpg", ".jpeg", ".txt", ".csv"]: self.assertIn(ext, get_supported_file_extensions()) self.assertEqual(get_default_file_extension('application/pdf'), ".pdf") self.assertEqual(get_default_file_extension('image/png'), ".png") self.assertEqual(get_default_file_extension('image/jpeg'), ".jpg") self.assertEqual(get_default_file_extension('text/plain'), ".txt") self.assertEqual(get_default_file_extension('text/csv'), ".csv") self.assertEqual(get_default_file_extension('application/zip'), ".zip") self.assertEqual(get_default_file_extension('aasdasd/dgfgf'), "") self.assertEqual(get_parser_class_for_mime_type('application/pdf'), RasterisedDocumentParser) self.assertEqual(get_parser_class_for_mime_type('text/plain'), TextDocumentParser) self.assertEqual(get_parser_class_for_mime_type('text/sdgsdf'), None) self.assertTrue(is_file_ext_supported('.pdf')) self.assertFalse(is_file_ext_supported('.hsdfh'))
def file_type(self): return get_default_file_extension(self.mime_type)