-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: assertion of DynamoType failing #7073
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -5807,3 +5809,51 @@ | |
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") | ||
Check failure on line 5828 in tests/test_dynamodb/test_dynamodb.py GitHub Actions / test / test (3.8)
Check failure on line 5828 in tests/test_dynamodb/test_dynamodb.py GitHub Actions / test / test (3.9)
Check failure on line 5828 in tests/test_dynamodb/test_dynamodb.py GitHub Actions / test / test (3.12)
Check failure on line 5828 in tests/test_dynamodb/test_dynamodb.py GitHub Actions / test / test (3.11)
|
||
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"}}} | ||
}, | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should stop the mock at the end: Not a big problem if you only run the one test, but if you run multiple tests and one mock is still active, it wreaks havoc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our CI does not have a region configured, so we have to specify it here explicitly