moto5.1.18
Published
A library that allows you to easily mock out tests based on AWS infrastructure
pip install moto
Package Downloads
Authors
Project URLs
Requires Python
>=3.9
Dependencies
- boto3
>=1.9.201 - botocore
!=1.35.45,!=1.35.46,>=1.20.88 - cryptography
>=35.0.0 - requests
>=2.5 - xmltodict
- werkzeug
!=2.2.0,!=2.2.1,>=0.5 - python-dateutil
<3.0.0,>=2.1 - responses
!=0.25.5,>=0.15.0 - Jinja2
>=2.10.1 - antlr4-python3-runtime
; extra == "all" - joserfc
>=0.9.0; extra == "all" - jsonpath_ng
; extra == "all" - docker
>=3.0.0; extra == "all" - graphql-core
; extra == "all" - PyYAML
>=5.1; extra == "all" - cfn-lint
>=0.40.0; extra == "all" - jsonschema
; extra == "all" - openapi-spec-validator
>=0.5.0; extra == "all" - pyparsing
>=3.0.7; extra == "all" - py-partiql-parser
==0.6.3; extra == "all" - aws-xray-sdk
!=0.96,>=0.93; extra == "all" - setuptools
; extra == "all" - multipart
; extra == "all" - antlr4-python3-runtime
; extra == "proxy" - joserfc
>=0.9.0; extra == "proxy" - jsonpath_ng
; extra == "proxy" - docker
>=2.5.1; extra == "proxy" - graphql-core
; extra == "proxy" - PyYAML
>=5.1; extra == "proxy" - cfn-lint
>=0.40.0; extra == "proxy" - openapi-spec-validator
>=0.5.0; extra == "proxy" - pyparsing
>=3.0.7; extra == "proxy" - py-partiql-parser
==0.6.3; extra == "proxy" - aws-xray-sdk
!=0.96,>=0.93; extra == "proxy" - setuptools
; extra == "proxy" - multipart
; extra == "proxy" - antlr4-python3-runtime
; extra == "server" - joserfc
>=0.9.0; extra == "server" - jsonpath_ng
; extra == "server" - docker
>=3.0.0; extra == "server" - graphql-core
; extra == "server" - PyYAML
>=5.1; extra == "server" - cfn-lint
>=0.40.0; extra == "server" - openapi-spec-validator
>=0.5.0; extra == "server" - pyparsing
>=3.0.7; extra == "server" - py-partiql-parser
==0.6.3; extra == "server" - aws-xray-sdk
!=0.96,>=0.93; extra == "server" - setuptools
; extra == "server" - flask
!=2.2.0,!=2.2.1; extra == "server" - flask-cors
; extra == "server" - PyYAML
>=5.1; extra == "apigateway" - joserfc
>=0.9.0; extra == "apigateway" - openapi-spec-validator
>=0.5.0; extra == "apigateway" - PyYAML
>=5.1; extra == "apigatewayv2" - openapi-spec-validator
>=0.5.0; extra == "apigatewayv2" - graphql-core
; extra == "appsync" - docker
>=3.0.0; extra == "awslambda" - docker
>=3.0.0; extra == "batch" - joserfc
>=0.9.0; extra == "cloudformation" - docker
>=3.0.0; extra == "cloudformation" - graphql-core
; extra == "cloudformation" - PyYAML
>=5.1; extra == "cloudformation" - cfn-lint
>=0.40.0; extra == "cloudformation" - openapi-spec-validator
>=0.5.0; extra == "cloudformation" - pyparsing
>=3.0.7; extra == "cloudformation" - py-partiql-parser
==0.6.3; extra == "cloudformation" - aws-xray-sdk
!=0.96,>=0.93; extra == "cloudformation" - setuptools
; extra == "cloudformation" - joserfc
>=0.9.0; extra == "cognitoidp" - docker
>=3.0.0; extra == "dynamodb" - py-partiql-parser
==0.6.3; extra == "dynamodb" - docker
>=3.0.0; extra == "dynamodbstreams" - py-partiql-parser
==0.6.3; extra == "dynamodbstreams" - jsonpath_ng
; extra == "events" - pyparsing
>=3.0.7; extra == "glue" - jsonschema
; extra == "quicksight" - joserfc
>=0.9.0; extra == "resourcegroupstaggingapi" - docker
>=3.0.0; extra == "resourcegroupstaggingapi" - graphql-core
; extra == "resourcegroupstaggingapi" - PyYAML
>=5.1; extra == "resourcegroupstaggingapi" - cfn-lint
>=0.40.0; extra == "resourcegroupstaggingapi" - openapi-spec-validator
>=0.5.0; extra == "resourcegroupstaggingapi" - pyparsing
>=3.0.7; extra == "resourcegroupstaggingapi" - py-partiql-parser
==0.6.3; extra == "resourcegroupstaggingapi" - PyYAML
>=5.1; extra == "s3" - py-partiql-parser
==0.6.3; extra == "s3" - PyYAML
>=5.1; extra == "s3crc32c" - py-partiql-parser
==0.6.3; extra == "s3crc32c" - crc32c
; extra == "s3crc32c" - PyYAML
>=5.1; extra == "ssm" - antlr4-python3-runtime
; extra == "stepfunctions" - jsonpath_ng
; extra == "stepfunctions" - aws-xray-sdk
!=0.96,>=0.93; extra == "xray" - setuptools
; extra == "xray"
Moto - Mock AWS Services
Install
$ pip install 'moto[ec2,s3,all]'
In a nutshell
Moto is a library that allows your tests to easily mock out AWS Services.
Imagine you have the following python code that you want to test:
import boto3
class MyModel:
def __init__(self, name, value):
self.name = name
self.value = value
def save(self):
s3 = boto3.client("s3", region_name="us-east-1")
s3.put_object(Bucket="mybucket", Key=self.name, Body=self.value)
Take a minute to think how you would have tested that in the past.
Now see how you could test it with Moto:
import boto3
from moto import mock_aws
from mymodule import MyModel
@mock_aws
def test_my_model_save():
conn = boto3.resource("s3", region_name="us-east-1")
# We need to create the bucket since this is all in Moto's 'virtual' AWS account
conn.create_bucket(Bucket="mybucket")
model_instance = MyModel("steve", "is awesome")
model_instance.save()
body = conn.Object("mybucket", "steve").get()["Body"].read().decode("utf-8")
assert body == "is awesome"
With the decorator wrapping the test, all the calls to s3 are automatically mocked out. The mock keeps track of the state of the buckets and keys.
For a full list of which services and features are covered, please see our implementation coverage.
Documentation
The full documentation can be found here:
http://docs.getmoto.org/en/latest/
Financial Contributions
Support this project and its continued development, by sponsoring us!
Click the Sponsor-button at the top of the page for more information.
Our finances are managed by OpenCollective, which means you have full visibility into all our contributions and expenses: https://opencollective.com/moto
Security contact information
To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.