Skip to content

Commit

Permalink
Deprecate mock_dynamodb2 (#4919)
Browse files Browse the repository at this point in the history
  • Loading branch information
bblommers committed Mar 9, 2022
1 parent 9dccebc commit 07913cf
Show file tree
Hide file tree
Showing 58 changed files with 10,076 additions and 9,867 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ include moto/ec2/resources/instance_types.json
include moto/ec2/resources/instance_type_offerings/*/*.json
include moto/ec2/resources/amis.json
include moto/cognitoidp/resources/*.json
include moto/dynamodb2/parsing/reserved_keywords.txt
include moto/dynamodb/parsing/reserved_keywords.txt
include moto/ssm/resources/*.json
include moto/support/resources/*.json
recursive-include moto/moto_server *
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/services/dynamodb.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ dynamodb

.. sourcecode:: python

@mock_dynamodb2
def test_dynamodb2_behaviour:
@mock_dynamodb
def test_dynamodb_behaviour:
boto3.client("dynamodb")
...

Expand Down
10 changes: 6 additions & 4 deletions moto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def f(*args, **kwargs):
mock_budgets = lazy_load(".budgets", "mock_budgets")
mock_cloudformation = lazy_load(".cloudformation", "mock_cloudformation")
mock_cloudfront = lazy_load(".cloudfront", "mock_cloudfront")
mock_cloudtrail = lazy_load(".cloudtrail", "mock_cloudtrail", boto3_name="cloudtrail")
mock_cloudtrail = lazy_load(".cloudtrail", "mock_cloudtrail")
mock_cloudwatch = lazy_load(".cloudwatch", "mock_cloudwatch")
mock_codecommit = lazy_load(".codecommit", "mock_codecommit")
mock_codepipeline = lazy_load(".codepipeline", "mock_codepipeline")
Expand All @@ -67,9 +67,11 @@ def f(*args, **kwargs):
mock_datasync = lazy_load(".datasync", "mock_datasync")
mock_dax = lazy_load(".dax", "mock_dax")
mock_dms = lazy_load(".dms", "mock_dms")
mock_ds = lazy_load(".ds", "mock_ds", boto3_name="ds")
mock_dynamodb = lazy_load(".dynamodb", "mock_dynamodb", warn_repurpose=True)
mock_dynamodb2 = lazy_load(".dynamodb2", "mock_dynamodb2", backend="dynamodb_backends2")
mock_ds = lazy_load(".ds", "mock_ds")
mock_dynamodb = lazy_load(".dynamodb", "mock_dynamodb")
mock_dynamodb2 = lazy_load(
".dynamodb", "mock_dynamodb", use_instead=("mock_dynamodb2", "mock_dynamodb")
)
mock_dynamodbstreams = lazy_load(".dynamodbstreams", "mock_dynamodbstreams")
mock_elasticbeanstalk = lazy_load(
".elasticbeanstalk", "mock_elasticbeanstalk", backend="eb_backends"
Expand Down
4 changes: 2 additions & 2 deletions moto/awslambda/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
split_layer_arn,
)
from moto.sqs import sqs_backends
from moto.dynamodb2 import dynamodb_backends2
from moto.dynamodb import dynamodb_backends
from moto.dynamodbstreams import dynamodbstreams_backends
from moto.core import ACCOUNT_ID
from moto.utilities.docker_utilities import DockerModel, parse_image_ref
Expand Down Expand Up @@ -1259,7 +1259,7 @@ def create_event_source_mapping(self, spec):
esm = EventSourceMapping(spec)
self._event_source_mappings[esm.uuid] = esm
table_name = stream["TableName"]
table = dynamodb_backends2[self.region_name].get_table(table_name)
table = dynamodb_backends[self.region_name].get_table(table_name)
table.lambda_event_source_mappings[esm.function_arn] = esm
return esm
raise RESTError("ResourceNotFoundException", "Invalid EventSourceArn")
Expand Down
1 change: 1 addition & 0 deletions moto/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
]
decorator_functions = [getattr(moto, f) for f in decorators]
BACKENDS = {f.boto3_name: (f.name, f.backend) for f in decorator_functions}
BACKENDS["dynamodb_v20111205"] = ("dynamodb_v20111205", "dynamodb_backends")
BACKENDS["moto_api"] = ("core", "moto_api_backends")
BACKENDS["instance_metadata"] = ("instance_metadata", "instance_metadata_backends")
BACKENDS["s3bucket_path"] = ("s3", "s3_backends")
Expand Down
2 changes: 1 addition & 1 deletion moto/cloudformation/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from moto.cloudformation.custom_model import CustomModel
from moto.cloudwatch import models # noqa # pylint: disable=all
from moto.datapipeline import models # noqa # pylint: disable=all
from moto.dynamodb2 import models # noqa # pylint: disable=all
from moto.dynamodb import models # noqa # pylint: disable=all
from moto.ec2 import models as ec2_models
from moto.ecr import models # noqa # pylint: disable=all
from moto.ecs import models # noqa # pylint: disable=all
Expand Down
7 changes: 4 additions & 3 deletions moto/dynamodb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .models import dynamodb_backend
from moto.dynamodb.models import dynamodb_backends
from ..core.models import base_decorator

dynamodb_backends = {"global": dynamodb_backend}
mock_dynamodb = dynamodb_backend.decorator
dynamodb_backend = dynamodb_backends["us-east-1"]
mock_dynamodb = base_decorator(dynamodb_backends)
Loading

0 comments on commit 07913cf

Please sign in to comment.