@@ -58,6 +58,54 @@ def expected_params_update_item(lambda_response, hashed_idempotency_key):
58
58
}
59
59
60
60
61
+ @pytest .fixture
62
+ def expected_params_update_item_with_validation (lambda_response , hashed_idempotency_key , hashed_validation_key ):
63
+ return {
64
+ "ExpressionAttributeNames" : {
65
+ "#expiry" : "expiration" ,
66
+ "#response_data" : "data" ,
67
+ "#status" : "status" ,
68
+ "#validation_key" : "validation" ,
69
+ },
70
+ "ExpressionAttributeValues" : {
71
+ ":expiry" : stub .ANY ,
72
+ ":response_data" : json .dumps (lambda_response ),
73
+ ":status" : "COMPLETED" ,
74
+ ":validation_key" : hashed_validation_key ,
75
+ },
76
+ "Key" : {"id" : hashed_idempotency_key },
77
+ "TableName" : "TEST_TABLE" ,
78
+ "UpdateExpression" : "SET #response_data = :response_data, "
79
+ "#expiry = :expiry, #status = :status, "
80
+ "#validation_key = :validation_key" ,
81
+ }
82
+
83
+
84
+ @pytest .fixture
85
+ def expected_params_put_item (hashed_idempotency_key ):
86
+ return {
87
+ "ConditionExpression" : "attribute_not_exists(id) OR expiration < :now" ,
88
+ "ExpressionAttributeValues" : {":now" : stub .ANY },
89
+ "Item" : {"expiration" : stub .ANY , "id" : hashed_idempotency_key , "status" : "INPROGRESS" },
90
+ "TableName" : "TEST_TABLE" ,
91
+ }
92
+
93
+
94
+ @pytest .fixture
95
+ def expected_params_put_item_with_validation (hashed_idempotency_key , hashed_validation_key ):
96
+ return {
97
+ "ConditionExpression" : "attribute_not_exists(id) OR expiration < :now" ,
98
+ "ExpressionAttributeValues" : {":now" : stub .ANY },
99
+ "Item" : {
100
+ "expiration" : stub .ANY ,
101
+ "id" : hashed_idempotency_key ,
102
+ "status" : "INPROGRESS" ,
103
+ "validation" : hashed_validation_key ,
104
+ },
105
+ "TableName" : "TEST_TABLE" ,
106
+ }
107
+
108
+
61
109
@pytest .fixture
62
110
def hashed_idempotency_key (lambda_apigw_event ):
63
111
return hashlib .md5 (json .dumps (lambda_apigw_event ["body" ]).encode ()).hexdigest ()
@@ -69,26 +117,23 @@ def hashed_validation_key(lambda_apigw_event):
69
117
70
118
71
119
@pytest .fixture
72
- def persistence_store (config ):
73
- persistence_store = DynamoDBPersistenceLayer (event_key_jmespath = "body" , table_name = TABLE_NAME , boto_config = config )
74
- return persistence_store
75
-
76
-
77
- @pytest .fixture
78
- def persistence_store_with_cache (config ):
120
+ def persistence_store (config , request ):
79
121
persistence_store = DynamoDBPersistenceLayer (
80
- event_key_jmespath = "body" , table_name = TABLE_NAME , boto_config = config , use_local_cache = True
122
+ event_key_jmespath = "body" ,
123
+ table_name = TABLE_NAME ,
124
+ boto_config = config ,
125
+ use_local_cache = request .param ["use_local_cache" ],
81
126
)
82
127
return persistence_store
83
128
84
129
85
130
@pytest .fixture
86
- def persistence_store_with_validation (config ):
131
+ def persistence_store_with_validation (config , request ):
87
132
persistence_store = DynamoDBPersistenceLayer (
88
133
event_key_jmespath = "body" ,
89
134
table_name = TABLE_NAME ,
90
135
boto_config = config ,
91
- use_local_cache = True ,
136
+ use_local_cache = request . param ,
92
137
payload_validation_jmespath = "requestContext" ,
93
138
)
94
139
return persistence_store
0 commit comments