Test API that receives content type 'multipart/form-data'
- Dominant language
- Python
- Stars
- 11.1k
- Forks
- 1k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 2
Description
Good evening,
In our application we have a lambda function that receives files. The lambda is declared as follows:
```
@upload_routes.route(routes_common.DATA_UPLOAD_ROUTE,
methods=['POST'],
content_types=['multipart/form-data'],
authorizer=authorizer,
cors=True)
```
I would like to implement a unit test for this lambda, as we have done for all the others.
However, I'm not sure about what is the right way of passing the files.
With the `request` library, I would use the parameter `files`. What's the best way of testing such lambda with the Caliche Client test class?
Thanks in advance!
Contributor guide
Research direction
Start with the Chalice Client test class and the multipart/form-data route declaration shown in the issue. Determine how the client accepts uploaded files, then confirm the approach with a unit test that exercises the lambda and verifies the received file content.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, testing
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100