##// END OF EJS Templates
Fixed page 404 and some tests
neko259 -
r1988:5bf4a97e default
parent child Browse files
Show More
@@ -1,46 +1,46 b''
1 1 import logging
2 from django.core.urlresolvers import reverse, NoReverseMatch
2 from django.urls import reverse, NoReverseMatch
3 3 from django.test import TestCase, Client
4 4 from boards import urls
5 5
6 6
7 7 logger = logging.getLogger(__name__)
8 8
9 9 HTTP_CODE_OK = 200
10 10
11 11 EXCLUDED_VIEWS = {
12 12 'banned',
13 13 'get_thread_diff',
14 14 'api_sync_pull',
15 15 }
16 16
17 17
18 18 class ViewTest(TestCase):
19 19
20 20 def test_all_views(self):
21 21 """
22 22 Try opening all views defined in ulrs.py that don't need additional
23 23 parameters
24 24 """
25 25
26 26 client = Client()
27 27 for url in urls.urlpatterns:
28 28 try:
29 29 view_name = url.name
30 30 if view_name in EXCLUDED_VIEWS:
31 31 logger.debug('View {} is excluded.'.format(view_name))
32 32 continue
33 33
34 34 logger.debug('Testing view %s' % view_name)
35 35
36 36 try:
37 37 response = client.get(reverse(view_name))
38 38
39 39 self.assertEqual(HTTP_CODE_OK, response.status_code,
40 40 'View not opened: {}'.format(view_name))
41 41 except NoReverseMatch:
42 42 # This view just needs additional arguments
43 43 pass
44 44 except AttributeError:
45 45 # This is normal, some views do not have names
46 46 pass
@@ -1,17 +1,17 b''
1 1 from django.shortcuts import render
2 2
3 3 from boards.views.base import BaseBoardView
4 4
5 5
6 6 class NotFoundView(BaseBoardView):
7 7 """
8 8 Page 404 (not found)
9 9 """
10 10
11 def get(self, request):
11 def get(self, request, *args, **kwargs):
12 12 params = self.get_context_data()
13 13
14 14 response = render(request, 'boards/404.html', params)
15 15 response.status_code = 404
16 16
17 17 return response
General Comments 0
You need to be logged in to leave comments. Login now