March 2019
Intermediate to advanced
168 pages
4h 33m
English
There is a Python AWS mocking framework called Moto (http://docs.getmoto.org/en/latest/), but I prefer to use a generic one called mock, which is much more widely supported in the Python community and from Python 3.3 is included in the Python standard library.
The following mocking code can be found at the bottom of serverless-microservice-data-api/test/test_dynamo_get.py:
from unittest import mock mock.patch.object(lambda_query_dynamo.DynamoRepository, "query_by_partition_key", return_value=['item']) def test_validid_checkstatus_status200(self, mock_query_by_partition_key): result = lambda_query_dynamo.Controller.get_dynamodb_records( self.validJsonDataNoStartDate) assert result['statusCode'] == '200' @mock.patch.object(lambda_query_dynamo.DynamoRepository, ...
Read now
Unlock full access