diff options
author | Tim Graham <timograham@gmail.com> | 2015-12-10 13:44:10 -0500 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2015-12-10 13:44:54 -0500 |
commit | 5bc881541caafbac6911fb26d9718b8ad6d45b2a (patch) | |
tree | fb9bb57632db64301deb30e15b6e44db331e46fd /tests/middleware | |
parent | 071af825398bab08246aa28c227514ed37cf4244 (diff) | |
download | django-5bc881541caafbac6911fb26d9718b8ad6d45b2a.tar.gz |
Moved a few CommonMiddleware tests to the correct test class.
Diffstat (limited to 'tests/middleware')
-rw-r--r-- | tests/middleware/tests.py | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/tests/middleware/tests.py b/tests/middleware/tests.py index 0b594b5b6d..7ccfd919cc 100644 --- a/tests/middleware/tests.py +++ b/tests/middleware/tests.py @@ -270,6 +270,27 @@ class CommonMiddlewareTest(SimpleTestCase): self.assertEqual(r.url, 'http://www.testserver/customurlconf/slash/') + # ETag + If-Not-Modified support tests + + @override_settings(USE_ETAGS=True) + def test_etag(self): + req = HttpRequest() + res = HttpResponse('content') + self.assertTrue(CommonMiddleware().process_response(req, res).has_header('ETag')) + + @override_settings(USE_ETAGS=True) + def test_etag_streaming_response(self): + req = HttpRequest() + res = StreamingHttpResponse(['content']) + res['ETag'] = 'tomatoes' + self.assertEqual(CommonMiddleware().process_response(req, res).get('ETag'), 'tomatoes') + + @override_settings(USE_ETAGS=True) + def test_no_etag_streaming_response(self): + req = HttpRequest() + res = StreamingHttpResponse(['content']) + self.assertFalse(CommonMiddleware().process_response(req, res).has_header('ETag')) + # Other tests @override_settings(DISALLOWED_USER_AGENTS=[re.compile(r'foo')]) @@ -474,29 +495,6 @@ class ConditionalGetMiddlewareTest(SimpleTestCase): self.resp = ConditionalGetMiddleware().process_response(self.req, self.resp) self.assertEqual(self.resp.status_code, 400) - @override_settings(USE_ETAGS=True) - def test_etag(self): - req = HttpRequest() - res = HttpResponse('content') - self.assertTrue( - CommonMiddleware().process_response(req, res).has_header('ETag')) - - @override_settings(USE_ETAGS=True) - def test_etag_streaming_response(self): - req = HttpRequest() - res = StreamingHttpResponse(['content']) - res['ETag'] = 'tomatoes' - self.assertEqual( - CommonMiddleware().process_response(req, res).get('ETag'), - 'tomatoes') - - @override_settings(USE_ETAGS=True) - def test_no_etag_streaming_response(self): - req = HttpRequest() - res = StreamingHttpResponse(['content']) - self.assertFalse( - CommonMiddleware().process_response(req, res).has_header('ETag')) - # Tests for the Last-Modified header def test_if_modified_since_and_no_last_modified(self): |