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 d6b0e16
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions 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 @@ -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])

Check failure on line 5819 in tests/test_dynamodb/test_dynamodb.py

View workflow job for this annotation

GitHub Actions / test / test (3.7)

test_dynamo_type_assertion_exception_not_raised_when_reloading_modules TypeError: super(type, obj): obj must be an instance or subtype of type

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

View workflow job for this annotation

GitHub Actions / test / test (3.8)

test_dynamo_type_assertion_exception_not_raised_when_reloading_modules botocore.exceptions.NoRegionError: You must specify a region.

Check failure on line 5828 in tests/test_dynamodb/test_dynamodb.py

View workflow job for this annotation

GitHub Actions / test / test (3.9)

test_dynamo_type_assertion_exception_not_raised_when_reloading_modules botocore.exceptions.NoRegionError: You must specify a region.

Check failure on line 5828 in tests/test_dynamodb/test_dynamodb.py

View workflow job for this annotation

GitHub Actions / test / test (3.12)

test_dynamo_type_assertion_exception_not_raised_when_reloading_modules botocore.exceptions.NoRegionError: You must specify a region.

Check failure on line 5828 in tests/test_dynamodb/test_dynamodb.py

View workflow job for this annotation

GitHub Actions / test / test (3.11)

test_dynamo_type_assertion_exception_not_raised_when_reloading_modules botocore.exceptions.NoRegionError: You must specify a region.

Check failure on line 5828 in tests/test_dynamodb/test_dynamodb.py

View workflow job for this annotation

GitHub Actions / test / test (3.10)

test_dynamo_type_assertion_exception_not_raised_when_reloading_modules botocore.exceptions.NoRegionError: You must specify a region.
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 d6b0e16

Please sign in to comment.