May 02, 2021 · $ python3 -m pip install boto3 moto pytest Overview of the Moto Library “Moto is a library that allows your tests to easily mock out AWS Services.” — moto on GitHub. Let’s create a main.py containing a simple function that creates EC2 instances: Moto is not limited to the EC2 service. It supports many other AWS services to mock out.
Boto3 reference. ¶. class boto3. NullHandler (level=0) [source] ¶. Initializes the instance - basically setting the formatter to None and the filter list to empty. Create a low-level service client by name using the default session. See boto3.session.Session.client (). Create a resource service client by name using the default session.
method (str) -- The name of the client method to stub. service_response (dict) -- A dict response stub. Provided parameters will be validated against the service model. expected_params-- A dictionary of the expected parameters to be called for the provided service response. The parameters match the names of keyword arguments passed to that ...
Running the Test with the Step Functions Docker Image. I personally recommend this way as it is much easier to reproduce the testing environment. This is the Dockerfile. FROM python:3.7 WORKDIR /app COPY ./my ./my COPY ./tests ./tests RUN pip install pytest pytest-stepfunctions pytest-mock boto3. and the docker-compose.yml for Docker Compose: