##// END OF EJS Templates
404 page now returns the 404 status for real. Fixed some tests related to...
neko259 -
r890:dec155c1 default
parent child Browse files
Show More
@@ -7,12 +7,10 b" NEW_THREAD_PAGE = '/'"
7 7 THREAD_PAGE_ONE = '/thread/1/'
8 8 THREAD_PAGE = '/thread/'
9 9 TAG_PAGE = '/tag/'
10 HTTP_CODE_REDIRECT = 302
10 HTTP_CODE_REDIRECT = 301
11 11 HTTP_CODE_OK = 200
12 12 HTTP_CODE_NOT_FOUND = 404
13 13
14 PAGE_404 = 'boards/404.html'
15
16 14
17 15 class PagesTest(TestCase):
18 16
@@ -33,7 +31,7 b' class PagesTest(TestCase):'
33 31
34 32 response_not_existing = client.get(THREAD_PAGE + str(
35 33 existing_post_id + 1) + '/')
36 self.assertEqual(PAGE_404, response_not_existing.templates[0].name,
34 self.assertEqual(HTTP_CODE_NOT_FOUND, response_not_existing.status_code,
37 35 'Not existing thread is opened')
38 36
39 37 response_existing = client.get(TAG_PAGE + tag_name + '/')
@@ -42,8 +40,7 b' class PagesTest(TestCase):'
42 40 'Cannot open existing tag')
43 41
44 42 response_not_existing = client.get(TAG_PAGE + 'not_tag' + '/')
45 self.assertEqual(PAGE_404,
46 response_not_existing.templates[0].name,
43 self.assertEqual(HTTP_CODE_NOT_FOUND, response_not_existing.status_code,
47 44 'Not existing tag is opened')
48 45
49 46 reply_id = Post.objects.create_post('', TEST_TEXT,
@@ -51,6 +48,5 b' class PagesTest(TestCase):'
51 48 .get_thread())
52 49 response_not_existing = client.get(THREAD_PAGE + str(
53 50 reply_id) + '/')
54 self.assertEqual(PAGE_404,
55 response_not_existing.templates[0].name,
51 self.assertEqual(HTTP_CODE_REDIRECT, response_not_existing.status_code,
56 52 'Reply is opened as a thread')
@@ -8,6 +8,10 b' logger = logging.getLogger(__name__)'
8 8
9 9 HTTP_CODE_OK = 200
10 10
11 EXCLUDED_VIEWS = {
12 'banned',
13 }
14
11 15
12 16 class ViewTest(TestCase):
13 17
@@ -21,13 +25,17 b' class ViewTest(TestCase):'
21 25 for url in urls.urlpatterns:
22 26 try:
23 27 view_name = url.name
28 if view_name in EXCLUDED_VIEWS:
29 logger.debug('View {} is excluded.'.format(view_name))
30 continue
31
24 32 logger.debug('Testing view %s' % view_name)
25 33
26 34 try:
27 35 response = client.get(reverse(view_name))
28 36
29 37 self.assertEqual(HTTP_CODE_OK, response.status_code,
30 '%s view not opened' % view_name)
38 'View not opened: {}'.format(view_name))
31 39 except NoReverseMatch:
32 40 # This view just needs additional arguments
33 41 pass
@@ -12,4 +12,7 b' class NotFoundView(BaseBoardView):'
12 12 context = self.get_context_data(request=request)
13 13
14 14 # TODO Use dict here
15 return render(request, 'boards/404.html', context_instance=context)
15 response = render(request, 'boards/404.html', context_instance=context)
16 response.status_code = 404
17
18 return response
General Comments 0
You need to be logged in to leave comments. Login now