Skip to content

Commit 6a99328

Browse files
author
Lucas McDonald
committed
m
1 parent a42e500 commit 6a99328

File tree

3 files changed

+41
-19
lines changed

3 files changed

+41
-19
lines changed

DynamoDbEncryption/runtimes/python/test/responses.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,20 +153,25 @@ def basic_transact_write_items_response(items):
153153
},
154154
}
155155

156+
156157
# No exhaustive response for transact_write_items;
157158
# The basic_transact_write_items_response is sufficient
158159

160+
159161
def basic_transact_get_items_response(items):
160162
"""Get a transact_get_items response in resource (ddb) format for any items."""
161163
return {"Responses": [{"Item": item} for item in items]}
162164

165+
163166
# No exhaustive response for transact_get_items;
164167
# The basic_transact_get_items_response is sufficient
165168

169+
166170
def basic_update_item_response(item):
167171
"""Get an update_item response in resource (ddb) format for any item."""
168172
return {"Attributes": item}
169173

174+
170175
def exhaustive_update_item_response(item):
171176
"""
172177
Get an update_item response in resource (ddb) format for any item.
@@ -182,10 +187,12 @@ def exhaustive_update_item_response(item):
182187
}
183188
return {**base, **additional_keys}
184189

190+
185191
def basic_delete_item_response(item):
186192
"""Get a delete_item response in resource (ddb) format for any item."""
187193
return {"Attributes": item}
188194

195+
189196
def exhaustive_delete_item_response(item):
190197
"""
191198
Get a delete_item response in resource (ddb) format for any item.
@@ -206,6 +213,7 @@ def basic_execute_statement_response(items):
206213
"""Get an execute_statement response in resource (ddb) format for any items."""
207214
return {"Items": items}
208215

216+
209217
def exhaustive_execute_statement_response(items):
210218
"""
211219
Get an execute_statement response in resource (ddb) format for any items.
@@ -222,17 +230,21 @@ def exhaustive_execute_statement_response(items):
222230
}
223231
return {**base, **additional_keys}
224232

233+
225234
def basic_execute_transaction_response(items):
226235
"""Get an execute_transaction response in resource (ddb) format for any items."""
227236
return {"Responses": [{"Item": item} for item in items]}
228237

238+
229239
# No exhaustive response for execute_transaction;
230240
# The basic_execute_transaction_response is sufficient
231241

242+
232243
def basic_batch_execute_statement_response(items):
233244
"""Get a batch_execute_statement response in resource (ddb) format for any items."""
234245
return {"Responses": [{"Item": item} for item in items]}
235246

247+
236248
def exhaustive_batch_execute_statement_response(items):
237249
"""
238250
Get a batch_execute_statement response in resource (ddb) format for any items.
@@ -247,4 +259,4 @@ def exhaustive_batch_execute_statement_response(items):
247259
"sort_key": items[0]["sort_key"],
248260
}
249261
}
250-
return base
262+
return base

DynamoDbEncryption/runtimes/python/test/unit/internal/test_client_to_resource.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,29 +55,29 @@
5555
exhaustive_scan_request_dict,
5656
)
5757
from ...responses import (
58+
basic_batch_execute_statement_response,
5859
basic_batch_get_item_response,
5960
basic_batch_write_item_put_response,
6061
basic_delete_item_response,
61-
exhaustive_delete_item_response,
62+
basic_execute_statement_response,
63+
basic_execute_transaction_response,
6264
basic_get_item_response,
6365
basic_put_item_response,
6466
basic_query_response,
6567
basic_scan_response,
6668
basic_transact_get_items_response,
6769
basic_transact_write_items_response,
6870
basic_update_item_response,
69-
exhaustive_update_item_response,
71+
exhaustive_batch_execute_statement_response,
7072
exhaustive_batch_get_item_response,
7173
exhaustive_batch_write_item_put_response,
74+
exhaustive_delete_item_response,
75+
exhaustive_execute_statement_response,
7276
exhaustive_get_item_response,
7377
exhaustive_put_item_response,
7478
exhaustive_query_response,
7579
exhaustive_scan_response,
76-
exhaustive_execute_statement_response,
77-
basic_execute_statement_response,
78-
basic_execute_transaction_response,
79-
basic_batch_execute_statement_response,
80-
exhaustive_batch_execute_statement_response,
80+
exhaustive_update_item_response,
8181
)
8282

8383
client_to_resource_converter = ClientShapeToResourceShapeConverter()
@@ -629,7 +629,9 @@ def test_execute_statement_response(use_exhaustive_request):
629629
return basic_execute_statement_response
630630

631631

632-
def test_GIVEN_test_execute_statement_response_WHEN_client_to_resource_THEN_returns_dict_value(test_execute_statement_response, test_ddb_item, test_dict_item):
632+
def test_GIVEN_test_execute_statement_response_WHEN_client_to_resource_THEN_returns_dict_value(
633+
test_execute_statement_response, test_ddb_item, test_dict_item
634+
):
633635
# Given: Execute statement response
634636
ddb_response = test_execute_statement_response([test_ddb_item])
635637
# When: Converting to resource format
@@ -653,12 +655,15 @@ def test_GIVEN_test_execute_transaction_request_WHEN_client_to_resource_THEN_ret
653655
# Then: Returns dict value (here, request is not modified)
654656
assert dict_item == test_execute_transaction_request(test_dict_item)
655657

658+
656659
@pytest.fixture
657660
def test_execute_transaction_response():
658661
return basic_execute_transaction_response
659662

660663

661-
def test_GIVEN_test_execute_transaction_response_WHEN_client_to_resource_THEN_returns_dict_value(test_execute_transaction_response, test_ddb_item, test_dict_item):
664+
def test_GIVEN_test_execute_transaction_response_WHEN_client_to_resource_THEN_returns_dict_value(
665+
test_execute_transaction_response, test_ddb_item, test_dict_item
666+
):
662667
# Given: Execute transaction response
663668
ddb_response = test_execute_transaction_response([test_ddb_item])
664669
# When: Converting to resource format
@@ -690,7 +695,9 @@ def test_batch_execute_statement_response(use_exhaustive_request):
690695
return basic_batch_execute_statement_response
691696

692697

693-
def test_GIVEN_test_batch_execute_statement_response_WHEN_client_to_resource_THEN_returns_dict_value(test_batch_execute_statement_response, test_ddb_item, test_dict_item):
698+
def test_GIVEN_test_batch_execute_statement_response_WHEN_client_to_resource_THEN_returns_dict_value(
699+
test_batch_execute_statement_response, test_ddb_item, test_dict_item
700+
):
694701
# Given: Batch execute statement response
695702
ddb_response = test_batch_execute_statement_response([test_ddb_item])
696703
# When: Converting to resource format

DynamoDbEncryption/runtimes/python/test/unit/internal/test_resource_to_client.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,29 +56,29 @@
5656
exhaustive_scan_request_dict,
5757
)
5858
from ...responses import (
59+
basic_batch_execute_statement_response,
5960
basic_batch_get_item_response,
6061
basic_batch_write_item_put_response,
6162
basic_delete_item_response,
62-
exhaustive_delete_item_response,
63+
basic_execute_statement_response,
64+
basic_execute_transaction_response,
6365
basic_get_item_response,
6466
basic_put_item_response,
6567
basic_query_response,
6668
basic_scan_response,
6769
basic_transact_get_items_response,
6870
basic_transact_write_items_response,
6971
basic_update_item_response,
70-
exhaustive_update_item_response,
72+
exhaustive_batch_execute_statement_response,
7173
exhaustive_batch_get_item_response,
7274
exhaustive_batch_write_item_put_response,
75+
exhaustive_delete_item_response,
76+
exhaustive_execute_statement_response,
7377
exhaustive_get_item_response,
7478
exhaustive_put_item_response,
7579
exhaustive_query_response,
7680
exhaustive_scan_response,
77-
exhaustive_execute_statement_response,
78-
basic_execute_statement_response,
79-
basic_execute_transaction_response,
80-
basic_batch_execute_statement_response,
81-
exhaustive_batch_execute_statement_response,
81+
exhaustive_update_item_response,
8282
)
8383

8484
resource_to_client_converter = ResourceShapeToClientShapeConverter(table_name=INTEG_TEST_DEFAULT_DYNAMODB_TABLE_NAME)
@@ -942,7 +942,9 @@ def test_GIVEN_test_execute_statement_response_WHEN_resource_to_client_THEN_retu
942942
actual_ddb_response = resource_to_client_converter.execute_statement_response(response)
943943
# Then: Returns dict value
944944
actual_ddb_response = sort_attribute_list_of_dynamodb_json_lists(actual_ddb_response, "Items")
945-
expected_ddb_response = sort_attribute_list_of_dynamodb_json_lists(test_execute_statement_response([test_ddb_item]), "Items")
945+
expected_ddb_response = sort_attribute_list_of_dynamodb_json_lists(
946+
test_execute_statement_response([test_ddb_item]), "Items"
947+
)
946948

947949
assert actual_ddb_response == expected_ddb_response
948950

@@ -967,6 +969,7 @@ def test_GIVEN_test_execute_transaction_request_WHEN_resource_to_client_THEN_ret
967969
def test_execute_transaction_response():
968970
return basic_execute_transaction_response
969971

972+
970973
def test_GIVEN_test_execute_transaction_response_WHEN_resource_to_client_THEN_returns_dict_value(
971974
test_execute_transaction_response, test_ddb_item, test_dict_item
972975
):

0 commit comments

Comments
 (0)