1010)
1111
1212# Base request structures that are shared between DDB and dict formats
13+ # Use ConsistentRead: True for all requests;
14+ # many of these are used in integ tests, where consistent reads reduce test flakiness.
1315
1416
1517def base_put_item_request (item ):
@@ -19,7 +21,7 @@ def base_put_item_request(item):
1921
2022def base_get_item_request (item ):
2123 """Base structure for get_item requests."""
22- return {"Key" : {"partition_key" : item ["partition_key" ], "sort_key" : item ["sort_key" ]}}
24+ return {"Key" : {"partition_key" : item ["partition_key" ], "sort_key" : item ["sort_key" ]}, "ConsistentRead" : True }
2325
2426
2527def base_delete_item_request (item ):
@@ -32,6 +34,7 @@ def base_query_request(item):
3234 return {
3335 "KeyConditionExpression" : "partition_key = :pk" ,
3436 "ExpressionAttributeValues" : {":pk" : item ["partition_key" ]},
37+ "ConsistentRead" : True ,
3538 }
3639
3740
@@ -40,6 +43,7 @@ def base_scan_request(item):
4043 return {
4144 "FilterExpression" : "attribute2 = :a2" ,
4245 "ExpressionAttributeValues" : {":a2" : item ["attribute2" ]},
46+ "ConsistentRead" : True ,
4347 }
4448
4549
@@ -50,7 +54,7 @@ def base_batch_write_item_request(actions_with_items):
5054
5155def base_batch_get_item_request (keys ):
5256 """Base structure for batch_get_item requests."""
53- return {"RequestItems" : {INTEG_TEST_DEFAULT_DYNAMODB_TABLE_NAME : {"Keys" : keys }}}
57+ return {"RequestItems" : {INTEG_TEST_DEFAULT_DYNAMODB_TABLE_NAME : {"Keys" : keys , "ConsistentRead" : True }}}
5458
5559
5660def base_transact_write_item_request (actions_with_items ):
@@ -142,15 +146,15 @@ def basic_batch_execute_statement_request_plaintext_table():
142146
143147# No exhaustive requests are intended to be able to be used as real requests.
144148# Some parameters conflict with each other when sent to DynamoDB.
145- # These are only intended to test the conversion of the structure from client to resource format .
149+ # These are only intended to test the conversion of the structure between client and resource formats .
146150
147151
148152def base_exhaustive_put_item_request (item ):
149153 """
150154 Base structure for exhaustive put_item requests.
151155 This is not intended to be able to be used as a real request.
152156 Some parameters conflict with each other when sent to DynamoDB.
153- This is only intended to test the conversion of the request from client to resource format .
157+ This is only intended to test the conversion of the request between client and resource formats .
154158 """
155159 return {
156160 # Expected is legacy, but still in the boto3 docs.
@@ -174,7 +178,7 @@ def base_exhaustive_get_item_request(item):
174178 Base structure for exhaustive get_item requests.
175179 This is not intended to be able to be used as a real request.
176180 Some parameters conflict with each other when sent to DynamoDB.
177- This is only intended to test the conversion of the request from client to resource format .
181+ This is only intended to test the conversion of the request between client and resource formats .
178182 """
179183 return {
180184 "ReturnConsumedCapacity" : "TOTAL" ,
@@ -196,7 +200,7 @@ def base_exhaustive_delete_item_request(item):
196200 Base structure for exhaustive delete_item requests.
197201 This is not intended to be able to be used as a real request.
198202 Some parameters conflict with each other when sent to DynamoDB.
199- This is only intended to test the conversion of the request from client to resource format .
203+ This is only intended to test the conversion of the request between client and resource formats .
200204 """
201205 return {
202206 "ReturnConsumedCapacity" : "TOTAL" ,
@@ -211,7 +215,7 @@ def base_exhaustive_query_request(item):
211215 Base structure for exhaustive query requests.
212216 This is not intended to be able to be used as a real request.
213217 Some parameters conflict with each other when sent to DynamoDB.
214- This is only intended to test the conversion of the request from client to resource format .
218+ This is only intended to test the conversion of the request between client and resource formats .
215219 """
216220 return {
217221 "IndexName" : "index_name" ,
@@ -240,7 +244,7 @@ def base_exhaustive_scan_request(item):
240244 Base structure for exhaustive scan requests.
241245 This is not intended to be able to be used as a real request.
242246 Some parameters conflict with each other when sent to DynamoDB.
243- This is only intended to test the conversion of the request from client to resource format .
247+ This is only intended to test the conversion of the request between client and resource formats .
244248 """
245249 return {
246250 "IndexName" : "index_name" ,
@@ -310,7 +314,7 @@ def exhaustive_query_request_ddb(item):
310314 Query request with all possible parameters.
311315 This is not intended to be able to be used as a real request.
312316 Some parameters conflict with each other when sent to DynamoDB.
313- This is only intended to test the conversion of the request from client to resource format .
317+ This is only intended to test the conversion of the request between client and resource formats .
314318 """
315319 base = basic_query_request_ddb (item )
316320 additional_keys = base_exhaustive_query_request (item )
@@ -390,6 +394,7 @@ def basic_query_paginator_request(key):
390394 "TableName" : INTEG_TEST_DEFAULT_DYNAMODB_TABLE_NAME ,
391395 "KeyConditionExpression" : "partition_key = :pk AND sort_key = :sk" ,
392396 "ExpressionAttributeValues" : {":pk" : key ["partition_key" ], ":sk" : key ["sort_key" ]},
397+ "ConsistentRead" : True ,
393398 }
394399
395400
@@ -399,6 +404,7 @@ def basic_scan_paginator_request(item):
399404 "TableName" : INTEG_TEST_DEFAULT_DYNAMODB_TABLE_NAME ,
400405 "FilterExpression" : "partition_key = :pk AND sort_key = :sk" ,
401406 "ExpressionAttributeValues" : {":pk" : item ["partition_key" ], ":sk" : item ["sort_key" ]},
407+ "ConsistentRead" : True ,
402408 }
403409
404410
@@ -427,7 +433,7 @@ def exhaustive_put_item_request_dict(item):
427433 Get a put_item request in dict format for any item.
428434 This is not intended to be able to be used as a real request.
429435 Some parameters conflict with each other when sent to DynamoDB.
430- This is only intended to test the conversion of the request from client to resource format .
436+ This is only intended to test the conversion of the request between client and resource formats .
431437 """
432438 base = basic_put_item_request_dict (item )
433439 # Replace the default ConditionExpression string with a ConditionExpression object
@@ -452,7 +458,7 @@ def exhaustive_get_item_request_dict(item):
452458 Get a get_item request in dict format for any item.
453459 This is not intended to be able to be used as a real request.
454460 Some parameters conflict with each other when sent to DynamoDB.
455- This is only intended to test the conversion of the request from client to resource format .
461+ This is only intended to test the conversion of the request between client and resource formats .
456462 """
457463 base = basic_get_item_request_dict (item )
458464 additional_keys = base_exhaustive_get_item_request (item )
@@ -478,7 +484,7 @@ def exhaustive_query_request_dict(item):
478484 Get a query request in dict format for any item.
479485 This is not intended to be able to be used as a real request.
480486 Some parameters conflict with each other when sent to DynamoDB.
481- This is only intended to test the conversion of the request from client to resource format .
487+ This is only intended to test the conversion of the request between client and resource formats .
482488 """
483489 base = basic_query_request_dict (item )
484490 additional_keys = base_exhaustive_query_request (item )
@@ -495,7 +501,7 @@ def exhaustive_scan_request_dict(item):
495501 Get a scan request in dict format for any item.
496502 This is not intended to be able to be used as a real request.
497503 Some parameters conflict with each other when sent to DynamoDB.
498- This is only intended to test the conversion of the request from client to resource format .
504+ This is only intended to test the conversion of the request between client and resource formats .
499505 """
500506 base = basic_scan_request_dict (item )
501507 additional_keys = base_exhaustive_scan_request (item )
0 commit comments