File tree 1 file changed +23
-0
lines changed
tests/functional/idempotency
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 3
3
import json
4
4
import sys
5
5
from hashlib import md5
6
+ from unittest .mock import MagicMock
6
7
7
8
import jmespath
8
9
import pytest
@@ -994,3 +995,25 @@ def dummy(payload):
994
995
995
996
# WHEN
996
997
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
You can’t perform that action at this time.
0 commit comments