Show More
@@ -1,9 +1,13 b'' | |||
|
1 | 1 | # coding=utf-8 |
|
2 | import time | |
|
3 | import logging | |
|
4 | ||
|
2 | 5 | from django.test import TestCase |
|
3 | 6 | from django.test.client import Client |
|
4 | import time | |
|
7 | from django.core.urlresolvers import reverse, NoReverseMatch | |
|
5 | 8 | |
|
6 | 9 | from boards.models import Post, Tag |
|
10 | from boards import urls | |
|
7 | 11 | from neboard import settings |
|
8 | 12 | |
|
9 | 13 | PAGE_404 = 'boards/404.html' |
@@ -18,6 +22,8 b' HTTP_CODE_REDIRECT = 302' | |||
|
18 | 22 | HTTP_CODE_OK = 200 |
|
19 | 23 | HTTP_CODE_NOT_FOUND = 404 |
|
20 | 24 | |
|
25 | logger = logging.getLogger(__name__) | |
|
26 | ||
|
21 | 27 | |
|
22 | 28 | class PostTests(TestCase): |
|
23 | 29 | |
@@ -223,11 +229,29 b' class FormTest(TestCase):' | |||
|
223 | 229 | |
|
224 | 230 | |
|
225 | 231 | class ViewTest(TestCase): |
|
226 | def test_index(self): | |
|
232 | ||
|
233 | def test_all_views(self): | |
|
234 | ''' | |
|
235 | Try opening all views defined in ulrs.py that don't need additional | |
|
236 | parameters | |
|
237 | ''' | |
|
238 | ||
|
227 | 239 | client = Client() |
|
240 | for url in urls.urlpatterns: | |
|
241 | try: | |
|
242 | view_name = url.name | |
|
243 | logger.debug('Testing view %s' % view_name) | |
|
228 | 244 | |
|
229 | response = client.get('/') | |
|
230 | self.assertEqual(HTTP_CODE_OK, response.status_code, 'Index page not ' | |
|
231 | 'opened') | |
|
232 | self.assertEqual('boards/posting_general.html', response.templates[0] | |
|
233 | .name, 'Index page should open posting_general template') | |
|
245 | try: | |
|
246 | response = client.get(reverse(view_name)) | |
|
247 | ||
|
248 | self.assertEqual(HTTP_CODE_OK, response.status_code, | |
|
249 | '%s view not opened' % view_name) | |
|
250 | except NoReverseMatch: | |
|
251 | # This view just needs additional arguments | |
|
252 | pass | |
|
253 | except Exception, e: | |
|
254 | self.fail('Got exception %s at %s view' % (e, view_name)) | |
|
255 | except AttributeError: | |
|
256 | # This is normal, some views do not have names | |
|
257 | pass |
@@ -49,7 +49,7 b" urlpatterns = patterns(''," | |||
|
49 | 49 | url(r'^delete/(?P<post_id>\w+)/$', views.delete, name='delete'), |
|
50 | 50 | url(r'^ban/(?P<post_id>\w+)/$', views.ban, name='ban'), |
|
51 | 51 | |
|
52 | url(r'^banned/$', views.banned.BannedView.as_view, name='banned'), | |
|
52 | url(r'^banned/$', views.banned.BannedView.as_view(), name='banned'), | |
|
53 | 53 | url(r'^staticpage/(?P<name>\w+)/$', views.static_page, name='staticpage'), |
|
54 | 54 | |
|
55 | 55 | # RSS feeds |
@@ -9,7 +9,7 b' class BannedView(BaseBoardView):' | |||
|
9 | 9 | def get(self, request): |
|
10 | 10 | """Show the page that notifies that user is banned""" |
|
11 | 11 | |
|
12 | context = self.get_context_data(request) | |
|
12 | context = self.get_context_data(request=request) | |
|
13 | 13 | |
|
14 | 14 | ban = get_object_or_404(Ban, ip=utils.get_client_ip(request)) |
|
15 | 15 | context['ban_reason'] = ban.reason |
General Comments 0
You need to be logged in to leave comments.
Login now