#27622 closed New feature (fixed)
Test client should accept vendor tree json variants
Reported by: | John Gresty | Owned by: | nobody |
---|---|---|---|
Component: | Testing framework | Version: | dev |
Severity: | Normal | Keywords: | json vendor testing_client |
Cc: | desecho@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
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/"
Change History (11)
comment:1 by , 8 years ago
Keywords: | vendor added; jsonp json_api removed |
---|
follow-up: 3 comment:2 by , 8 years ago
comment:3 by , 8 years ago
Replying to 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'
comment:4 by , 8 years ago
Triage Stage: | Unreviewed → Accepted |
---|
Thanks, I guess it's okay to accept application/json
variants then. I didn't verify your regex is correct.
comment:5 by , 8 years ago
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).
comment:7 by , 8 years ago
Summary: | Testing client should accept vendor tree json variants → Test client should accept vendor tree json variants |
---|---|
Triage Stage: | Accepted → Ready for checkin |
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?