Skip to content

Commit 2b8a4f2

Browse files
author
Tom McCarthy
committed
chore: add test for new env var
1 parent 7eb2198 commit 2b8a4f2

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/functional/idempotency/test_idempotency.py

+23
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
import sys
55
from hashlib import md5
6+
from unittest.mock import MagicMock
67

78
import jmespath
89
import pytest
@@ -994,3 +995,25 @@ def dummy(payload):
994995

995996
# WHEN
996997
dummy(payload=data_two)
998+
999+
1000+
def test_idempotency_disabled_envvar(monkeypatch, lambda_context, persistence_store: DynamoDBPersistenceLayer):
1001+
# Scenario to validate no requests sent to dynamodb table when 'POWERTOOLS_IDEMPOTENCY_DISABLED' is set
1002+
mock_event = {"data": "value"}
1003+
1004+
persistence_store.table = MagicMock()
1005+
1006+
monkeypatch.setenv("POWERTOOLS_IDEMPOTENCY_DISABLED", "1")
1007+
1008+
@idempotent_function(data_keyword_argument="data", persistence_store=persistence_store)
1009+
def dummy(data):
1010+
return {"message": "hello"}
1011+
1012+
@idempotent(persistence_store=persistence_store)
1013+
def dummy_handler(event, context):
1014+
return {"message": "hi"}
1015+
1016+
dummy(data=mock_event)
1017+
dummy_handler(mock_event, lambda_context)
1018+
1019+
assert len(persistence_store.table.method_calls) == 0

0 commit comments

Comments
 (0)