summaryrefslogtreecommitdiff
path: root/tests/sites_tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-09-28 07:58:01 -0400
committerTim Graham <timograham@gmail.com>2017-09-28 08:14:17 -0400
commit2015f5f134e17fa906074ce293ea2abe8b74b1df (patch)
tree988ffdbd81967cdae10e14e688ec53d28f91e4e5 /tests/sites_tests
parent1d8cfa36089f2d1295abad03a99fc3c259bde6b5 (diff)
Added a separate test class for RequestSite.
Diffstat (limited to 'tests/sites_tests')
-rw-r--r--tests/sites_tests/tests.py31
1 files changed, 15 insertions, 16 deletions
diff --git a/tests/sites_tests/tests.py b/tests/sites_tests/tests.py
index 9e2d7ad4fc..9751ce5449 100644
--- a/tests/sites_tests/tests.py
+++ b/tests/sites_tests/tests.py
@@ -10,7 +10,9 @@ from django.contrib.sites.shortcuts import get_current_site
from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.db.models.signals import post_migrate
from django.http import HttpRequest, HttpResponse
-from django.test import TestCase, modify_settings, override_settings
+from django.test import (
+ SimpleTestCase, TestCase, modify_settings, override_settings,
+)
from django.test.utils import captured_stdout
@@ -203,27 +205,24 @@ class SitesFrameworkTests(TestCase):
self.assertEqual(Site.objects.get_by_natural_key(self.site.domain), self.site)
self.assertEqual(self.site.natural_key(), (self.site.domain,))
- @override_settings(ALLOWED_HOSTS=['example.com'])
- def test_requestsite_save_notimplemented_msg(self):
- # Test response msg for RequestSite.save NotImplementedError
+
+@override_settings(ALLOWED_HOSTS=['example.com'])
+class RequestSiteTests(SimpleTestCase):
+
+ def setUp(self):
request = HttpRequest()
- request.META = {
- "HTTP_HOST": "example.com",
- }
+ request.META = {'HTTP_HOST': 'example.com'}
+ self.site = RequestSite(request)
+
+ def test_save(self):
msg = 'RequestSite cannot be saved.'
with self.assertRaisesMessage(NotImplementedError, msg):
- RequestSite(request).save()
+ self.site.save()
- @override_settings(ALLOWED_HOSTS=['example.com'])
- def test_requestsite_delete_notimplemented_msg(self):
- # Test response msg for RequestSite.delete NotImplementedError
- request = HttpRequest()
- request.META = {
- "HTTP_HOST": "example.com",
- }
+ def test_delete(self):
msg = 'RequestSite cannot be deleted.'
with self.assertRaisesMessage(NotImplementedError, msg):
- RequestSite(request).delete()
+ self.site.delete()
class JustOtherRouter: