<s> from __future__ import unicode_literals <EOL> import boto <EOL> from boto . exception import BotoServerError <EOL> from moto import mock_sns <EOL> import sure <EOL> @ mock_sns <EOL> def test_create_platform_application ( ) : <EOL> conn = boto . connect_sns ( ) <EOL> platform_application = conn . create_platform_application ( <EOL> name = "<STR_LIT>" , <EOL> platform = "<STR_LIT>" , <EOL> attributes = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } , <EOL> ) <EOL> application_arn = platform_application [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> application_arn . should . equal ( '<STR_LIT>' ) <EOL> @ mock_sns <EOL> def test_get_platform_application_attributes ( ) : <EOL> conn = boto . connect_sns ( ) <EOL> platform_application = conn . create_platform_application ( <EOL> name = "<STR_LIT>" , <EOL> platform = "<STR_LIT>" , <EOL> attributes = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } , <EOL> ) <EOL> arn = platform_application [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> attributes = conn . get_platform_application_attributes ( arn ) [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> attributes . should . equal ( { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } ) <EOL> @ mock_sns <EOL> def test_get_missing_platform_application_attributes ( ) : <EOL> conn = boto . connect_sns ( ) <EOL> conn . get_platform_application_attributes . when . called_with ( "<STR_LIT>" ) . should . throw ( BotoServerError ) <EOL> @ mock_sns <EOL> def test_set_platform_application_attributes ( ) : <EOL> conn = boto . connect_sns ( ) <EOL> platform_application = conn . create_platform_application ( <EOL> name = "<STR_LIT>" , <EOL> platform = "<STR_LIT>" , <EOL> attributes = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } , <EOL> ) <EOL> arn = platform_application [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> conn . set_platform_application_attributes ( arn , <EOL> { "<STR_LIT>" : "<STR_LIT>" } <EOL> ) <EOL> attributes = conn . get_platform_application_attributes ( arn ) [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> attributes . should . equal ( { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } ) <EOL> @ mock_sns <EOL> def test_list_platform_applications ( ) : <EOL> conn = boto . connect_sns ( ) <EOL> conn . create_platform_application ( <EOL> name = "<STR_LIT>" , <EOL> platform = "<STR_LIT>" , <EOL> ) <EOL> conn . create_platform_application ( <EOL> name = "<STR_LIT>" , <EOL> platform = "<STR_LIT>" , <EOL> ) <EOL> applications_repsonse = conn . list_platform_applications ( ) <EOL> applications = applications_repsonse [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> applications . should . have . length_of ( <NUM_LIT:2> ) <EOL> @ mock_sns <EOL> def test_delete_platform_application ( ) : <EOL> conn = boto . connect_sns ( ) <EOL> conn . create_platform_application ( <EOL> name = "<STR_LIT>" , <EOL> platform = "<STR_LIT>" , <EOL> ) <EOL> conn . create_platform_application ( <EOL> name = "<STR_LIT>" , <EOL> platform = "<STR_LIT>" , <EOL> ) <EOL> applications_repsonse = conn . list_platform_applications ( ) <EOL> applications = applications_repsonse [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> applications . should . have . length_of ( <NUM_LIT:2> ) <EOL> application_arn = applications [ <NUM_LIT:0> ] [ '<STR_LIT>' ] <EOL> conn . delete_platform_application ( application_arn ) <EOL> applications_repsonse = conn . list_platform_applications ( ) <EOL> applications = applications_repsonse [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> applications . should . have . length_of ( <NUM_LIT:1> ) <EOL> @ mock_sns <EOL> def test_create_platform_endpoint ( ) : <EOL> conn = boto . connect_sns ( ) <EOL> platform_application = conn . create_platform_application ( <EOL> name = "<STR_LIT>" , <EOL> platform = "<STR_LIT>" , <EOL> ) <EOL> application_arn = platform_application [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> endpoint = conn . create_platform_endpoint ( <EOL> platform_application_arn = application_arn , <EOL> token = "<STR_LIT>" , <EOL> custom_user_data = "<STR_LIT>" , <EOL> attributes = { <EOL> "<STR_LIT>" : False , <EOL> } , <EOL> ) <EOL> endpoint_arn = endpoint [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> endpoint_arn . should . contain ( "<STR_LIT>" ) <EOL> @ mock_sns <EOL> def test_get_list_endpoints_by_platform_application ( ) : <EOL> conn = boto . connect_sns ( ) <EOL> platform_application = conn . create_platform_application ( <EOL> name = "<STR_LIT>" , <EOL> platform = "<STR_LIT>" , <EOL> ) <EOL> application_arn = platform_application [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> endpoint = conn . create_platform_endpoint ( <EOL> platform_application_arn = application_arn , <EOL> token = "<STR_LIT>" , <EOL> custom_user_data = "<STR_LIT>" , <EOL> attributes = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } , <EOL> ) <EOL> endpoint_arn = endpoint [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> endpoint_list = conn . list_endpoints_by_platform_application ( <EOL> platform_application_arn = application_arn <EOL> ) [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> endpoint_list . should . have . length_of ( <NUM_LIT:1> ) <EOL> endpoint_list [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] . should . equal ( '<STR_LIT>' ) <EOL> endpoint_list [ <NUM_LIT:0> ] [ '<STR_LIT>' ] . should . equal ( endpoint_arn ) <EOL> @ mock_sns <EOL> def test_get_endpoint_attributes ( ) : <EOL> conn = boto . connect_sns ( ) <EOL> platform_application = conn . create_platform_application ( <EOL> name = "<STR_LIT>" , <EOL> platform = "<STR_LIT>" , <EOL> ) <EOL> application_arn = platform_application [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> endpoint = conn . create_platform_endpoint ( <EOL> platform_application_arn = application_arn , <EOL> token = "<STR_LIT>" , <EOL> custom_user_data = "<STR_LIT>" , <EOL> attributes = { <EOL> "<STR_LIT>" : False , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } , <EOL> ) <EOL> endpoint_arn = endpoint [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> attributes = conn . get_endpoint_attributes ( endpoint_arn ) [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> attributes . should . equal ( { <EOL> "<STR_LIT>" : '<STR_LIT:False>' , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } ) <EOL> @ mock_sns <EOL> def test_get_missing_endpoint_attributes ( ) : <EOL> conn = boto . connect_sns ( ) <EOL> conn . get_endpoint_attributes . when . called_with ( "<STR_LIT>" ) . should . throw ( BotoServerError ) <EOL> @ mock_sns <EOL> def test_set_endpoint_attributes ( ) : <EOL> conn = boto . connect_sns ( ) <EOL> platform_application = conn . create_platform_application ( <EOL> name = "<STR_LIT>" , <EOL> platform = "<STR_LIT>" , <EOL> ) <EOL> application_arn = platform_application [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> endpoint = conn . create_platform_endpoint ( <EOL> platform_application_arn = application_arn , <EOL> token = "<STR_LIT>" , <EOL> custom_user_data = "<STR_LIT>" , <EOL> attributes = { <EOL> "<STR_LIT>" : False , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } , <EOL> ) <EOL> endpoint_arn = endpoint [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> conn . set_endpoint_attributes ( endpoint_arn , <EOL> { "<STR_LIT>" : "<STR_LIT>" } <EOL> ) <EOL> attributes = conn . get_endpoint_attributes ( endpoint_arn ) [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> attributes . should . equal ( { <EOL> "<STR_LIT>" : '<STR_LIT:False>' , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } ) <EOL> @ mock_sns <EOL> def test_publish_to_platform_endpoint ( ) : <EOL> conn = boto . connect_sns ( ) <EOL> platform_application = conn . create_platform_application ( <EOL> name = "<STR_LIT>" , <EOL> platform = "<STR_LIT>" , <EOL> ) <EOL> application_arn = platform_application [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> endpoint = conn . create_platform_endpoint ( <EOL> platform_application_arn = application_arn , <EOL> token = "<STR_LIT>" , <EOL> custom_user_data = "<STR_LIT>" , <EOL> attributes = { <EOL> "<STR_LIT>" : False , <EOL> } , <EOL> ) <EOL> endpoint_arn = endpoint [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> conn . publish ( message = "<STR_LIT>" , message_structure = "<STR_LIT>" , target_arn = endpoint_arn ) </s>
