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 ):
0 commit comments