Skip to content

Commit b4490b9

Browse files
author
Tom McCarthy
committed
chore: update test fixtures to use jmespath
1 parent dca02ee commit b4490b9

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

tests/functional/idempotency/conftest.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
import os
55

6+
import jmespath
67
import pytest
78
from botocore import stub
89
from botocore.config import Config
@@ -43,6 +44,11 @@ def lambda_response():
4344
return {"message": "test", "statusCode": 200}
4445

4546

47+
@pytest.fixture
48+
def default_jmespath():
49+
return "[body, queryStringParameters]"
50+
51+
4652
@pytest.fixture
4753
def expected_params_update_item(lambda_response, hashed_idempotency_key):
4854
return {
@@ -107,8 +113,10 @@ def expected_params_put_item_with_validation(hashed_idempotency_key, hashed_vali
107113

108114

109115
@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()
112120

113121

114122
@pytest.fixture
@@ -117,9 +125,9 @@ def hashed_validation_key(lambda_apigw_event):
117125

118126

119127
@pytest.fixture
120-
def persistence_store(config, request):
128+
def persistence_store(config, request, default_jmespath):
121129
persistence_store = DynamoDBPersistenceLayer(
122-
event_key_jmespath="body",
130+
event_key_jmespath=default_jmespath,
123131
table_name=TABLE_NAME,
124132
boto_config=config,
125133
use_local_cache=request.param["use_local_cache"],
@@ -128,9 +136,9 @@ def persistence_store(config, request):
128136

129137

130138
@pytest.fixture
131-
def persistence_store_with_validation(config, request):
139+
def persistence_store_with_validation(config, request, default_jmespath):
132140
persistence_store = DynamoDBPersistenceLayer(
133-
event_key_jmespath="body",
141+
event_key_jmespath=default_jmespath,
134142
table_name=TABLE_NAME,
135143
boto_config=config,
136144
use_local_cache=request.param,

0 commit comments

Comments
 (0)