summaryrefslogtreecommitdiff
path: root/tests/httpwrappers
diff options
context:
space:
mode:
Diffstat (limited to 'tests/httpwrappers')
-rw-r--r--tests/httpwrappers/tests.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/httpwrappers/tests.py b/tests/httpwrappers/tests.py
index fbc5019979..cbf8b7d586 100644
--- a/tests/httpwrappers/tests.py
+++ b/tests/httpwrappers/tests.py
@@ -286,7 +286,7 @@ class QueryDictTests(SimpleTestCase):
QueryDict.fromkeys(0)
-class HttpResponseTests(unittest.TestCase):
+class HttpResponseTests(SimpleTestCase):
def test_headers_type(self):
r = HttpResponse()
@@ -470,10 +470,31 @@ class HttpResponseTests(unittest.TestCase):
# del doesn't raise a KeyError on nonexistent headers.
del r.headers['X-Foo']
+ def test_instantiate_with_headers(self):
+ r = HttpResponse('hello', headers={'X-Foo': 'foo'})
+ self.assertEqual(r.headers['X-Foo'], 'foo')
+ self.assertEqual(r.headers['x-foo'], 'foo')
+
def test_content_type(self):
r = HttpResponse('hello', content_type='application/json')
self.assertEqual(r.headers['Content-Type'], 'application/json')
+ def test_content_type_headers(self):
+ r = HttpResponse('hello', headers={'Content-Type': 'application/json'})
+ self.assertEqual(r.headers['Content-Type'], 'application/json')
+
+ def test_content_type_mutually_exclusive(self):
+ msg = (
+ "'headers' must not contain 'Content-Type' when the "
+ "'content_type' parameter is provided."
+ )
+ with self.assertRaisesMessage(ValueError, msg):
+ HttpResponse(
+ 'hello',
+ content_type='application/json',
+ headers={'Content-Type': 'text/csv'},
+ )
+
class HttpResponseSubclassesTests(SimpleTestCase):
def test_redirect(self):