@@ -215,6 +215,13 @@ def persistence_store_compound(config):
215
215
return DynamoDBPersistenceLayer (table_name = TABLE_NAME , boto_config = config , key_attr = "id" , sort_key_attr = "sk" )
216
216
217
217
218
+ @pytest .fixture
219
+ def persistence_store_compound_static_pk_value (config , static_pk_value ):
220
+ return DynamoDBPersistenceLayer (
221
+ table_name = TABLE_NAME , boto_config = config , key_attr = "id" , sort_key_attr = "sk" , static_pk_value = static_pk_value
222
+ )
223
+
224
+
218
225
@pytest .fixture
219
226
def idempotency_config (config , request , default_jmespath ):
220
227
return IdempotencyConfig (
@@ -246,3 +253,58 @@ def _func_echo_decoder(self, value):
246
253
@pytest .fixture
247
254
def mock_function ():
248
255
return mock .MagicMock ()
256
+
257
+
258
+ @pytest .fixture
259
+ def static_pk_value ():
260
+ return "static-value"
261
+
262
+
263
+ @pytest .fixture
264
+ def expected_params_update_item_compound_key_static_pk_value (
265
+ serialized_lambda_response , hashed_idempotency_key , static_pk_value
266
+ ):
267
+ return {
268
+ "ExpressionAttributeNames" : {
269
+ "#expiry" : "expiration" ,
270
+ "#response_data" : "data" ,
271
+ "#status" : "status" ,
272
+ },
273
+ "ExpressionAttributeValues" : {
274
+ ":expiry" : {"N" : stub .ANY },
275
+ ":response_data" : {"S" : serialized_lambda_response },
276
+ ":status" : {"S" : "COMPLETED" },
277
+ },
278
+ "Key" : {"id" : {"S" : static_pk_value }, "sk" : {"S" : hashed_idempotency_key }},
279
+ "TableName" : "TEST_TABLE" ,
280
+ "UpdateExpression" : "SET #response_data = :response_data, " "#expiry = :expiry, #status = :status" ,
281
+ }
282
+
283
+
284
+ @pytest .fixture
285
+ def expected_params_put_item_compound_key_static_pk_value (hashed_idempotency_key , static_pk_value ):
286
+ return {
287
+ "ConditionExpression" : (
288
+ "attribute_not_exists(#id) OR #expiry < :now OR "
289
+ "(#status = :inprogress AND attribute_exists(#in_progress_expiry) AND #in_progress_expiry < :now_in_millis)"
290
+ ),
291
+ "ExpressionAttributeNames" : {
292
+ "#id" : "id" ,
293
+ "#expiry" : "expiration" ,
294
+ "#status" : "status" ,
295
+ "#in_progress_expiry" : "in_progress_expiration" ,
296
+ },
297
+ "ExpressionAttributeValues" : {
298
+ ":now" : {"N" : stub .ANY },
299
+ ":now_in_millis" : {"N" : stub .ANY },
300
+ ":inprogress" : {"S" : "INPROGRESS" },
301
+ },
302
+ "Item" : {
303
+ "expiration" : {"N" : stub .ANY },
304
+ "in_progress_expiration" : {"N" : stub .ANY },
305
+ "id" : {"S" : static_pk_value },
306
+ "sk" : {"S" : hashed_idempotency_key },
307
+ "status" : {"S" : "INPROGRESS" },
308
+ },
309
+ "TableName" : "TEST_TABLE" ,
310
+ }
0 commit comments