diff options
| author | Brett Haydon <brett@haydon.id.au> | 2016-06-07 10:26:24 +1000 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-06-07 09:46:58 -0400 |
| commit | bd7de3cb87b40b264ef9c4ecb8af59501525d9a6 (patch) | |
| tree | 1347d093a1929d01dc7fad93cfce823f47372fb7 /tests | |
| parent | 34f13e030be0f061b23d7332a47292794cd50fed (diff) | |
[1.10.x] Fixed #26716 -- Made CurrentSiteMiddleware compatible with new-style middleware.
Backport of 5e3f4c2e53d9dde0fcf9f5f33f63c15c4750019f from master
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/sites_tests/tests.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/sites_tests/tests.py b/tests/sites_tests/tests.py index fa618b4acc..7a4215cc4a 100644 --- a/tests/sites_tests/tests.py +++ b/tests/sites_tests/tests.py @@ -11,7 +11,7 @@ from django.contrib.sites.requests import RequestSite 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 +from django.http import HttpRequest, HttpResponse from django.test import TestCase, modify_settings, override_settings from django.test.utils import captured_stdout @@ -305,9 +305,15 @@ class CreateDefaultSiteTests(TestCase): class MiddlewareTest(TestCase): - def test_request(self): + def test_old_style_request(self): """ Makes sure that the request has correct `site` attribute. """ middleware = CurrentSiteMiddleware() request = HttpRequest() middleware.process_request(request) self.assertEqual(request.site.id, settings.SITE_ID) + + def test_request(self): + def get_response(request): + return HttpResponse(str(request.site.id)) + response = CurrentSiteMiddleware(get_response)(HttpRequest()) + self.assertContains(response, settings.SITE_ID) |
