Skip to content

Commit

Permalink
Remove more DynamoDB2 references (getmoto#4933)
Browse files Browse the repository at this point in the history
  • Loading branch information
bblommers authored Mar 11, 2022
1 parent eed32a5 commit 382ff2b
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 47 deletions.
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def get_version():
)

# 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"]
Expand Down
8 changes: 4 additions & 4 deletions tests/test_apigateway/test_apigateway_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
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
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions tests/test_awslambda/test_lambda_eventsourcemapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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,
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from moto import (
mock_cloudformation,
mock_dynamodb2,
mock_dynamodb,
mock_s3,
mock_sns,
mock_sqs,
Expand Down Expand Up @@ -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")
Expand All @@ -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():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from moto import (
mock_autoscaling,
mock_cloudformation,
mock_dynamodb2,
mock_dynamodb,
mock_ec2,
mock_events,
mock_kms,
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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"}}},
Expand Down
4 changes: 2 additions & 2 deletions tests/test_core/test_mock_regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
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


Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_core/test_socket.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
38 changes: 19 additions & 19 deletions tests/test_dynamodb/exceptions/test_dynamodb_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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"}],
Expand All @@ -25,7 +25,7 @@
}


@mock_dynamodb2
@mock_dynamodb
def test_query_gsi_with_wrong_key_attribute_names_throws_exception():
item = {
"partitionKey": "pk-1",
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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")

Expand All @@ -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")
Expand All @@ -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")

Expand All @@ -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")

Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand All @@ -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")

Expand All @@ -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")

Expand All @@ -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"}],
Expand Down Expand Up @@ -502,7 +502,7 @@ def update_email_transact(email):
)


@mock_dynamodb2
@mock_dynamodb
def test_transact_write_items__too_many_transactions():
table_schema = {
"KeySchema": [{"AttributeName": "pk", "KeyType": "HASH"}],
Expand Down Expand Up @@ -534,7 +534,7 @@ def update_email_transact(email):
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:
Expand Down
14 changes: 7 additions & 7 deletions tests/test_dynamodb/exceptions/test_key_length_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
Loading

0 comments on commit 382ff2b

Please sign in to comment.