Skip to content

Commit 681e1d5

Browse files
committed
test: add self contained test reporudicng the issue
1 parent 66ae12f commit 681e1d5

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

tests/test_dynamodb/test_dynamodb.py

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import pytest
33
import uuid
44
import re
5+
import importlib
6+
import sys
57
from botocore.exceptions import ClientError
68
from datetime import datetime
79
from decimal import Decimal
@@ -5749,7 +5751,7 @@ def test_projection_expression_with_binary_attr():
57495751
assert item["key"] == Binary(b"value\xbf")
57505752

57515753

5752-
@mock_dynamodb
5754+
57535755
def test_invalid_projection_expressions():
57545756
table_name = "test-projection-expressions-table"
57555757
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -5807,3 +5809,51 @@ def test_invalid_projection_expressions():
58075809
ClientError, match="ProjectionExpression: Attribute name contains white space"
58085810
):
58095811
client.scan(TableName=table_name, ProjectionExpression="not_a_keyword, na me")
5812+
5813+
5814+
# https://github.com/getmoto/moto/pull/7073
5815+
def test_dynamo_type_assertion_exception_not_raised_when_reloading_modules():
5816+
importlib.reload(sys.modules["moto"])
5817+
to_reload = [module for module in sys.modules if module.startswith("moto.")]
5818+
for module in to_reload:
5819+
importlib.reload(sys.modules[module])
5820+
5821+
importlib.reload(sys.modules["moto"])
5822+
to_reload = [module for module in sys.modules if module.startswith("moto.")]
5823+
for module in to_reload:
5824+
importlib.reload(sys.modules[module])
5825+
5826+
mock_dynamo = mock_dynamodb()
5827+
mock_dynamo.start()
5828+
dynamo_client = boto3.client("dynamodb")
5829+
dynamo_client.create_table(
5830+
TableName="SomeTable",
5831+
AttributeDefinitions=[
5832+
{"AttributeName": "SomeKey", "AttributeType": "S"},
5833+
],
5834+
KeySchema=[
5835+
{"AttributeName": "SomeKey", "KeyType": "HASH"},
5836+
],
5837+
BillingMode="PAY_PER_REQUEST",
5838+
)
5839+
5840+
config_key = "SomeKeyValue"
5841+
5842+
dynamo_client.put_item(
5843+
TableName="SomeTable",
5844+
Item={
5845+
"SomeKey": {"S": config_key},
5846+
"ConfigValue": {"M": {"Some key": {"S": "Some value"}}},
5847+
},
5848+
)
5849+
5850+
dynamo_client.update_item(
5851+
TableName="SomeTable",
5852+
Key={
5853+
"SomeKey": {"S": config_key},
5854+
},
5855+
UpdateExpression="SET SomeValue = :some_value",
5856+
ExpressionAttributeValues={
5857+
":some_value": {"M": {"Some key": {"S": "Some new value"}}}
5858+
},
5859+
)

0 commit comments

Comments
 (0)