Fixed submission error handling and broken tests
authorJoar Wandborg <git@wandborg.com>
Sat, 31 Dec 2011 21:57:08 +0000 (22:57 +0100)
committerJoar Wandborg <git@wandborg.com>
Sat, 31 Dec 2011 21:57:08 +0000 (22:57 +0100)
- Fixed broken test_auth test
- Fixed error handling on submission, it now raises the exception
  if it is not explicitly relevant to file submission.

mediagoblin/media_types/__init__.py
mediagoblin/submit/views.py
mediagoblin/tests/test_auth.py

index 7b9bf0d730cec7df3aab83583436b9f2a3be1fbe..e7eb1ddeb32015988797d151cd12175a986d28d6 100644 (file)
@@ -73,7 +73,7 @@ def get_media_type_and_manager(filename):
         # Get the file extension
         ext = os.path.splitext(filename)[1].lower()
     else:
-        raise Exception(
+        raise InvalidFileType(
             _(u'Could not extract any file extension from "{filename}"').format(
                 filename=filename))
 
index 443d0e5240a5c75b84a48267d7b1dac6d04ef6f1..60693bd6fef9c2738e55941f8b1a3a6fc808dd1e 100644 (file)
@@ -31,7 +31,8 @@ from mediagoblin.decorators import require_active_login
 from mediagoblin.submit import forms as submit_forms, security
 from mediagoblin.processing import mark_entry_failed, ProcessMedia
 from mediagoblin.messages import add_message, SUCCESS
-from mediagoblin.media_types import get_media_type_and_manager, InvalidFileType
+from mediagoblin.media_types import get_media_type_and_manager, \
+    InvalidFileType, FileTypeNotSupported
 
 
 @require_active_login
@@ -133,8 +134,13 @@ def submit_start(request):
                 This section is intended to catch exceptions raised in 
                 mediagobling.media_types
                 '''
-                submit_form.file.errors.append(
-                    e)
+
+                if isinstance(e, InvalidFileType) or \
+                        isinstance(e, FileTypeNotSupported):
+                    submit_form.file.errors.append(
+                        e)
+                else:
+                    raise
 
     return render_to_response(
         request,
index 9b0dea662a9cab2ccabd5a539173e1ad6612a45b..e54ffa5aad46afe7cf59751f95cd756ecf0037e6 100644 (file)
@@ -233,9 +233,9 @@ def test_register_views(test_app):
     ## Did we redirect to the proper page?  Use the right template?
     assert_equal(
         urlparse.urlsplit(response.location)[2],
-        '/auth/forgot_password/email_sent/')
+        '/auth/login/')
     assert template.TEMPLATE_TEST_CONTEXT.has_key(
-        'mediagoblin/auth/fp_email_sent.html')
+        'mediagoblin/auth/login.html')
 
     ## Make sure link to change password is sent by email
     assert len(mail.EMAIL_TEST_INBOX) == 1