custom test views repair
This commit is contained in:
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user