Browse Source

Fixed unit tests

Rafał Pitoń 11 years ago
parent
commit
d9d614b6d3

+ 1 - 1
misago/core/forms.py

@@ -14,7 +14,7 @@ class AutoStripWhitespacesMixin(object):
                     self.data[name] = self.data[name].strip()
                     self.data[name] = self.data[name].strip()
                 except KeyError:
                 except KeyError:
                     pass
                     pass
-        return super(AutoStripInputMixin, self).full_clean()
+        return super(AutoStripWhitespacesMixin, self).full_clean()
 
 
 
 
 class Form(AutoStripWhitespacesMixin, BaseForm):
 class Form(AutoStripWhitespacesMixin, BaseForm):

+ 3 - 6
misago/core/tests/test_errorpages.py

@@ -1,21 +1,18 @@
 from django.core.urlresolvers import reverse
 from django.core.urlresolvers import reverse
 from django.test import TestCase
 from django.test import TestCase
-from misago.core import errorpages
 
 
 
 
 class ErrorPageViewsTests(TestCase):
 class ErrorPageViewsTests(TestCase):
-    def setUp(self):
-        response = self.client.get(reverse('forum_index'))
-        self.request = response.request
+    urls = 'misago.core.testproject.urls'
 
 
     def test_permission_denied_returns_403(self):
     def test_permission_denied_returns_403(self):
         """permission_denied error page has no show-stoppers"""
         """permission_denied error page has no show-stoppers"""
-        response = errorpages.permission_denied(self.request)
+        response = self.client.get(reverse('raise_misago_403'))
         self.assertEqual(response.status_code, 403)
         self.assertEqual(response.status_code, 403)
 
 
     def test_page_not_found_returns_404(self):
     def test_page_not_found_returns_404(self):
         """page_not_found error page has no show-stoppers"""
         """page_not_found error page has no show-stoppers"""
-        response = errorpages.page_not_found(self.request)
+        response = self.client.get(reverse('raise_misago_404'))
         self.assertEqual(response.status_code, 404)
         self.assertEqual(response.status_code, 404)
 
 
 
 

+ 4 - 3
misago/core/tests/test_exceptionhandler.py

@@ -1,3 +1,4 @@
+from django.core.urlresolvers import reverse
 from django.http import Http404
 from django.http import Http404
 from django.core import exceptions as django_exceptions
 from django.core import exceptions as django_exceptions
 from django.core.exceptions import PermissionDenied
 from django.core.exceptions import PermissionDenied
@@ -68,7 +69,7 @@ class GetExceptionHandlerTests(TestCase):
 class HandleHttp404ExceptionTests(TestCase):
 class HandleHttp404ExceptionTests(TestCase):
     def setUp(self):
     def setUp(self):
         self.exception = Http404()
         self.exception = Http404()
-        self.request = RequestFactory().get('/')
+        self.request = RequestFactory().get(reverse('forum_index'))
 
 
     def test_get_handle_http404_exception(self):
     def test_get_handle_http404_exception(self):
         """get_exception_handler returns correct Http404 exception handler"""
         """get_exception_handler returns correct Http404 exception handler"""
@@ -89,7 +90,7 @@ class HandleHttp404ExceptionTests(TestCase):
 class HandleOutdatedSlugExceptionTests(TestCase):
 class HandleOutdatedSlugExceptionTests(TestCase):
     def setUp(self):
     def setUp(self):
         self.exception = OutdatedSlug()
         self.exception = OutdatedSlug()
-        self.request = RequestFactory().get('/')
+        self.request = RequestFactory().get(reverse('forum_index'))
 
 
     def test_get_handle_outdated_slug_exception(self):
     def test_get_handle_outdated_slug_exception(self):
         """
         """
@@ -115,7 +116,7 @@ class HandlePermissionDeniedExceptionTests(TestCase):
     def setUp(self):
     def setUp(self):
         self.exception_message = "Page access not allowed"
         self.exception_message = "Page access not allowed"
         self.exception = PermissionDenied(self.exception_message)
         self.exception = PermissionDenied(self.exception_message)
-        self.request = RequestFactory().get('/')
+        self.request = RequestFactory().get(reverse('forum_index'))
 
 
     def test_get_handle_permission_denied_exception(self):
     def test_get_handle_permission_denied_exception(self):
         """
         """

+ 2 - 0
misago/project_template/project_name/urls.py

@@ -12,6 +12,8 @@ urlpatterns = patterns('',
 
 
 
 
 # Serve static and media files in development
 # Serve static and media files in development
+from django.conf.urls.static import static
+
 urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
 urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
 urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
 urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)