You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Webtest seems to confuse URL parameters and body content when creating JSON requests.
For example:
# Test GET /api/photos?id=10
response = self.testapp.get('/api/photos/', {'id': 10})
# If I want to test PUT /api/photos?id=10 I have to do this:
response = self.testapp.put_json('/api/photos?id=10', {'title': 'Different title'})
# Because the following will PUT to /api/photos and will serialize id=10 in the JSON body.
response = self.testapp.put_json('/api/photos', {'id': 10, 'title': 'Different title'})
In my request handlers, request.get and request.json.get are not equivalent. Example:
def put(self):
# Get the id from the URL params.
id_param = self.request.get('id')
# Get the id from the JSON body.
id_val = self.request.json.get('id')
It'd be fantastic if webtest supported both as separate options.
It looks like I may have confused myself about the expectations of parameters in GET vs POST requests. WebOb also offers Request.params which is a combination of the query string and request body. This seems like confusing behavior to me since there's potential for overlap, but I'm willing to admit that I misunderstood it.
I agree that /things/?id=10 doesn’t follow common best practices that would recomment /things/10. But I also think that HTTP lets you have both a query string in the URI and a request body.
Webtest seems to confuse URL parameters and body content when creating JSON requests.
For example:
In my request handlers,
request.get
andrequest.json.get
are not equivalent. Example:It'd be fantastic if webtest supported both as separate options.
The text was updated successfully, but these errors were encountered: