-
Notifications
You must be signed in to change notification settings - Fork 16
Service should only accept application/json content-types. #667
Conversation
af5c697
to
486dbe1
Compare
@ayusharma Can you validate that this branch fixes your issue? There are tests here to validate the integration with Kinto. |
r? @almet |
C'est bien. |
Few questions:
|
Functionalities: Woking. Test Case: 1 Fail for python2.7 and Errors for Python 3 Take a look at error trace : http://pastebin.com/f4YfNeZP |
@@ -28,12 +28,27 @@ class ViewSet(object): | |||
|
|||
readonly_methods = ('GET', 'OPTIONS', 'HEAD') | |||
|
|||
content_types = ["application/json"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is not used at the class level, I would suggest not to define it here but in a constant (repeating is even acceptable IMO).
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One may want to accept xml for his service, that's the reason why I added this configuration here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh you mean that it won't actually work if we update the content_type property.
It looks good to me! Do not hesitate to define new errors if no one matches (invalid parameter seems ok to me but I understand it's not very precise) Theorically we should test very http method on both collection/record enpoints (motto no code should be here if no test fails when it's removed). But it's acceptable to leave it like you did. If you could go a bit further with:
would be great :) |
It seems to me that the http code is sufficient in that case. Don't you? |
r+ |
…nt_type Service should only accept application/json content-types.
Didn't read the context here yet, but you referenced Cornices/cornice#343 here. Will have a look into that. |
At first I though that I could use function based content-type to return application/json in case it was post/put/patch and None in case it was the other methods. Finally I did it differently in Cliquet. @amotl Do you think you could add a failing test in cornice? |
Refs: Kinto/kinto#461