|
2 | 2 | import pytest |
3 | 3 | import uuid |
4 | 4 | import re |
| 5 | +import importlib |
| 6 | +import sys |
5 | 7 | from botocore.exceptions import ClientError |
6 | 8 | from datetime import datetime |
7 | 9 | from decimal import Decimal |
@@ -5749,7 +5751,7 @@ def test_projection_expression_with_binary_attr(): |
5749 | 5751 | assert item["key"] == Binary(b"value\xbf") |
5750 | 5752 |
|
5751 | 5753 |
|
5752 | | -@mock_dynamodb |
| 5754 | + |
5753 | 5755 | def test_invalid_projection_expressions(): |
5754 | 5756 | table_name = "test-projection-expressions-table" |
5755 | 5757 | client = boto3.client("dynamodb", region_name="us-east-1") |
@@ -5807,3 +5809,51 @@ def test_invalid_projection_expressions(): |
5807 | 5809 | ClientError, match="ProjectionExpression: Attribute name contains white space" |
5808 | 5810 | ): |
5809 | 5811 | 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