MCPcopy Index your code
hub / github.com/getmoto/moto

github.com/getmoto/moto @5.2.2 sqlite

repository ↗ · DeepWiki ↗ · release 5.2.2 ↗
34,124 symbols 154,529 edges 2,562 files 1,982 documented · 6% 2 cross-repo links
README

Moto - Mock AWS Services

Join the chat at https://gitter.im/awsmoto/Lobby

Build Status Coverage Status Docs PyPI PyPI - Python Version PyPI - Downloads Code style: Ruff Financial Contributors

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.

Core symbols most depended-on inside this repo

get
called by 5679
moto/sdb/models.py
_get_param
called by 5485
moto/kms/responses.py
append
called by 1526
moto/route53/models.py
resource
called by 941
moto/stepfunctions/parser/asl/component/state/exec/state_map/item_reader/item_reader_decl.py
pop
called by 880
moto/s3/utils.py
uuid4
called by 795
moto/moto_api/_internal/moto_random.py
match
called by 662
moto/quicksight/utils.py
_get_param
called by 616
moto/core/responses.py

Shape

Method 18,804
Function 11,223
Class 3,984
Route 113

Languages

Python100%
Java1%
TypeScript1%
Go1%

Modules by API surface

moto/stepfunctions/parser/asl/antlr/runtime/ASLParser.py1,757 symbols
moto/rds/models.py365 symbols
moto/iam/models.py322 symbols
moto/stepfunctions/parser/asl/antlr/runtime/ASLParserListener.py313 symbols
moto/sagemaker/models.py312 symbols
moto/ec2/exceptions.py244 symbols
tests/test_cognitoidp/test_cognitoidp.py226 symbols
moto/iot/models.py225 symbols
moto/s3/models.py218 symbols
moto/apigateway/models.py211 symbols
moto/awslambda/models.py193 symbols
moto/glue/models.py185 symbols

Used by 2 indexed graphs manifest dependencies, hub-wide

Dependencies from manifests, versioned

github.com/aws/aws-sdk-go-v2v1.41.11 · 1×
github.com/aws/aws-sdk-go-v2/configv1.32.22 · 1×
github.com/aws/aws-sdk-go-v2/credentialsv1.19.21 · 1×
github.com/aws/aws-sdk-go-v2/feature/ec2/imdsv1.18.27 · 1×
github.com/aws/aws-sdk-go-v2/internal/configsourcesv1.4.27 · 1×
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2v2.7.27 · 1×
github.com/aws/aws-sdk-go-v2/internal/v4av1.4.28 · 1×
github.com/aws/aws-sdk-go-v2/service/dynamodbv1.57.8 · 1×
github.com/aws/aws-sdk-go-v2/service/dynamodbstreamsv1.32.20 · 1×
github.com/aws/aws-sdk-go-v2/service/eksv1.84.4 · 1×
github.com/aws/aws-sdk-go-v2/service/internal/accept-encodingv1.13.11 · 1×
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discoveryv1.12.4 · 1×

Datastores touched

myspecialdatabaseDatabase · 1 repos
(mysql)Database · 1 repos
cantcreatethisdatabasetwiceDatabase · 1 repos
defaultDatabase · 1 repos
existingdatabaseDatabase · 1 repos
my_database_nameDatabase · 1 repos
mydbDatabase · 1 repos
nosuchdatabaseDatabase · 1 repos

For agents

$ claude mcp add moto \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact