'How to use fixture when testing Serverless locally with FastAPI?
I am testing a few endpoints written with FastAPI. I wrote tests for commands and queries using pytest with a dynamoDB table from a fixture that I had written, and it works.
However, now that I want to test the endpoints with an example test_event.json (I need the requestContext field) with the command:
serverless invoke local --function API --path test_event.json
I get the following error:
botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the Query operation: The table does not have the specified index: GS1PK-GS1SK-index
So, obviously the DynamoDB table was not loaded. Anyone has an idea how to use the fixtures in this case?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
