Fixed #29662 -- Allowed test client to accept structured suffix JSON content types.
This commit is contained in:
parent
7eb556a6c2
commit
7cc52250f0
|
@ -34,8 +34,8 @@ __all__ = ('Client', 'RedirectCycleError', 'RequestFactory', 'encode_file', 'enc
|
||||||
BOUNDARY = 'BoUnDaRyStRiNg'
|
BOUNDARY = 'BoUnDaRyStRiNg'
|
||||||
MULTIPART_CONTENT = 'multipart/form-data; boundary=%s' % BOUNDARY
|
MULTIPART_CONTENT = 'multipart/form-data; boundary=%s' % BOUNDARY
|
||||||
CONTENT_TYPE_RE = re.compile(r'.*; charset=([\w\d-]+);?')
|
CONTENT_TYPE_RE = re.compile(r'.*; charset=([\w\d-]+);?')
|
||||||
# JSON Vendor Tree spec: https://tools.ietf.org/html/rfc6838#section-3.2
|
# Structured suffix spec: https://tools.ietf.org/html/rfc6838#section-4.2.8
|
||||||
JSON_CONTENT_TYPE_RE = re.compile(r'^application\/(vnd\..+\+)?json')
|
JSON_CONTENT_TYPE_RE = re.compile(r'^application\/(.+\+)?json')
|
||||||
|
|
||||||
|
|
||||||
class RedirectCycleError(Exception):
|
class RedirectCycleError(Exception):
|
||||||
|
|
|
@ -32,3 +32,6 @@ Bugfixes
|
||||||
* Fixed a regression where a ``related_query_name`` reverse accessor wasn't set
|
* Fixed a regression where a ``related_query_name`` reverse accessor wasn't set
|
||||||
up when a ``GenericRelation`` is declared on an abstract base model
|
up when a ``GenericRelation`` is declared on an abstract base model
|
||||||
(:ticket:`29653`).
|
(:ticket:`29653`).
|
||||||
|
|
||||||
|
* Fixed the test client's JSON serialization of a request data dictionary for
|
||||||
|
structured content type suffixes (:ticket:`29662`).
|
||||||
|
|
|
@ -1204,11 +1204,13 @@ class RequestMethodStringDataTests(SimpleTestCase):
|
||||||
response = self.client.get('/json_response/')
|
response = self.client.get('/json_response/')
|
||||||
self.assertEqual(response.json(), {'key': 'value'})
|
self.assertEqual(response.json(), {'key': 'value'})
|
||||||
|
|
||||||
def test_json_vendor(self):
|
def test_json_structured_suffixes(self):
|
||||||
valid_types = (
|
valid_types = (
|
||||||
'application/vnd.api+json',
|
'application/vnd.api+json',
|
||||||
'application/vnd.api.foo+json',
|
'application/vnd.api.foo+json',
|
||||||
'application/json; charset=utf-8',
|
'application/json; charset=utf-8',
|
||||||
|
'application/activity+json',
|
||||||
|
'application/activity+json; charset=utf-8',
|
||||||
)
|
)
|
||||||
for content_type in valid_types:
|
for content_type in valid_types:
|
||||||
response = self.client.get('/json_response/', {'content_type': content_type})
|
response = self.client.get('/json_response/', {'content_type': content_type})
|
||||||
|
|
Loading…
Reference in New Issue