Allow developers to define TestRequest URL params and body separately
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 346
- Forks
- 113
- PR merge metrics
- No merged PRs in 30d
Description
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.
response = self.testapp.put_json(url, params, body, headers, *args, **kwargs)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the TestApp put_json request helper and compare it with the GET and PUT examples in the issue. Determine how URL parameters and JSON body content are currently passed, then add separate support for both and verify that the URL query and request body remain distinct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100