mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Added a separate test class for RequestSite.
This commit is contained in:
parent
1d8cfa3608
commit
2015f5f134
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user