Skip to content
Browse files

prove the importance of coverage

  • Loading branch information...
1 parent 5255877 commit 97d1e505c913a7b58cd864e88e6fa5faf8a2dea7 Øyvind Saltvik committed Sep 25, 2011
Showing with 11 additions and 2 deletions.
  1. +7 −0 cmsplugin_blog/tests/__init__.py
  2. +4 −2 cmsplugin_blog/views.py
View
7 cmsplugin_blog/tests/__init__.py
@@ -297,10 +297,17 @@ def test_01_redirect_existing_language(self):
with SettingsOverride(DEBUG=True):
self.client.get(u'/en/')
+ mwc = [mw for mw in settings.MIDDLEWARE_CLASSES if mw != 'cmsplugin_blog.middleware.MultilingualBlogEntriesMiddleware']
+ with SettingsOverride(MIDDLEWARE_CLASSES=mwc):
+ response = self.client.get(u'/test-page-1/2011/08/31/entry-title/')
+ self.assertEqual(response.status_code, 404)
+
response = self.client.get(u'/test-page-1/2011/08/31/entry-title/')
self.assertRedirects(response, u'/de/test-page-1/2011/08/31/entry-title/')
+
response = self.client.get(u'/de/test-page-1/2011/08/31/entry-title/')
self.assertEqual(response.status_code, 200)
+
self.create_entry_title(entry, language='nb')
self.client.get(u'/en/')
response = self.client.get(u'/test-page-1/2011/08/31/entry-title/')
View
6 cmsplugin_blog/views.py
@@ -1,8 +1,8 @@
import datetime
-try:
+try: # pragma: no cover
from django.views.generic.dates import BaseDateDetailView, ArchiveIndexView, _date_lookup_for_field, _date_from_string
from django.views.generic.detail import SingleObjectTemplateResponseMixin
-except ImportError:
+except ImportError: # pragma: no cover
from cbv.views.detail import SingleObjectTemplateResponseMixin
from cbv.views.dates import BaseDateDetailView, ArchiveIndexView, _date_lookup_for_field, _date_from_string
@@ -76,6 +76,8 @@ def get_object(self):
raise e
# We know there is only one title for this entry, so we can simply use get()
raise Redirect(obj.entrytitle_set.get().get_absolute_url())
+ else:
+ raise e
set_language_changer(self.request, obj.language_changer)
return obj

0 comments on commit 97d1e50

Please sign in to comment.
Something went wrong with that request. Please try again.