diff --git a/cadpoint/web/tests.py b/cadpoint/web/tests.py index 26032d6..31a7e8c 100644 --- a/cadpoint/web/tests.py +++ b/cadpoint/web/tests.py @@ -2,7 +2,7 @@ from unittest.mock import patch from django.contrib.auth import get_user_model from django.forms import Textarea -from django.test import SimpleTestCase, TestCase +from django.test import RequestFactory, SimpleTestCase, TestCase from django.urls import reverse from etpgrf.config import MODE_UNICODE, SANITIZE_ETPGRF from taggit.models import Tag @@ -444,3 +444,50 @@ class SitemapTests(TestCase): self.assertNotContains(response, 'skrytaya-statya') +class ErrorHandlersTests(SimpleTestCase): + def setUp(self): + self.factory = RequestFactory() + + def test_handler400_renders_modern_template(self): + from web.views import handler400 + + request = self.factory.get('/bad-request/') + response = handler400(request, Exception('bad request')) + + self.assertEqual(response.status_code, 400) + self.assertContains(response, 'CADpoint.ru - http 400 error', status_code=400) + self.assertContains(response, '', status_code=400) + self.assertContains(response, 'запрос получился некорректным', status_code=400) + self.assertContains(response, 'Вернуться на главную', status_code=400) + + def test_handler403_renders_modern_template(self): + from web.views import handler403 + + request = self.factory.get('/forbidden/') + response = handler403(request, Exception('forbidden')) + + self.assertEqual(response.status_code, 403) + self.assertContains(response, 'CADpoint.ru - http 403 error', status_code=403) + self.assertContains(response, '', status_code=403) + self.assertContains(response, 'доступ к этой странице ограничен.', status_code=403) + + def test_handler404_renders_modern_template(self): + response = self.client.get('/no-such-page/') + + self.assertEqual(response.status_code, 404) + self.assertContains(response, 'CADpoint.ru - http 404 error', status_code=404) + self.assertContains(response, '', status_code=404) + self.assertContains(response, 'похоже, такой страницы больше нет.', status_code=404) + + def test_handler500_renders_modern_template(self): + from web.views import handler500 + + request = self.factory.get('/boom/') + response = handler500(request) + + self.assertEqual(response.status_code, 500) + self.assertContains(response, 'CADpoint.ru - http 500 error', status_code=500) + self.assertContains(response, '', status_code=500) + self.assertContains(response, 'подождите, скоро всё починят…', status_code=500) + + diff --git a/public/favicon.svg b/public/favicon.svg index 48f5def..e8049a7 100644 --- a/public/favicon.svg +++ b/public/favicon.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/public/static/svgs/404-error.svg b/public/static/svgs/404-error.svg index e368faa..bb683a9 100644 --- a/public/static/svgs/404-error.svg +++ b/public/static/svgs/404-error.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/public/static/svgs/500-error.svg b/public/static/svgs/500-error.svg index 3c19b49..89b57ae 100644 --- a/public/static/svgs/500-error.svg +++ b/public/static/svgs/500-error.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/public/static/svgs/cappoint_under_reconstruction.svg b/public/static/svgs/cappoint_under_reconstruction.svg index a1e3579..7d7bfbe 100644 --- a/public/static/svgs/cappoint_under_reconstruction.svg +++ b/public/static/svgs/cappoint_under_reconstruction.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/public/static/svgs/favicon.svg b/public/static/svgs/favicon.svg index 48f5def..e8049a7 100644 --- a/public/static/svgs/favicon.svg +++ b/public/static/svgs/favicon.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/public/static/svgs/logo_cadpoint-2021-border.svg b/public/static/svgs/logo_cadpoint-2021-border.svg index efd6714..e67a724 100644 --- a/public/static/svgs/logo_cadpoint-2021-border.svg +++ b/public/static/svgs/logo_cadpoint-2021-border.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/public/static/svgs/logo_cadpoint-2021.svg b/public/static/svgs/logo_cadpoint-2021.svg index 1760f7f..0af3f8f 100644 --- a/public/static/svgs/logo_cadpoint-2021.svg +++ b/public/static/svgs/logo_cadpoint-2021.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/public/static/svgs/search-ico.svg b/public/static/svgs/search-ico.svg index 67b6cbc..d186ef4 100644 --- a/public/static/svgs/search-ico.svg +++ b/public/static/svgs/search-ico.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/public/static/svgs/tag.svg b/public/static/svgs/tag.svg index c0d05c0..bbaaa7e 100644 --- a/public/static/svgs/tag.svg +++ b/public/static/svgs/tag.svg @@ -1,4 +1 @@ - - - - \ No newline at end of file + \ No newline at end of file