How to use the moto.mock_dynamodb2 function in moto

To help you get started, we’ve selected a few moto examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github botfront / rasa-for-botfront / tests / core / test_tracker_stores.py View on Github external
@mock_dynamodb2
def test_dynamo_get_or_create():
    get_or_create_tracker_store(DynamoTrackerStore(domain))
github whisller / pytest-serverless / pytest_serverless.py View on Github external
def _handle_dynamodb_table(resources):
    from moto import mock_dynamodb2

    dynamodb = mock_dynamodb2()

    def before():
        dynamodb.start()

        for resource_definition in resources:
            boto3.resource("dynamodb").create_table(
                **_get_property(
                    resource_definition["Properties"],
                    (
                        "TableName",
                        "AttributeDefinitions",
                        "KeySchema",
                        "LocalSecondaryIndexes",
                        "GlobalSecondaryIndexes",
                        "BillingMode",
                        "ProvisionedThroughput",
github rackerlabs / ebs_snapper / tests / test_clean.py View on Github external
@mock_dynamodb2
@mock_iam
@mock_sts
def test_clean_snapshots_tagged_timeout(mocker):
    """Test that we _DONT_ clean anything if runtime > 4 minutes"""
    # default settings
    region = 'us-east-1'
    mocks.create_dynamodb(region)
    ctx = utils.MockContext()
    ctx.set_remaining_time_in_millis(5)  # 5 millis remaining

    # create an instance and record the id
    instance_id = mocks.create_instances(region, count=1)[0]

    # setup the min # snaps for the instance
    config_data = {
        "match": {"instance-id": instance_id},
github ONSdigital / eq-survey-runner / tests / integration / integration_test_case.py View on Github external
def _set_up_app(self):
        self._ddb = mock_dynamodb2()
        self._ddb.start()

        from application import configure_logging
        configure_logging()

        setting_overrides = {
            'SQLALCHEMY_DATABASE_URI': 'sqlite://',
            'EQ_DYNAMODB_ENDPOINT': None
        }

        self._application = create_app(setting_overrides)

        self._key_store = KeyStore({
            'keys': {
                EQ_USER_AUTHENTICATION_RRM_PRIVATE_KEY_KID: {
                    'purpose': KEY_PURPOSE_AUTHENTICATION,
github spulec / moto / tests / test_dynamodb2 / test_dynamodb.py View on Github external
@mock_dynamodb2
def test_scan_filter3():
    client = boto3.client("dynamodb", region_name="us-east-1")
    dynamodb = boto3.resource("dynamodb", region_name="us-east-1")

    # Create the DynamoDB table.
    client.create_table(
        TableName="test1",
        AttributeDefinitions=[
            {"AttributeName": "client", "AttributeType": "S"},
            {"AttributeName": "app", "AttributeType": "N"},
        ],
        KeySchema=[
            {"AttributeName": "client", "KeyType": "HASH"},
            {"AttributeName": "app", "KeyType": "RANGE"},
        ],
        ProvisionedThroughput={"ReadCapacityUnits": 123, "WriteCapacityUnits": 123},
github spulec / moto / tests / test_dynamodb2 / test_dynamodb.py View on Github external
@mock_dynamodb2
def test_basic_projection_expressions():
    dynamodb = boto3.resource("dynamodb", region_name="us-east-1")

    # Create the DynamoDB table.
    table = dynamodb.create_table(
        TableName="users",
        KeySchema=[
            {"AttributeName": "forum_name", "KeyType": "HASH"},
            {"AttributeName": "subject", "KeyType": "RANGE"},
        ],
        AttributeDefinitions=[
            {"AttributeName": "forum_name", "AttributeType": "S"},
            {"AttributeName": "subject", "AttributeType": "S"},
        ],
        ProvisionedThroughput={"ReadCapacityUnits": 5, "WriteCapacityUnits": 5},
    )
github spulec / moto / tests / test_dynamodb2 / test_dynamodb.py View on Github external
@mock_dynamodb2
def test_get_item_returns_consumed_capacity():
    dynamodb = boto3.resource("dynamodb", region_name="us-east-1")

    # Create the DynamoDB table.
    table = dynamodb.create_table(
        TableName="users",
        KeySchema=[
            {"AttributeName": "forum_name", "KeyType": "HASH"},
            {"AttributeName": "subject", "KeyType": "RANGE"},
        ],
        AttributeDefinitions=[
            {"AttributeName": "forum_name", "AttributeType": "S"},
            {"AttributeName": "subject", "AttributeType": "S"},
        ],
        ProvisionedThroughput={"ReadCapacityUnits": 5, "WriteCapacityUnits": 5},
    )
github spulec / moto / tests / test_dynamodb2 / test_dynamodb.py View on Github external
@mock_dynamodb2
def test_basic_projection_expressions_using_scan_with_attr_expression_names():
    dynamodb = boto3.resource("dynamodb", region_name="us-east-1")

    # Create the DynamoDB table.
    table = dynamodb.create_table(
        TableName="users",
        KeySchema=[
            {"AttributeName": "forum_name", "KeyType": "HASH"},
            {"AttributeName": "subject", "KeyType": "RANGE"},
        ],
        AttributeDefinitions=[
            {"AttributeName": "forum_name", "AttributeType": "S"},
            {"AttributeName": "subject", "AttributeType": "S"},
        ],
        ProvisionedThroughput={"ReadCapacityUnits": 5, "WriteCapacityUnits": 5},
    )
github spulec / moto / tests / test_dynamodb2 / test_dynamodb.py View on Github external
@mock_dynamodb2
def test_condition_expressions():
    client = boto3.client("dynamodb", region_name="us-east-1")

    # Create the DynamoDB table.
    client.create_table(
        TableName="test1",
        AttributeDefinitions=[
            {"AttributeName": "client", "AttributeType": "S"},
            {"AttributeName": "app", "AttributeType": "S"},
        ],
        KeySchema=[
            {"AttributeName": "client", "KeyType": "HASH"},
            {"AttributeName": "app", "KeyType": "RANGE"},
        ],
        ProvisionedThroughput={"ReadCapacityUnits": 123, "WriteCapacityUnits": 123},
    )
github rackerlabs / ebs_snapper / tests / test_clean.py View on Github external
@mock_dynamodb2
@mock_iam
@mock_sts
def test_clean_tagged_snapshots_ignore_instance(mocker):
    """Test for method of the same name."""
    # default settings
    region = 'us-east-1'
    mocks.create_dynamodb(region)

    # create an instance and record the id
    instance_id = mocks.create_instances(region, count=1)[0]
    ctx = utils.MockContext()

    # setup the min # snaps for the instance
    config_data = {
        "match": {"instance-id": instance_id},
        "snapshot": {