Skip to content

Commit 26c5b0f

Browse files
committed
Fix
1 parent 7163a5f commit 26c5b0f

File tree

3 files changed

+12
-24
lines changed

3 files changed

+12
-24
lines changed

DynamoDbEncryption/runtimes/python/test/integ/legacy/test_client.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,11 @@
4545
)
4646

4747

48-
# TODO: standard_dicts tests were failing with TypeError: __str__ returned non-string (type bytes)
49-
# Initial assumption is that some thing is wrong with my test setup.
5048
# Creates a matrix of tests for each value in param,
5149
# with a user-friendly string for test output:
5250
# expect_standard_dictionaries = True -> "standard_dicts"
5351
# expect_standard_dictionaries = False -> "ddb_json"
54-
# @pytest.fixture(params=[True, False], ids=["standard_dicts", "ddb_json"])
55-
@pytest.fixture(params=[False], ids=["ddb_json"])
52+
@pytest.fixture(params=[True, False], ids=["standard_dicts", "ddb_json"])
5653
def expect_standard_dictionaries(request):
5754
return request.param
5855

DynamoDbEncryption/runtimes/python/test/integ/legacy/test_paginator.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,11 @@
4242
)
4343

4444

45-
# TODO: standard_dicts tests were failing with TypeError: __str__ returned non-string (type bytes)
46-
# Initial assumption is that some thing is wrong with my test setup.
4745
# Creates a matrix of tests for each value in param,
4846
# with a user-friendly string for test output:
4947
# expect_standard_dictionaries = True -> "standard_dicts"
5048
# expect_standard_dictionaries = False -> "ddb_json"
51-
# @pytest.fixture(params=[True, False], ids=["standard_dicts", "ddb_json"])
52-
@pytest.fixture(params=[False], ids=["ddb_json"])
49+
@pytest.fixture(params=[True, False], ids=["standard_dicts", "ddb_json"])
5350
def expect_standard_dictionaries(request):
5451
return request.param
5552

DynamoDbEncryption/runtimes/python/test/integ/legacy/utils.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def create_legacy_encrypted_client(attribute_actions=None, expect_standard_dicti
5555
"""Create a legacy DynamoDB encrypted client."""
5656
cmp = AwsKmsCryptographicMaterialsProvider(key_id=INTEG_TEST_DEFAULT_KMS_KEY_ID)
5757
return LegacyEncryptedClient(
58-
client=boto3.client("dynamodb"),
58+
client=plaintext_client(expect_standard_dictionaries),
5959
materials_provider=cmp,
6060
attribute_actions=attribute_actions,
6161
expect_standard_dictionaries=expect_standard_dictionaries,
@@ -124,6 +124,14 @@ def create_encryption_config(legacy_encryptor=None, legacy_policy=None):
124124
return DynamoDbTablesEncryptionConfig(table_encryption_configs=table_configs)
125125

126126

127+
def plaintext_client(expect_standard_dictionaries):
128+
if expect_standard_dictionaries:
129+
client = boto3.resource("dynamodb").Table(INTEG_TEST_DEFAULT_DYNAMODB_TABLE_NAME).meta.client
130+
else:
131+
client = boto3.client("dynamodb")
132+
return client
133+
134+
127135
def encrypted_client_with_legacy_override(
128136
legacy_encryptor=None, legacy_policy=None, expect_standard_dictionaries=False
129137
):
@@ -132,7 +140,7 @@ def encrypted_client_with_legacy_override(
132140

133141
# Create the EncryptedClient
134142
return EncryptedClient(
135-
client=boto3.client("dynamodb"),
143+
client=plaintext_client(expect_standard_dictionaries),
136144
encryption_config=tables_config,
137145
expect_standard_dictionaries=expect_standard_dictionaries,
138146
)
@@ -159,17 +167,3 @@ def encrypted_resource_with_legacy_override(legacy_encryptor=None, legacy_policy
159167
resource=boto3.resource("dynamodb"),
160168
encryption_config=tables_config,
161169
)
162-
163-
164-
def cleanup_ddb_items(items):
165-
"""Delete DynamoDB items from the test table."""
166-
client = boto3.client("dynamodb")
167-
for item in items:
168-
try:
169-
client.delete_item(
170-
TableName=INTEG_TEST_DEFAULT_DYNAMODB_TABLE_NAME,
171-
Key={"partition_key": item["partition_key"], "sort_key": item["sort_key"]},
172-
)
173-
except Exception:
174-
# Ignore errors on cleanup
175-
pass

0 commit comments

Comments
 (0)