Private
Public Access
1
0
Files
rowsandall/rowers/tests/test_errorpages.py
Sander Roosendaal 1c63c6ef3a bug fixes
2019-04-12 21:48:59 -04:00

48 lines
1.6 KiB
Python

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
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):
factory = RequestFactory()
request = factory.get('/')
e = None
response = error404_view(request,e )
self.assertEqual(response.status_code, 404)
self.assertIn('404 Page not found', str(response.content))
response = error500_view(request)
self.assertEqual(response.status_code, 500)
self.assertIn('500 Internal Server Error', str(response.content))
response = error400_view(request, e)
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))