summaryrefslogtreecommitdiff
path: root/tests/test_client_regress
diff options
context:
space:
mode:
authorAnton Samarchyan <desecho@gmail.com>2016-12-29 08:32:15 -0500
committerTim Graham <timograham@gmail.com>2016-12-29 08:32:15 -0500
commit0b5d4c49d652ba7156b8998cec142ea4f4c55d58 (patch)
tree48654178c39c54419cc63d531286e67cdf26fb4b /tests/test_client_regress
parentd20e046bbd7417c043f40d5fb8ebab863595b3eb (diff)
downloaddjango-0b5d4c49d652ba7156b8998cec142ea4f4c55d58.tar.gz
Fixed #27622 -- Allowed test client to accept vendor tree JSON content types.
Diffstat (limited to 'tests/test_client_regress')
-rw-r--r--tests/test_client_regress/tests.py6
-rw-r--r--tests/test_client_regress/views.py4
2 files changed, 9 insertions, 1 deletions
diff --git a/tests/test_client_regress/tests.py b/tests/test_client_regress/tests.py
index 7a633ee7a3..2c1a9b346a 100644
--- a/tests/test_client_regress/tests.py
+++ b/tests/test_client_regress/tests.py
@@ -1209,6 +1209,12 @@ class RequestMethodStringDataTests(SimpleTestCase):
response = self.client.get('/json_response/')
self.assertEqual(response.json(), {'key': 'value'})
+ def test_json_vendor(self):
+ for content_type in ('application/vnd.api+json', 'application/vnd.api.foo+json'):
+ response = self.client.get('/json_response/', {'content_type': content_type})
+ self.assertEqual(response['Content-Type'], content_type)
+ self.assertEqual(response.json(), {'key': 'value'})
+
def test_json_multiple_access(self):
response = self.client.get('/json_response/')
self.assertIs(response.json(), response.json())
diff --git a/tests/test_client_regress/views.py b/tests/test_client_regress/views.py
index a50b0e1ed3..ce60c0398c 100644
--- a/tests/test_client_regress/views.py
+++ b/tests/test_client_regress/views.py
@@ -106,7 +106,9 @@ def return_undecodable_binary(request):
def return_json_response(request):
- return JsonResponse({'key': 'value'})
+ content_type = request.GET.get('content_type')
+ kwargs = {'content_type': content_type} if content_type else {}
+ return JsonResponse({'key': 'value'}, **kwargs)
def return_json_file(request):