Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Commit bdd3c30

Browse files
committed
simplify store access in test
1 parent 34c61bf commit bdd3c30

2 files changed

Lines changed: 54 additions & 48 deletions

File tree

tests/aws/services/sns/test_sns.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4698,15 +4698,13 @@ def test_is_phone_number_opted_out(
46984698
# this test expects the fixture-provided phone number to be opted out
46994699
# if you want to test against AWS, you need to manually opt out a number
47004700
# https://us-east-1.console.aws.amazon.com/sms-voice/home?region=us-east-1#/opt-out-lists?name=Default&tab=opt-out-list-opted-out-numbers
4701+
sns_store = sns_provider().get_store(account_id, region_name)
4702+
47014703
def cleanup_store():
4702-
SnsProvider = sns_provider()
4703-
store = SnsProvider.get_store(account_id, region_name)
4704-
store.PHONE_NUMBERS_OPTED_OUT.remove(phone_number)
4704+
sns_store.PHONE_NUMBERS_OPTED_OUT.remove(phone_number)
47054705

47064706
if not is_aws_cloud():
4707-
SnsProvider = sns_provider()
4708-
store = SnsProvider.get_store(account_id, region_name)
4709-
store.PHONE_NUMBERS_OPTED_OUT.append(phone_number)
4707+
sns_store.PHONE_NUMBERS_OPTED_OUT.append(phone_number)
47104708
cleanups.append(cleanup_store)
47114709

47124710
response = aws_client.sns.check_if_phone_number_is_opted_out(phoneNumber=phone_number)
@@ -4720,15 +4718,13 @@ def test_list_phone_numbers_opted_out(
47204718
# this test expects exactly one phone number opted out
47214719
# if you want to test against AWS, you need to manually opt out a number
47224720
# https://us-east-1.console.aws.amazon.com/sms-voice/home?region=us-east-1#/opt-out-lists?name=Default&tab=opt-out-list-opted-out-numbers
4721+
sns_store = sns_provider().get_store(account_id, region_name)
4722+
47234723
def cleanup_store():
4724-
SnsProvider = sns_provider()
4725-
store = SnsProvider.get_store(account_id, region_name)
4726-
store.PHONE_NUMBERS_OPTED_OUT.remove(phone_number)
4724+
sns_store.PHONE_NUMBERS_OPTED_OUT.remove(phone_number)
47274725

47284726
if not is_aws_cloud():
4729-
SnsProvider = sns_provider()
4730-
store = SnsProvider.get_store(account_id, region_name)
4731-
store.PHONE_NUMBERS_OPTED_OUT.append(phone_number)
4727+
sns_store.PHONE_NUMBERS_OPTED_OUT.append(phone_number)
47324728
cleanups.append(cleanup_store)
47334729

47344730
snapshot.add_transformer(
@@ -4750,15 +4746,13 @@ def test_opt_in_phone_number(
47504746
# https://us-east-1.console.aws.amazon.com/sms-voice/home?region=us-east-1#/opt-out-lists?name=Default&tab=opt-out-list-opted-out-numbers
47514747
# IMPORTANT: a phone number can only be opted in once every 30 days on AWS.
47524748
# Make sure everything else is set up and taken care of properly before trying to validate this.
4749+
sns_store = sns_provider().get_store(account_id, region_name)
4750+
47534751
def cleanup_store():
4754-
SnsProvider = sns_provider()
4755-
store = SnsProvider.get_store(account_id, region_name)
4756-
store.PHONE_NUMBERS_OPTED_OUT.remove(phone_number)
4752+
sns_store.PHONE_NUMBERS_OPTED_OUT.remove(phone_number)
47574753

47584754
if not is_aws_cloud():
4759-
SnsProvider = sns_provider()
4760-
store = SnsProvider.get_store(account_id, region_name)
4761-
store.PHONE_NUMBERS_OPTED_OUT.append(phone_number)
4755+
sns_store.PHONE_NUMBERS_OPTED_OUT.append(phone_number)
47624756
cleanups.append(cleanup_store)
47634757
response = aws_client.sns.check_if_phone_number_is_opted_out(phoneNumber=phone_number)
47644758
assert response["isOptedOut"]

tests/aws/services/sns/test_sns.validation.json

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -657,12 +657,12 @@
657657
"last_validated_date": "2023-11-07T10:11:37+00:00"
658658
},
659659
"tests/aws/services/sns/test_sns.py::TestSNSSMS::test_get_sms_attributes_from_unmodified_region": {
660-
"last_validated_date": "2025-10-15T12:02:37+00:00",
660+
"last_validated_date": "2025-12-02T12:58:44+00:00",
661661
"durations_in_seconds": {
662-
"setup": 0.67,
663-
"call": 2.07,
662+
"setup": 0.0,
663+
"call": 2.64,
664664
"teardown": 0.0,
665-
"total": 2.74
665+
"total": 2.64
666666
}
667667
},
668668
"tests/aws/services/sns/test_sns.py::TestSNSSMS::test_is_phone_number_opted_out": {
@@ -675,21 +675,21 @@
675675
}
676676
},
677677
"tests/aws/services/sns/test_sns.py::TestSNSSMS::test_list_phone_numbers_opted_out": {
678-
"last_validated_date": "2025-12-01T19:37:44+00:00",
678+
"last_validated_date": "2025-12-02T12:58:54+00:00",
679679
"durations_in_seconds": {
680-
"setup": 0.92,
681-
"call": 1.23,
682-
"teardown": 0.01,
683-
"total": 2.16
680+
"setup": 0.0,
681+
"call": 0.16,
682+
"teardown": 0.0,
683+
"total": 0.16
684684
}
685685
},
686686
"tests/aws/services/sns/test_sns.py::TestSNSSMS::test_opt_in_non_existing_phone_number": {
687-
"last_validated_date": "2025-12-01T19:53:23+00:00",
687+
"last_validated_date": "2025-12-02T12:58:54+00:00",
688688
"durations_in_seconds": {
689-
"setup": 0.99,
690-
"call": 1.03,
689+
"setup": 0.0,
690+
"call": 0.14,
691691
"teardown": 0.0,
692-
"total": 2.02
692+
"total": 0.14
693693
}
694694
},
695695
"tests/aws/services/sns/test_sns.py::TestSNSSMS::test_opt_in_phone_number": {
@@ -702,7 +702,13 @@
702702
}
703703
},
704704
"tests/aws/services/sns/test_sns.py::TestSNSSMS::test_publish_wrong_phone_format": {
705-
"last_validated_date": "2023-08-24T22:20:12+00:00"
705+
"last_validated_date": "2025-12-02T12:58:42+00:00",
706+
"durations_in_seconds": {
707+
"setup": 0.0,
708+
"call": 0.87,
709+
"teardown": 0.25,
710+
"total": 1.12
711+
}
706712
},
707713
"tests/aws/services/sns/test_sns.py::TestSNSSMS::test_set_get_sms_attributes": {
708714
"last_validated_date": "2025-10-13T10:30:42+00:00",
@@ -714,39 +720,39 @@
714720
}
715721
},
716722
"tests/aws/services/sns/test_sns.py::TestSNSSMS::test_set_invalid_sms_attributes[InvalidAttributeName]": {
717-
"last_validated_date": "2025-10-15T12:14:04+00:00",
723+
"last_validated_date": "2025-12-02T12:58:45+00:00",
718724
"durations_in_seconds": {
719-
"setup": 1.45,
720-
"call": 1.32,
725+
"setup": 0.01,
726+
"call": 0.3,
721727
"teardown": 0.0,
722-
"total": 2.77
728+
"total": 0.31
723729
}
724730
},
725731
"tests/aws/services/sns/test_sns.py::TestSNSSMS::test_set_invalid_sms_attributes[InvalidSMSType]": {
726-
"last_validated_date": "2025-10-15T12:14:12+00:00",
732+
"last_validated_date": "2025-12-02T12:58:53+00:00",
727733
"durations_in_seconds": {
728734
"setup": 0.0,
729-
"call": 2.24,
735+
"call": 2.16,
730736
"teardown": 0.0,
731-
"total": 2.24
737+
"total": 2.16
732738
}
733739
},
734740
"tests/aws/services/sns/test_sns.py::TestSNSSMS::test_set_invalid_sms_attributes[NoLetterID]": {
735-
"last_validated_date": "2025-10-15T12:14:09+00:00",
741+
"last_validated_date": "2025-12-02T12:58:51+00:00",
736742
"durations_in_seconds": {
737-
"setup": 0.01,
738-
"call": 3.39,
743+
"setup": 0.0,
744+
"call": 3.38,
739745
"teardown": 0.0,
740-
"total": 3.4
746+
"total": 3.38
741747
}
742748
},
743749
"tests/aws/services/sns/test_sns.py::TestSNSSMS::test_set_invalid_sms_attributes[TooLongID]": {
744-
"last_validated_date": "2025-10-15T12:14:06+00:00",
750+
"last_validated_date": "2025-12-02T12:58:48+00:00",
745751
"durations_in_seconds": {
746-
"setup": 0.1,
747-
"call": 1.78,
752+
"setup": 0.0,
753+
"call": 3.04,
748754
"teardown": 0.0,
749-
"total": 1.88
755+
"total": 3.04
750756
}
751757
},
752758
"tests/aws/services/sns/test_sns.py::TestSNSSMS::test_set_invalid_sms_attributes[attribute_key_value0]": {
@@ -786,7 +792,13 @@
786792
}
787793
},
788794
"tests/aws/services/sns/test_sns.py::TestSNSSMS::test_subscribe_sms_endpoint": {
789-
"last_validated_date": "2024-05-14T19:34:11+00:00"
795+
"last_validated_date": "2025-12-02T12:58:41+00:00",
796+
"durations_in_seconds": {
797+
"setup": 0.81,
798+
"call": 2.06,
799+
"teardown": 0.61,
800+
"total": 3.48
801+
}
790802
},
791803
"tests/aws/services/sns/test_sns.py::TestSNSSubscriptionCrud::test_create_subscriptions_with_attributes": {
792804
"last_validated_date": "2025-10-06T10:25:19+00:00",

0 commit comments

Comments
 (0)