3
3
import json
4
4
import os
5
5
6
+ import jmespath
6
7
import pytest
7
8
from botocore import stub
8
9
from botocore .config import Config
@@ -43,6 +44,11 @@ def lambda_response():
43
44
return {"message" : "test" , "statusCode" : 200 }
44
45
45
46
47
+ @pytest .fixture
48
+ def default_jmespath ():
49
+ return "[body, queryStringParameters]"
50
+
51
+
46
52
@pytest .fixture
47
53
def expected_params_update_item (lambda_response , hashed_idempotency_key ):
48
54
return {
@@ -107,8 +113,10 @@ def expected_params_put_item_with_validation(hashed_idempotency_key, hashed_vali
107
113
108
114
109
115
@pytest .fixture
110
- def hashed_idempotency_key (lambda_apigw_event ):
111
- return hashlib .md5 (json .dumps (lambda_apigw_event ["body" ]).encode ()).hexdigest ()
116
+ def hashed_idempotency_key (lambda_apigw_event , default_jmespath ):
117
+ compiled_jmespath = jmespath .compile (default_jmespath )
118
+ data = compiled_jmespath .search (lambda_apigw_event )
119
+ return hashlib .md5 (json .dumps (data ).encode ()).hexdigest ()
112
120
113
121
114
122
@pytest .fixture
@@ -117,9 +125,9 @@ def hashed_validation_key(lambda_apigw_event):
117
125
118
126
119
127
@pytest .fixture
120
- def persistence_store (config , request ):
128
+ def persistence_store (config , request , default_jmespath ):
121
129
persistence_store = DynamoDBPersistenceLayer (
122
- event_key_jmespath = "body" ,
130
+ event_key_jmespath = default_jmespath ,
123
131
table_name = TABLE_NAME ,
124
132
boto_config = config ,
125
133
use_local_cache = request .param ["use_local_cache" ],
@@ -128,9 +136,9 @@ def persistence_store(config, request):
128
136
129
137
130
138
@pytest .fixture
131
- def persistence_store_with_validation (config , request ):
139
+ def persistence_store_with_validation (config , request , default_jmespath ):
132
140
persistence_store = DynamoDBPersistenceLayer (
133
- event_key_jmespath = "body" ,
141
+ event_key_jmespath = default_jmespath ,
134
142
table_name = TABLE_NAME ,
135
143
boto_config = config ,
136
144
use_local_cache = request .param ,
0 commit comments