diff --git a/setup.py b/setup.py index b5e56763f..48b31efd7 100755 --- a/setup.py +++ b/setup.py @@ -102,7 +102,8 @@ extras_per_service.update( ) # When a Table has a Stream, we'll always need to import AWSLambda to search for a corresponding function to send the table data to -extras_per_service["dynamodb2"] = extras_per_service["awslambda"] +extras_per_service["dynamodb"] = extras_per_service["awslambda"] +extras_per_service["dynamodb2"] = extras_per_service["dynamodb"] extras_per_service["dynamodbstreams"] = extras_per_service["awslambda"] # EFS depends on EC2 to find subnets etc extras_per_service["efs"] = extras_per_service["ec2"] diff --git a/tests/test_apigateway/test_apigateway_integration.py b/tests/test_apigateway/test_apigateway_integration.py index 315122816..d58b87738 100644 --- a/tests/test_apigateway/test_apigateway_integration.py +++ b/tests/test_apigateway/test_apigateway_integration.py @@ -2,7 +2,7 @@ import boto3 import json import requests -from moto import mock_apigateway, mock_dynamodb2 +from moto import mock_apigateway, mock_dynamodb from moto import settings from moto.core.models import responses_mock from unittest import SkipTest @@ -54,7 +54,7 @@ def test_http_integration(): @mock_apigateway -@mock_dynamodb2 +@mock_dynamodb def test_aws_integration_dynamodb(): if settings.TEST_SERVER_MODE: raise SkipTest("Cannot test mock of execute-api.apigateway in ServerMode") @@ -79,7 +79,7 @@ def test_aws_integration_dynamodb(): @mock_apigateway -@mock_dynamodb2 +@mock_dynamodb def test_aws_integration_dynamodb_multiple_stages(): if settings.TEST_SERVER_MODE: raise SkipTest("Cannot test mock of execute-api.apigateway in ServerMode") @@ -116,7 +116,7 @@ def test_aws_integration_dynamodb_multiple_stages(): @mock_apigateway -@mock_dynamodb2 +@mock_dynamodb def test_aws_integration_dynamodb_multiple_resources(): if settings.TEST_SERVER_MODE: raise SkipTest("Cannot test mock of execute-api.apigateway in ServerMode") diff --git a/tests/test_awslambda/test_lambda_eventsourcemapping.py b/tests/test_awslambda/test_lambda_eventsourcemapping.py index 0239af3d6..c8eae48e1 100644 --- a/tests/test_awslambda/test_lambda_eventsourcemapping.py +++ b/tests/test_awslambda/test_lambda_eventsourcemapping.py @@ -6,7 +6,7 @@ import time import sure # noqa # pylint: disable=unused-import import uuid -from moto import mock_dynamodb2, mock_lambda, mock_logs, mock_sns, mock_sqs +from moto import mock_dynamodb, mock_lambda, mock_logs, mock_sns, mock_sqs from uuid import uuid4 from .utilities import ( get_role_name, @@ -97,7 +97,7 @@ def test_invoke_function_from_sqs(key): @pytest.mark.network @mock_logs @mock_lambda -@mock_dynamodb2 +@mock_dynamodb def test_invoke_function_from_dynamodb_put(): dynamodb = boto3.client("dynamodb", region_name="us-east-1") table_name = str(uuid4())[0:6] + "_table" @@ -148,7 +148,7 @@ def test_invoke_function_from_dynamodb_put(): @pytest.mark.network @mock_logs @mock_lambda -@mock_dynamodb2 +@mock_dynamodb def test_invoke_function_from_dynamodb_update(): dynamodb = boto3.client("dynamodb", region_name="us-east-1") table_name = str(uuid4())[0:6] + "_table" diff --git a/tests/test_cloudformation/test_cloudformation_stack_crud_boto3.py b/tests/test_cloudformation/test_cloudformation_stack_crud_boto3.py index c2faff78f..5dd731ae2 100644 --- a/tests/test_cloudformation/test_cloudformation_stack_crud_boto3.py +++ b/tests/test_cloudformation/test_cloudformation_stack_crud_boto3.py @@ -14,7 +14,7 @@ from unittest import SkipTest from moto import ( mock_cloudformation, - mock_dynamodb2, + mock_dynamodb, mock_s3, mock_sns, mock_sqs, @@ -2113,7 +2113,7 @@ def test_boto3_create_duplicate_stack(): cf_conn.create_stack(StackName="test_stack", TemplateBody=dummy_template_json) -@mock_dynamodb2 +@mock_dynamodb @mock_cloudformation def test_delete_stack_dynamo_template(): conn = boto3.client("cloudformation", region_name="us-east-1") @@ -2127,7 +2127,7 @@ def test_delete_stack_dynamo_template(): conn.create_stack(StackName="test_stack", TemplateBody=dummy_template_json4) -@mock_dynamodb2 +@mock_dynamodb @mock_cloudformation @mock_lambda def test_create_stack_lambda_and_dynamodb(): diff --git a/tests/test_cloudformation/test_cloudformation_stack_integration.py b/tests/test_cloudformation/test_cloudformation_stack_integration.py index 5608ad858..ee64f2f10 100644 --- a/tests/test_cloudformation/test_cloudformation_stack_integration.py +++ b/tests/test_cloudformation/test_cloudformation_stack_integration.py @@ -13,7 +13,7 @@ from string import Template from moto import ( mock_autoscaling, mock_cloudformation, - mock_dynamodb2, + mock_dynamodb, mock_ec2, mock_events, mock_kms, @@ -986,7 +986,7 @@ def test_stack_elbv2_resources_integration(): name["OutputValue"].should.equal(load_balancers[0]["LoadBalancerName"]) -@mock_dynamodb2 +@mock_dynamodb @mock_cloudformation def test_stack_dynamodb_resources_integration(): dynamodb_template = { @@ -1628,7 +1628,7 @@ def test_stack_events_get_attribute_integration(): @mock_cloudformation -@mock_dynamodb2 +@mock_dynamodb def test_dynamodb_table_creation(): CFN_TEMPLATE = { "Outputs": {"MyTableName": {"Value": {"Ref": "MyTable"}}}, diff --git a/tests/test_core/test_mock_regions.py b/tests/test_core/test_mock_regions.py index 6a389fae4..8123ad7cd 100644 --- a/tests/test_core/test_mock_regions.py +++ b/tests/test_core/test_mock_regions.py @@ -2,7 +2,7 @@ import boto3 import mock import os import pytest -from moto import mock_dynamodb2, mock_sns, settings +from moto import mock_dynamodb, mock_sns, settings from unittest import SkipTest @@ -44,7 +44,7 @@ def test_use_unknown_region_from_env_but_allow_it(): client.list_platform_applications()["PlatformApplications"].should.equal([]) -@mock_dynamodb2 +@mock_dynamodb @mock.patch.dict(os.environ, {"MOTO_ALLOW_NONEXISTENT_REGION": "trUe"}) def test_use_unknown_region_from_env_but_allow_it__dynamo(): if settings.TEST_SERVER_MODE: diff --git a/tests/test_core/test_socket.py b/tests/test_core/test_socket.py index c0ad836aa..f3ade2096 100644 --- a/tests/test_core/test_socket.py +++ b/tests/test_core/test_socket.py @@ -1,10 +1,10 @@ import unittest -from moto import mock_dynamodb2 +from moto import mock_dynamodb import socket class TestSocketPair(unittest.TestCase): - @mock_dynamodb2 + @mock_dynamodb def test_socket_pair(self): a, b = socket.socketpair() self.assertIsNotNone(a) diff --git a/tests/test_dynamodb/exceptions/test_dynamodb_exceptions.py b/tests/test_dynamodb/exceptions/test_dynamodb_exceptions.py index 62c400a67..79445926a 100644 --- a/tests/test_dynamodb/exceptions/test_dynamodb_exceptions.py +++ b/tests/test_dynamodb/exceptions/test_dynamodb_exceptions.py @@ -3,7 +3,7 @@ import pytest import sure # noqa # pylint: disable=unused-import from boto3.dynamodb.conditions import Key from botocore.exceptions import ClientError -from moto import mock_dynamodb2 +from moto import mock_dynamodb table_schema = { "KeySchema": [{"AttributeName": "partitionKey", "KeyType": "HASH"}], @@ -25,7 +25,7 @@ table_schema = { } -@mock_dynamodb2 +@mock_dynamodb def test_query_gsi_with_wrong_key_attribute_names_throws_exception(): item = { "partitionKey": "pk-1", @@ -98,7 +98,7 @@ def test_query_gsi_with_wrong_key_attribute_names_throws_exception(): ) -@mock_dynamodb2 +@mock_dynamodb def test_empty_expressionattributenames(): ddb = boto3.resource("dynamodb", region_name="us-east-1") ddb.create_table( @@ -114,7 +114,7 @@ def test_empty_expressionattributenames(): ) -@mock_dynamodb2 +@mock_dynamodb def test_empty_expressionattributenames_with_empty_projection(): ddb = boto3.resource("dynamodb", region_name="us-east-1") ddb.create_table( @@ -130,7 +130,7 @@ def test_empty_expressionattributenames_with_empty_projection(): err["Message"].should.equal("ExpressionAttributeNames must not be empty") -@mock_dynamodb2 +@mock_dynamodb def test_empty_expressionattributenames_with_projection(): ddb = boto3.resource("dynamodb", region_name="us-east-1") ddb.create_table( @@ -146,7 +146,7 @@ def test_empty_expressionattributenames_with_projection(): err["Message"].should.equal("ExpressionAttributeNames must not be empty") -@mock_dynamodb2 +@mock_dynamodb def test_update_item_range_key_set(): ddb = boto3.resource("dynamodb", region_name="us-east-1") @@ -168,7 +168,7 @@ def test_update_item_range_key_set(): ) -@mock_dynamodb2 +@mock_dynamodb def test_batch_get_item_non_existing_table(): client = boto3.client("dynamodb", region_name="us-west-2") @@ -180,7 +180,7 @@ def test_batch_get_item_non_existing_table(): assert err["Message"].should.equal("Requested resource not found") -@mock_dynamodb2 +@mock_dynamodb def test_batch_write_item_non_existing_table(): client = boto3.client("dynamodb", region_name="us-west-2") @@ -194,7 +194,7 @@ def test_batch_write_item_non_existing_table(): assert err["Message"].should.equal("Requested resource not found") -@mock_dynamodb2 +@mock_dynamodb def test_create_table_with_redundant_attributes(): dynamodb = boto3.client("dynamodb", region_name="us-east-1") @@ -241,7 +241,7 @@ def test_create_table_with_redundant_attributes(): ) -@mock_dynamodb2 +@mock_dynamodb def test_create_table_with_missing_attributes(): dynamodb = boto3.client("dynamodb", region_name="us-east-1") @@ -284,7 +284,7 @@ def test_create_table_with_missing_attributes(): ) -@mock_dynamodb2 +@mock_dynamodb def test_create_table_with_redundant_and_missing_attributes(): dynamodb = boto3.client("dynamodb", region_name="us-east-1") @@ -327,7 +327,7 @@ def test_create_table_with_redundant_and_missing_attributes(): ) -@mock_dynamodb2 +@mock_dynamodb def test_put_item_wrong_attribute_type(): dynamodb = boto3.client("dynamodb", region_name="us-east-1") @@ -373,7 +373,7 @@ def test_put_item_wrong_attribute_type(): ) -@mock_dynamodb2 +@mock_dynamodb # https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Query.html#DDB-Query-request-KeyConditionExpression def test_hash_key_cannot_use_begins_with_operations(): dynamodb = boto3.resource("dynamodb", region_name="us-east-1") @@ -404,7 +404,7 @@ def test_hash_key_cannot_use_begins_with_operations(): # Test this again, but with manually supplying an operator -@mock_dynamodb2 +@mock_dynamodb @pytest.mark.parametrize("operator", ["<", "<=", ">", ">="]) def test_hash_key_can_only_use_equals_operations(operator): dynamodb = boto3.resource("dynamodb", region_name="us-east-1") @@ -426,7 +426,7 @@ def test_hash_key_can_only_use_equals_operations(operator): err["Message"].should.equal("Query key condition not supported") -@mock_dynamodb2 +@mock_dynamodb def test_creating_table_with_0_local_indexes(): dynamodb = boto3.resource("dynamodb", region_name="us-east-1") @@ -445,7 +445,7 @@ def test_creating_table_with_0_local_indexes(): ) -@mock_dynamodb2 +@mock_dynamodb def test_creating_table_with_0_global_indexes(): dynamodb = boto3.resource("dynamodb", region_name="us-east-1") @@ -464,7 +464,7 @@ def test_creating_table_with_0_global_indexes(): ) -@mock_dynamodb2 +@mock_dynamodb def test_multiple_transactions_on_same_item(): table_schema = { "KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}], @@ -502,7 +502,7 @@ def test_multiple_transactions_on_same_item(): ) -@mock_dynamodb2 +@mock_dynamodb def test_transact_write_items__too_many_transactions(): table_schema = { "KeySchema": [{"AttributeName": "pk", "KeyType": "HASH"}], @@ -534,7 +534,7 @@ def test_transact_write_items__too_many_transactions(): err["Message"].should.match("Member must have length less than or equal to 25") -@mock_dynamodb2 +@mock_dynamodb def test_update_item_non_existent_table(): client = boto3.client("dynamodb", region_name="us-west-2") with pytest.raises(client.exceptions.ResourceNotFoundException) as exc: diff --git a/tests/test_dynamodb/exceptions/test_key_length_exceptions.py b/tests/test_dynamodb/exceptions/test_key_length_exceptions.py index d3623c008..6b04c7c05 100644 --- a/tests/test_dynamodb/exceptions/test_key_length_exceptions.py +++ b/tests/test_dynamodb/exceptions/test_key_length_exceptions.py @@ -4,12 +4,12 @@ import boto3 import sure # noqa # pylint: disable=unused-import import pytest -from moto import mock_dynamodb2 +from moto import mock_dynamodb from botocore.exceptions import ClientError from moto.dynamodb.limits import HASH_KEY_MAX_LENGTH, RANGE_KEY_MAX_LENGTH -@mock_dynamodb2 +@mock_dynamodb def test_item_add_long_string_hash_key_exception(): name = "TestTable" conn = boto3.client("dynamodb", region_name="us-west-2") @@ -50,7 +50,7 @@ def test_item_add_long_string_hash_key_exception(): ) -@mock_dynamodb2 +@mock_dynamodb def test_item_add_long_string_nonascii_hash_key_exception(): name = "TestTable" conn = boto3.client("dynamodb", region_name="us-west-2") @@ -97,7 +97,7 @@ def test_item_add_long_string_nonascii_hash_key_exception(): ) -@mock_dynamodb2 +@mock_dynamodb def test_item_add_long_string_range_key_exception(): name = "TestTable" conn = boto3.client("dynamodb", region_name="us-west-2") @@ -144,7 +144,7 @@ def test_item_add_long_string_range_key_exception(): ) -@mock_dynamodb2 +@mock_dynamodb def test_put_long_string_gsi_range_key_exception(): name = "TestTable" conn = boto3.client("dynamodb", region_name="us-west-2") @@ -213,7 +213,7 @@ def test_put_long_string_gsi_range_key_exception(): ) -@mock_dynamodb2 +@mock_dynamodb def test_update_item_with_long_string_hash_key_exception(): name = "TestTable" conn = boto3.client("dynamodb", region_name="us-west-2") @@ -253,7 +253,7 @@ def test_update_item_with_long_string_hash_key_exception(): ) -@mock_dynamodb2 +@mock_dynamodb def test_update_item_with_long_string_range_key_exception(): name = "TestTable" conn = boto3.client("dynamodb", region_name="us-west-2") diff --git a/tests/test_xray/test_xray_client.py b/tests/test_xray/test_xray_client.py index 7307ca08b..69e1cb006 100644 --- a/tests/test_xray/test_xray_client.py +++ b/tests/test_xray/test_xray_client.py @@ -1,4 +1,4 @@ -from moto import mock_xray_client, XRaySegment, mock_dynamodb2 +from moto import mock_xray_client, XRaySegment, mock_dynamodb import sure # noqa # pylint: disable=unused-import import boto3 @@ -19,7 +19,7 @@ original_session_prep_request = requests.Session.prepare_request @mock_xray_client -@mock_dynamodb2 +@mock_dynamodb def test_xray_dynamo_request_id(): # Could be ran in any order, so we need to tell sdk that its been unpatched xray_core_patcher._PATCHED_MODULES = set() @@ -48,7 +48,7 @@ def test_xray_dynamo_request_id(): def test_xray_dynamo_request_id_with_context_mgr(): with mock_xray_client(): assert isinstance(xray_core.xray_recorder._emitter, MockEmitter) - with mock_dynamodb2(): + with mock_dynamodb(): # Could be ran in any order, so we need to tell sdk that its been unpatched xray_core_patcher._PATCHED_MODULES = set() xray_core.patch_all()