Skip to content

Commit 54fd27a

Browse files
author
Lucas McDonald
committed
m
1 parent b7e8a55 commit 54fd27a

File tree

5 files changed

+24
-41
lines changed

5 files changed

+24
-41
lines changed

DynamoDbEncryption/runtimes/python/docs/index.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ Modules
1414
aws_dbesdk_dynamodb.encrypted.item
1515
aws_dbesdk_dynamodb.encrypted.resource
1616
aws_dbesdk_dynamodb.encrypted.paginator
17-
aws_dbesdk_dynamodb.models
18-
aws_dbesdk_dynamodb.models.dynamodb
19-
aws_dbesdk_dynamodb.smithygenerated.aws_cryptography_dbencryptionsdk_dynamodb.models
20-
aws_dbesdk_dynamodb.smithygenerated.aws_cryptography_dbencryptionsdk_structuredencryption.models
21-
aws_dbesdk_dynamodb.smithygenerated.aws_cryptography_dbencryptionsdk_dynamodb_itemencryptor.models
22-
aws_dbesdk_dynamodb.smithygenerated.aws_cryptography_dbencryptionsdk_dynamodb_itemencryptor.config
17+
aws_dbesdk_dynamodb.structures
18+
aws_dbesdk_dynamodb.structures.dynamodb
19+
aws_dbesdk_dynamodb.structures.structured_encryption
20+
aws_dbesdk_dynamodb.structures.item_encryptor
2321

2422

2523
The content below applies to all languages of the AWS DBESDK for DynamoDB.

DynamoDbEncryption/runtimes/python/src/aws_dbesdk_dynamodb/models/dynamodb.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

DynamoDbEncryption/runtimes/python/src/aws_dbesdk_dynamodb/models/structured_encryption.py

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
5+
def sort_dynamodb_json_lists(obj):
6+
"""
7+
Utility that recursively sorts all lists in a DynamoDB JSON-like structure.
8+
DynamoDB JSON uses lists to represent sets, so strict equality can fail.
9+
Sort lists to ensure consistent ordering when comparing expected and actual items.
10+
"""
11+
if isinstance(obj, dict):
12+
return {k: sort_dynamodb_json_lists(v) for k, v in obj.items()}
13+
elif isinstance(obj, list):
14+
try:
15+
return sorted(obj) # Sort lists for consistent comparison
16+
except TypeError:
17+
return obj # Not all lists are sortable; ex. complex_item_ddb's "list" attribute
18+
return obj

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

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from aws_dbesdk_dynamodb.encrypted.client import EncryptedClient
88
from aws_dbesdk_dynamodb.encrypted.paginator import EncryptedPaginator
99

10+
from . import sort_dynamodb_json_lists
11+
1012
from ...constants import (
1113
INTEG_TEST_DEFAULT_DYNAMODB_TABLE_NAME,
1214
INTEG_TEST_DEFAULT_TABLE_CONFIGS,
@@ -153,23 +155,6 @@ def get_item_request(expect_standard_dictionaries, test_item):
153155
return {**basic_get_item_request_dict(test_item), "TableName": INTEG_TEST_DEFAULT_DYNAMODB_TABLE_NAME}
154156
return basic_get_item_request_ddb(test_item)
155157

156-
157-
def sort_dynamodb_json_lists(obj):
158-
"""
159-
Utility that recursively sorts all lists in a DynamoDB JSON-like structure.
160-
DynamoDB JSON uses lists to represent sets, so strict equality can fail.
161-
Sort lists to ensure consistent ordering when comparing expected and actual items.
162-
"""
163-
if isinstance(obj, dict):
164-
return {k: sort_dynamodb_json_lists(v) for k, v in obj.items()}
165-
elif isinstance(obj, list):
166-
try:
167-
return sorted(obj) # Sort lists for consistent comparison
168-
except TypeError:
169-
return obj # Not all lists are sortable; ex. complex_item_ddb's "list" attribute
170-
return obj
171-
172-
173158
def test_GIVEN_valid_put_and_get_requests_WHEN_put_and_get_THEN_round_trip_passes(
174159
client, put_item_request, get_item_request
175160
):

0 commit comments

Comments
 (0)