Private
Public Access
1
0

custom test views repair

This commit is contained in:
Sander Roosendaal
2019-04-07 10:28:03 +02:00
parent a6766bb109
commit 0d68f90066
8 changed files with 56 additions and 23 deletions

View File

@@ -6,13 +6,12 @@ from __future__ import unicode_literals
#from __future__ import print_function
from .statements import *
from django.test import SimpleTestCase, override_settings
#@pytest.mark.django_db
class TestErrorPages(TestCase):
def test_error_handlers(self):
self.assertTrue(urls.handler404.endswith('.error404_view'))
self.assertTrue(urls.handler500.endswith('.error500_view'))
factory = RequestFactory()
request = factory.get('/')
response = error404_view(request)
@@ -26,3 +25,22 @@ class TestErrorPages(TestCase):
response = error400_view(request)
self.assertEqual(response.status_code, 400)
# ROOT_URLCONF must specify the module that contains handler403 = ...
#@override_settings(ROOT_URLCONF=__name__)
class CustomErrorHandlerTests(TestCase):
def setUp(self):
self.c = Client()
def test_handler_workout_notfound(self):
response = self.c.get('/rowers/workout/121/')
# Make assertions on the response here. For example:
self.assertEqual(response.status_code, 404)
self.assertIn('We could not find' ,str(response.content))
def test_handler_500(self):
response = self.c.get('/500/')
# Make assertions on the response here. For example:
self.assertEqual(response.status_code, 500)
self.assertIn('The site developer' ,str(response.content))

Binary file not shown.