sns
- class moto.sns.models.SNSBackend(region_name, account_id)
Responsible for mocking calls to SNS. Integration with SQS/HTTP/etc is supported.
Messages published to a topic are persisted in the backend. If you need to verify that a message was published successfully, you can use the internal API to check the message was published successfully:
from moto.core import DEFAULT_ACCOUNT_ID from moto.sns import sns_backends sns_backend = sns_backends[DEFAULT_ACCOUNT_ID]["us-east-1"] # Use the appropriate account/region all_send_notifications = sns_backend.topics[topic_arn].sent_notifications
Note that, as this is an internal API, the exact format may differ per versions.
Example usage
@mock_sns
def test_sns_behaviour:
boto3.client("sns")
...
Implemented features for this service
[X] add_permission
[ ] check_if_phone_number_is_opted_out
[ ] confirm_subscription
[X] create_platform_application
[X] create_platform_endpoint
[ ] create_sms_sandbox_phone_number
[X] create_topic
[X] delete_endpoint
[X] delete_platform_application
[ ] delete_sms_sandbox_phone_number
[X] delete_topic
[ ] get_data_protection_policy
[ ] get_endpoint_attributes
[ ] get_platform_application_attributes
[ ] get_sms_attributes
[ ] get_sms_sandbox_account_status
[X] get_subscription_attributes
[ ] get_topic_attributes
[X] list_endpoints_by_platform_application
[ ] list_origination_numbers
[ ] list_phone_numbers_opted_out
[X] list_platform_applications
[ ] list_sms_sandbox_phone_numbers
[X] list_subscriptions
[ ] list_subscriptions_by_topic
[X] list_tags_for_resource
[X] list_topics
[ ] opt_in_phone_number
[X] publish
[X] publish_batch
The MessageStructure and MessageDeduplicationId-parameters have not yet been implemented.
[ ] put_data_protection_policy
[X] remove_permission
[X] set_endpoint_attributes
[ ] set_platform_application_attributes
[ ] set_sms_attributes
[X] set_subscription_attributes
[ ] set_topic_attributes
[X] subscribe
[X] tag_resource
[X] unsubscribe
[X] untag_resource
[ ] verify_sms_sandbox_phone_number