def test_verify_url_file_extension_ok(self): url = 'https://github.com/lokal-profil/BatchUploadTools.jpg' ext = verify_url_file_extension(url, self.file_exts, self.protocols) self.assertEqual(ext, '.jpg')
def test_verify_url_file_extension_dissalowed_ext(self): expected_error = 'https://github.com/lokal-profil/BatchUploadTools.txt: Found url with a disallowed file extension (.txt)' # noqa E501 url = 'https://github.com/lokal-profil/BatchUploadTools.txt' with self.assertRaises(MyError) as cm: verify_url_file_extension(url, self.file_exts) self.assertEqual(cm.exception.value, expected_error)
def test_verify_url_file_extension_dissalowed_protocol(self): expected_error = 'ftp://github.com/lokal-profil/BatchUploadTools.jpg: Found url with a disallowed protocol' # noqa E501 url = 'ftp://github.com/lokal-profil/BatchUploadTools.jpg' with self.assertRaises(MyError) as cm: verify_url_file_extension(url, self.file_exts, self.protocols) self.assertEqual(cm.exception.value, expected_error)
def test_verify_url_file_extension_empty(self): expected_error = ': Found url with a disallowed protocol' with self.assertRaises(MyError) as cm: verify_url_file_extension('', tuple(), tuple()) self.assertEqual(cm.exception.value, expected_error)