Skip to content

Commit

Permalink
test: add self contained test reporudicng the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
verysamuel committed Nov 28, 2023
1 parent 66ae12f commit 681e1d5
Showing 1 changed file with 51 additions and 1 deletion.
52 changes: 51 additions & 1 deletion tests/test_dynamodb/test_dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import pytest
import uuid
import re
import importlib
import sys
from botocore.exceptions import ClientError
from datetime import datetime
from decimal import Decimal
Expand Down Expand Up @@ -5749,7 +5751,7 @@ def test_projection_expression_with_binary_attr():
assert item["key"] == Binary(b"value\xbf")


@mock_dynamodb

def test_invalid_projection_expressions():
table_name = "test-projection-expressions-table"
client = boto3.client("dynamodb", region_name="us-east-1")
Expand Down Expand Up @@ -5807,3 +5809,51 @@ def test_invalid_projection_expressions():
ClientError, match="ProjectionExpression: Attribute name contains white space"
):
client.scan(TableName=table_name, ProjectionExpression="not_a_keyword, na me")


# https://github.com/getmoto/moto/pull/7073
def test_dynamo_type_assertion_exception_not_raised_when_reloading_modules():
importlib.reload(sys.modules["moto"])
to_reload = [module for module in sys.modules if module.startswith("moto.")]
for module in to_reload:
importlib.reload(sys.modules[module])

importlib.reload(sys.modules["moto"])
to_reload = [module for module in sys.modules if module.startswith("moto.")]
for module in to_reload:
importlib.reload(sys.modules[module])

mock_dynamo = mock_dynamodb()
mock_dynamo.start()
dynamo_client = boto3.client("dynamodb")
dynamo_client.create_table(
TableName="SomeTable",
AttributeDefinitions=[
{"AttributeName": "SomeKey", "AttributeType": "S"},
],
KeySchema=[
{"AttributeName": "SomeKey", "KeyType": "HASH"},
],
BillingMode="PAY_PER_REQUEST",
)

config_key = "SomeKeyValue"

dynamo_client.put_item(
TableName="SomeTable",
Item={
"SomeKey": {"S": config_key},
"ConfigValue": {"M": {"Some key": {"S": "Some value"}}},
},
)

dynamo_client.update_item(
TableName="SomeTable",
Key={
"SomeKey": {"S": config_key},
},
UpdateExpression="SET SomeValue = :some_value",
ExpressionAttributeValues={
":some_value": {"M": {"Some key": {"S": "Some new value"}}}
},
)

0 comments on commit 681e1d5

Please sign in to comment.