From 319b7112d8aa4a5fc38e9a8af2137d0074011439 Mon Sep 17 00:00:00 2001 From: Piers Storey Date: Sun, 3 Apr 2016 10:45:23 +0200 Subject: [PATCH] Fixed #26446 -- Added additional tests to cover methods in the RequestSite class --- tests/sites_tests/tests.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/sites_tests/tests.py b/tests/sites_tests/tests.py index ffd6223866..3cbd6af2ee 100644 --- a/tests/sites_tests/tests.py +++ b/tests/sites_tests/tests.py @@ -190,6 +190,26 @@ 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,)) + def test_requestsite_save_notimplemented_msg(self): + # Test response msg for RequestSite.save NotImplementedError + request = HttpRequest() + request.META = { + "HTTP_HOST": "example.com", + } + msg = 'RequestSite cannot be saved.' + with self.assertRaisesMessage(NotImplementedError, msg): + RequestSite(request).save() + + def test_requestsite_delete_notimplemented_msg(self): + # Test response msg for RequestSite.delete NotImplementedError + request = HttpRequest() + request.META = { + "HTTP_HOST": "example.com", + } + msg = 'RequestSite cannot be deleted.' + with self.assertRaisesMessage(NotImplementedError, msg): + RequestSite(request).delete() + class JustOtherRouter(object): def allow_migrate(self, db, app_label, **hints):