@@ -76,7 +76,7 @@ def test_idempotent_lambda_already_completed(
76
76
Test idempotent decorator where event with matching event key has already been successfully processed
77
77
"""
78
78
79
- stubber = stub .Stubber (persistence_store ._client )
79
+ stubber = stub .Stubber (persistence_store .client )
80
80
ddb_response = {
81
81
"Item" : {
82
82
"id" : {"S" : hashed_idempotency_key },
@@ -120,7 +120,7 @@ def test_idempotent_lambda_in_progress(
120
120
Test idempotent decorator where lambda_handler is already processing an event with matching event key
121
121
"""
122
122
123
- stubber = stub .Stubber (persistence_store ._client )
123
+ stubber = stub .Stubber (persistence_store .client )
124
124
125
125
expected_params = {
126
126
"TableName" : TABLE_NAME ,
@@ -172,7 +172,7 @@ def test_idempotent_lambda_in_progress_with_cache(
172
172
"""
173
173
save_to_cache_spy = mocker .spy (persistence_store , "_save_to_cache" )
174
174
retrieve_from_cache_spy = mocker .spy (persistence_store , "_retrieve_from_cache" )
175
- stubber = stub .Stubber (persistence_store ._client )
175
+ stubber = stub .Stubber (persistence_store .client )
176
176
177
177
expected_params = {
178
178
"TableName" : TABLE_NAME ,
@@ -234,7 +234,7 @@ def test_idempotent_lambda_first_execution(
234
234
Test idempotent decorator when lambda is executed with an event with a previously unknown event key
235
235
"""
236
236
237
- stubber = stub .Stubber (persistence_store ._client )
237
+ stubber = stub .Stubber (persistence_store .client )
238
238
ddb_response = {}
239
239
240
240
stubber .add_response ("put_item" , ddb_response , expected_params_put_item )
@@ -269,7 +269,7 @@ def test_idempotent_lambda_first_execution_cached(
269
269
"""
270
270
save_to_cache_spy = mocker .spy (persistence_store , "_save_to_cache" )
271
271
retrieve_from_cache_spy = mocker .spy (persistence_store , "_retrieve_from_cache" )
272
- stubber = stub .Stubber (persistence_store ._client )
272
+ stubber = stub .Stubber (persistence_store .client )
273
273
ddb_response = {}
274
274
275
275
stubber .add_response ("put_item" , ddb_response , expected_params_put_item )
@@ -310,7 +310,7 @@ def test_idempotent_lambda_first_execution_event_mutation(
310
310
Ensures we're passing data by value, not reference.
311
311
"""
312
312
event = copy .deepcopy (lambda_apigw_event )
313
- stubber = stub .Stubber (persistence_store ._client )
313
+ stubber = stub .Stubber (persistence_store .client )
314
314
ddb_response = {}
315
315
stubber .add_response (
316
316
"put_item" ,
@@ -350,7 +350,7 @@ def test_idempotent_lambda_expired(
350
350
expiry window
351
351
"""
352
352
353
- stubber = stub .Stubber (persistence_store ._client )
353
+ stubber = stub .Stubber (persistence_store .client )
354
354
355
355
ddb_response = {}
356
356
@@ -385,7 +385,7 @@ def test_idempotent_lambda_exception(
385
385
# Create a new provider
386
386
387
387
# Stub the boto3 client
388
- stubber = stub .Stubber (persistence_store ._client )
388
+ stubber = stub .Stubber (persistence_store .client )
389
389
390
390
ddb_response = {}
391
391
expected_params_delete_item = {"TableName" : TABLE_NAME , "Key" : {"id" : {"S" : hashed_idempotency_key }}}
@@ -427,7 +427,7 @@ def test_idempotent_lambda_already_completed_with_validation_bad_payload(
427
427
Test idempotent decorator where event with matching event key has already been successfully processed
428
428
"""
429
429
430
- stubber = stub .Stubber (persistence_store ._client )
430
+ stubber = stub .Stubber (persistence_store .client )
431
431
ddb_response = {
432
432
"Item" : {
433
433
"id" : {"S" : hashed_idempotency_key },
@@ -471,7 +471,7 @@ def test_idempotent_lambda_expired_during_request(
471
471
returns inconsistent/rapidly changing result between put_item and get_item calls.
472
472
"""
473
473
474
- stubber = stub .Stubber (persistence_store ._client )
474
+ stubber = stub .Stubber (persistence_store .client )
475
475
476
476
ddb_response_get_item = {
477
477
"Item" : {
@@ -524,7 +524,7 @@ def test_idempotent_persistence_exception_deleting(
524
524
Test idempotent decorator when lambda is executed with an event with a previously unknown event key, but
525
525
lambda_handler raises an exception which is retryable.
526
526
"""
527
- stubber = stub .Stubber (persistence_store ._client )
527
+ stubber = stub .Stubber (persistence_store .client )
528
528
529
529
ddb_response = {}
530
530
@@ -556,7 +556,7 @@ def test_idempotent_persistence_exception_updating(
556
556
Test idempotent decorator when lambda is executed with an event with a previously unknown event key, but
557
557
lambda_handler raises an exception which is retryable.
558
558
"""
559
- stubber = stub .Stubber (persistence_store ._client )
559
+ stubber = stub .Stubber (persistence_store .client )
560
560
561
561
ddb_response = {}
562
562
@@ -587,7 +587,7 @@ def test_idempotent_persistence_exception_getting(
587
587
Test idempotent decorator when lambda is executed with an event with a previously unknown event key, but
588
588
lambda_handler raises an exception which is retryable.
589
589
"""
590
- stubber = stub .Stubber (persistence_store ._client )
590
+ stubber = stub .Stubber (persistence_store .client )
591
591
592
592
stubber .add_client_error ("put_item" , "ConditionalCheckFailedException" )
593
593
stubber .add_client_error ("get_item" , "UnexpectedException" )
@@ -625,7 +625,7 @@ def test_idempotent_lambda_first_execution_with_validation(
625
625
"""
626
626
Test idempotent decorator when lambda is executed with an event with a previously unknown event key
627
627
"""
628
- stubber = stub .Stubber (persistence_store ._client )
628
+ stubber = stub .Stubber (persistence_store .client )
629
629
ddb_response = {}
630
630
631
631
stubber .add_response ("put_item" , ddb_response , expected_params_put_item_with_validation )
@@ -661,7 +661,7 @@ def test_idempotent_lambda_with_validator_util(
661
661
validator utility to unwrap the event
662
662
"""
663
663
664
- stubber = stub .Stubber (persistence_store ._client )
664
+ stubber = stub .Stubber (persistence_store .client )
665
665
ddb_response = {
666
666
"Item" : {
667
667
"id" : {"S" : hashed_idempotency_key_with_envelope },
@@ -704,7 +704,7 @@ def test_idempotent_lambda_expires_in_progress_before_expire(
704
704
hashed_idempotency_key ,
705
705
lambda_context ,
706
706
):
707
- stubber = stub .Stubber (persistence_store ._client )
707
+ stubber = stub .Stubber (persistence_store .client )
708
708
709
709
stubber .add_client_error ("put_item" , "ConditionalCheckFailedException" )
710
710
@@ -751,7 +751,7 @@ def test_idempotent_lambda_expires_in_progress_after_expire(
751
751
hashed_idempotency_key ,
752
752
lambda_context ,
753
753
):
754
- stubber = stub .Stubber (persistence_store ._client )
754
+ stubber = stub .Stubber (persistence_store .client )
755
755
756
756
for _ in range (MAX_RETRIES + 1 ):
757
757
stubber .add_client_error ("put_item" , "ConditionalCheckFailedException" )
@@ -1070,7 +1070,7 @@ def test_custom_jmespath_function_overrides_builtin_functions(
1070
1070
def test_idempotent_lambda_save_inprogress_error (persistence_store : DynamoDBPersistenceLayer , lambda_context ):
1071
1071
# GIVEN a miss configured persistence layer
1072
1072
# like no table was created for the idempotency persistence layer
1073
- stubber = stub .Stubber (persistence_store ._client )
1073
+ stubber = stub .Stubber (persistence_store .client )
1074
1074
service_error_code = "ResourceNotFoundException"
1075
1075
service_message = "Custom message"
1076
1076
@@ -1327,7 +1327,7 @@ def test_idempotency_disabled_envvar(monkeypatch, lambda_context, persistence_st
1327
1327
# Scenario to validate no requests sent to dynamodb table when 'POWERTOOLS_IDEMPOTENCY_DISABLED' is set
1328
1328
mock_event = {"data" : "value" }
1329
1329
1330
- persistence_store ._client = MagicMock ()
1330
+ persistence_store .client = MagicMock ()
1331
1331
1332
1332
monkeypatch .setenv ("POWERTOOLS_IDEMPOTENCY_DISABLED" , "1" )
1333
1333
@@ -1342,7 +1342,7 @@ def dummy_handler(event, context):
1342
1342
dummy (data = mock_event )
1343
1343
dummy_handler (mock_event , lambda_context )
1344
1344
1345
- assert len (persistence_store ._client .method_calls ) == 0
1345
+ assert len (persistence_store .client .method_calls ) == 0
1346
1346
1347
1347
1348
1348
@pytest .mark .parametrize ("idempotency_config" , [{"use_local_cache" : True }], indirect = True )
@@ -1351,7 +1351,7 @@ def test_idempotent_function_duplicates(
1351
1351
):
1352
1352
# Scenario to validate the both methods are called
1353
1353
mock_event = {"data" : "value" }
1354
- persistence_store ._client = MagicMock ()
1354
+ persistence_store .client = MagicMock ()
1355
1355
1356
1356
@idempotent_function (data_keyword_argument = "data" , persistence_store = persistence_store , config = idempotency_config )
1357
1357
def one (data ):
@@ -1363,7 +1363,7 @@ def two(data):
1363
1363
1364
1364
assert one (data = mock_event ) == "one"
1365
1365
assert two (data = mock_event ) == "two"
1366
- assert len (persistence_store ._client .method_calls ) == 4
1366
+ assert len (persistence_store .client .method_calls ) == 4
1367
1367
1368
1368
1369
1369
def test_invalid_dynamodb_persistence_layer ():
@@ -1475,7 +1475,7 @@ def test_idempotent_lambda_compound_already_completed(
1475
1475
Test idempotent decorator having a DynamoDBPersistenceLayer with a compound key
1476
1476
"""
1477
1477
1478
- stubber = stub .Stubber (persistence_store_compound ._client )
1478
+ stubber = stub .Stubber (persistence_store_compound .client )
1479
1479
stubber .add_client_error ("put_item" , "ConditionalCheckFailedException" )
1480
1480
ddb_response = {
1481
1481
"Item" : {
@@ -1520,7 +1520,7 @@ def test_idempotent_lambda_compound_static_pk_value_has_correct_pk(
1520
1520
Test idempotent decorator having a DynamoDBPersistenceLayer with a compound key and a static PK value
1521
1521
"""
1522
1522
1523
- stubber = stub .Stubber (persistence_store_compound_static_pk_value ._client )
1523
+ stubber = stub .Stubber (persistence_store_compound_static_pk_value .client )
1524
1524
ddb_response = {}
1525
1525
1526
1526
stubber .add_response ("put_item" , ddb_response , expected_params_put_item_compound_key_static_pk_value )
0 commit comments