[Django] #27622: Testing client should accept vendor tree json variants

6 views
Skip to first unread message

Django

unread,
Dec 22, 2016, 6:32:31 AM12/22/16
to django-...@googlegroups.com
#27622: Testing client should accept vendor tree json variants
-------------------------------------+-------------------------------------
Reporter: John | Owner: nobody
Gresty |
Type: New | Status: new
feature |
Component: Testing | Version: master
framework | Keywords: json jsonp json_api
Severity: Normal | testing_client
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
The test client currently only supports parsing json with content-type
'application/json'.

Any variant on json (eg json api)which uses a different content-type will
cause a ValueError, the client should be configurable to accept a user
defined content-type, or accept "/application\/(vnd\.([a-z]*)\+)?json/"

--
Ticket URL: <https://code.djangoproject.com/ticket/27622>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 22, 2016, 6:33:00 AM12/22/16
to django-...@googlegroups.com
#27622: Testing client should accept vendor tree json variants
-------------------------------------+-------------------------------------
Reporter: John Gresty | Owner: nobody
Type: New feature | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: json vendor | Triage Stage:
testing_client | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by John Gresty):

* keywords: json jsonp json_api testing_client => json vendor
testing_client


--
Ticket URL: <https://code.djangoproject.com/ticket/27622#comment:1>

Django

unread,
Dec 22, 2016, 6:53:38 AM12/22/16
to django-...@googlegroups.com
#27622: Testing client should accept vendor tree json variants
-------------------------------------+-------------------------------------
Reporter: John Gresty | Owner: nobody
Type: New feature | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: json vendor | Triage Stage:
testing_client | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

I'm not familiar with vendor tree json variants. Could you explain that a
bit more and give a use case in the Django ecosystem? Is it common
practice and/or a standard?

--
Ticket URL: <https://code.djangoproject.com/ticket/27622#comment:2>

Django

unread,
Dec 22, 2016, 7:41:37 AM12/22/16
to django-...@googlegroups.com
#27622: Testing client should accept vendor tree json variants
-------------------------------------+-------------------------------------
Reporter: John Gresty | Owner: nobody
Type: New feature | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: json vendor | Triage Stage:
testing_client | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by John Gresty):

Replying to [comment:2 Tim Graham]:


> I'm not familiar with vendor tree json variants. Could you explain that
a bit more and give a use case in the Django ecosystem? Is it common
practice and/or a standard?

Vendor trees are defined in section 3.2 of RFC 6838
([https://tools.ietf.org/html/rfc6838#section-3.2]). My use case was
trying to test a json api ([http://jsonapi.org]) implemented using
[https://github.com/django-json-api/django-rest-framework-json-api] which
returns the IANA registered content-type 'application/vnd.api+json'

--
Ticket URL: <https://code.djangoproject.com/ticket/27622#comment:3>

Django

unread,
Dec 22, 2016, 8:04:45 AM12/22/16
to django-...@googlegroups.com
#27622: Testing client should accept vendor tree json variants
-------------------------------------+-------------------------------------
Reporter: John Gresty | Owner: nobody
Type: New feature | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: json vendor | Triage Stage: Accepted
testing_client |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted


Comment:

Thanks, I guess it's okay to accept `application/json` variants then. I
didn't verify your regex is correct.

--
Ticket URL: <https://code.djangoproject.com/ticket/27622#comment:4>

Django

unread,
Dec 22, 2016, 5:44:39 PM12/22/16
to django-...@googlegroups.com
#27622: Testing client should accept vendor tree json variants
-------------------------------------+-------------------------------------
Reporter: John Gresty | Owner: nobody
Type: New feature | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: json vendor | Triage Stage: Accepted
testing_client |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Adam Chainz):

The regex mentions `vnd.bigcompany.funnypictures` as a possible vendor
name which the suggested regex won't parse. Maybe django can use a looser
regex like `r'^application\/(vnd\..+\+)?json$'` as per the robustness
principle.

Or maybe even drop the header check - if a test calls `resp.json()` it's
already 99.99% sure the response is in JSON, and if it's not, what's wrong
with the test giving a `JSONDecodeError`? (Maybe heading into backwards
incompatible territory there though).

--
Ticket URL: <https://code.djangoproject.com/ticket/27622#comment:5>

Django

unread,
Dec 28, 2016, 5:49:13 PM12/28/16
to django-...@googlegroups.com
#27622: Testing client should accept vendor tree json variants
-------------------------------------+-------------------------------------
Reporter: John Gresty | Owner: nobody
Type: New feature | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: json vendor | Triage Stage: Accepted
testing_client |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Anton Samarchyan):

* cc: desecho@… (added)
* has_patch: 0 => 1


Comment:

Added [https://github.com/django/django/pull/7760 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/27622#comment:6>

Django

unread,
Dec 29, 2016, 8:05:14 AM12/29/16
to django-...@googlegroups.com
#27622: Test client should accept vendor tree json variants
-------------------------------------+-------------------------------------

Reporter: John Gresty | Owner: nobody
Type: New feature | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: json vendor | Triage Stage: Ready for
testing_client | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/27622#comment:7>

Django

unread,
Dec 29, 2016, 8:32:37 AM12/29/16
to django-...@googlegroups.com
#27622: Test client should accept vendor tree json variants
-------------------------------------+-------------------------------------

Reporter: John Gresty | Owner: nobody
Type: New feature | Status: closed

Component: Testing framework | Version: master
Severity: Normal | Resolution: fixed

Keywords: json vendor | Triage Stage: Ready for
testing_client | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"0b5d4c49d652ba7156b8998cec142ea4f4c55d58" 0b5d4c49]:
{{{
#!CommitTicketReference repository=""
revision="0b5d4c49d652ba7156b8998cec142ea4f4c55d58"
Fixed #27622 -- Allowed test client to accept vendor tree JSON content
types.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27622#comment:8>

Django

unread,
Mar 7, 2017, 10:15:29 AM3/7/17
to django-...@googlegroups.com
#27622: Test client should accept vendor tree json variants
-------------------------------------+-------------------------------------

Reporter: John Gresty | Owner: nobody
Type: New feature | Status: closed
Component: Testing framework | Version: master
Severity: Normal | Resolution: fixed
Keywords: json vendor | Triage Stage: Ready for
testing_client | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz):

I spotted a regression introduced by this change:
[https://github.com/django/django/pull/8153 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/27622#comment:9>

Django

unread,
Mar 7, 2017, 10:58:23 AM3/7/17
to django-...@googlegroups.com
#27622: Test client should accept vendor tree json variants
-------------------------------------+-------------------------------------

Reporter: John Gresty | Owner: nobody
Type: New feature | Status: closed
Component: Testing framework | Version: master
Severity: Normal | Resolution: fixed
Keywords: json vendor | Triage Stage: Ready for
testing_client | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz <claude@…>):

In [changeset:"145f6c3ed6e8856078e2d04ff2567e9fb4a17930" 145f6c3]:
{{{
#!CommitTicketReference repository=""
revision="145f6c3ed6e8856078e2d04ff2567e9fb4a17930"
Refs #27622 -- Fixed a regression in JSON content-type detection

A JSON Content-Type can contain further content, like charset for example.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27622#comment:10>

Django

unread,
Mar 7, 2017, 11:01:00 AM3/7/17
to django-...@googlegroups.com
#27622: Test client should accept vendor tree json variants
-------------------------------------+-------------------------------------

Reporter: John Gresty | Owner: nobody
Type: New feature | Status: closed
Component: Testing framework | Version: master
Severity: Normal | Resolution: fixed
Keywords: json vendor | Triage Stage: Ready for
testing_client | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz <claude@…>):

In [changeset:"ca58a405fca0ddc5ce2cb3d022dec403df1a5031" ca58a405]:
{{{
#!CommitTicketReference repository=""
revision="ca58a405fca0ddc5ce2cb3d022dec403df1a5031"
[1.11.x] Refs #27622 -- Fixed a regression in JSON content-type detection

A JSON Content-Type can contain further content, like charset for example.

Backport of 145f6c3ed6e8856078e2d04ff2567e9fb4a17930 from master.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27622#comment:11>

Reply all
Reply to author
Forward
0 new messages