How to use create_platform_application method in localstack

Best Python code snippet using localstack_python

test_application_boto3.py

Source:test_application_boto3.py Github

copy

Full Screen

...3from botocore.exceptions import ClientError4from moto import mock_sns5import sure # noqa6@mock_sns7def test_create_platform_application():8 conn = boto3.client('sns', region_name='us-east-1')9 response = conn.create_platform_application(10 Name="my-application",11 Platform="APNS",12 Attributes={13 "PlatformCredential": "platform_credential",14 "PlatformPrincipal": "platform_principal",15 },16 )17 application_arn = response['PlatformApplicationArn']18 application_arn.should.equal(19 'arn:aws:sns:us-east-1:123456789012:app/APNS/my-application')20@mock_sns21def test_get_platform_application_attributes():22 conn = boto3.client('sns', region_name='us-east-1')23 platform_application = conn.create_platform_application(24 Name="my-application",25 Platform="APNS",26 Attributes={27 "PlatformCredential": "platform_credential",28 "PlatformPrincipal": "platform_principal",29 },30 )31 arn = platform_application['PlatformApplicationArn']32 attributes = conn.get_platform_application_attributes(33 PlatformApplicationArn=arn)['Attributes']34 attributes.should.equal({35 "PlatformCredential": "platform_credential",36 "PlatformPrincipal": "platform_principal",37 })38@mock_sns39def test_get_missing_platform_application_attributes():40 conn = boto3.client('sns', region_name='us-east-1')41 conn.get_platform_application_attributes.when.called_with(42 PlatformApplicationArn="a-fake-arn").should.throw(ClientError)43@mock_sns44def test_set_platform_application_attributes():45 conn = boto3.client('sns', region_name='us-east-1')46 platform_application = conn.create_platform_application(47 Name="my-application",48 Platform="APNS",49 Attributes={50 "PlatformCredential": "platform_credential",51 "PlatformPrincipal": "platform_principal",52 },53 )54 arn = platform_application['PlatformApplicationArn']55 conn.set_platform_application_attributes(PlatformApplicationArn=arn,56 Attributes={57 "PlatformPrincipal": "other"}58 )59 attributes = conn.get_platform_application_attributes(60 PlatformApplicationArn=arn)['Attributes']61 attributes.should.equal({62 "PlatformCredential": "platform_credential",63 "PlatformPrincipal": "other",64 })65@mock_sns66def test_list_platform_applications():67 conn = boto3.client('sns', region_name='us-east-1')68 conn.create_platform_application(69 Name="application1",70 Platform="APNS",71 Attributes={},72 )73 conn.create_platform_application(74 Name="application2",75 Platform="APNS",76 Attributes={},77 )78 applications_repsonse = conn.list_platform_applications()79 applications = applications_repsonse['PlatformApplications']80 applications.should.have.length_of(2)81@mock_sns82def test_delete_platform_application():83 conn = boto3.client('sns', region_name='us-east-1')84 conn.create_platform_application(85 Name="application1",86 Platform="APNS",87 Attributes={},88 )89 conn.create_platform_application(90 Name="application2",91 Platform="APNS",92 Attributes={},93 )94 applications_repsonse = conn.list_platform_applications()95 applications = applications_repsonse['PlatformApplications']96 applications.should.have.length_of(2)97 application_arn = applications[0]['PlatformApplicationArn']98 conn.delete_platform_application(PlatformApplicationArn=application_arn)99 applications_repsonse = conn.list_platform_applications()100 applications = applications_repsonse['PlatformApplications']101 applications.should.have.length_of(1)102@mock_sns103def test_create_platform_endpoint():104 conn = boto3.client('sns', region_name='us-east-1')105 platform_application = conn.create_platform_application(106 Name="my-application",107 Platform="APNS",108 Attributes={},109 )110 application_arn = platform_application['PlatformApplicationArn']111 endpoint = conn.create_platform_endpoint(112 PlatformApplicationArn=application_arn,113 Token="some_unique_id",114 CustomUserData="some user data",115 Attributes={116 "Enabled": 'false',117 },118 )119 endpoint_arn = endpoint['EndpointArn']120 endpoint_arn.should.contain(121 "arn:aws:sns:us-east-1:123456789012:endpoint/APNS/my-application/")122@mock_sns123def test_create_duplicate_platform_endpoint():124 conn = boto3.client('sns', region_name='us-east-1')125 platform_application = conn.create_platform_application(126 Name="my-application",127 Platform="APNS",128 Attributes={},129 )130 application_arn = platform_application['PlatformApplicationArn']131 endpoint = conn.create_platform_endpoint(132 PlatformApplicationArn=application_arn,133 Token="some_unique_id",134 CustomUserData="some user data",135 Attributes={136 "Enabled": 'false',137 },138 )139 endpoint = conn.create_platform_endpoint.when.called_with(140 PlatformApplicationArn=application_arn,141 Token="some_unique_id",142 CustomUserData="some user data",143 Attributes={144 "Enabled": 'false',145 },146 ).should.throw(ClientError)147@mock_sns148def test_get_list_endpoints_by_platform_application():149 conn = boto3.client('sns', region_name='us-east-1')150 platform_application = conn.create_platform_application(151 Name="my-application",152 Platform="APNS",153 Attributes={},154 )155 application_arn = platform_application['PlatformApplicationArn']156 endpoint = conn.create_platform_endpoint(157 PlatformApplicationArn=application_arn,158 Token="some_unique_id",159 CustomUserData="some user data",160 Attributes={161 "CustomUserData": "some data",162 },163 )164 endpoint_arn = endpoint['EndpointArn']165 endpoint_list = conn.list_endpoints_by_platform_application(166 PlatformApplicationArn=application_arn167 )['Endpoints']168 endpoint_list.should.have.length_of(1)169 endpoint_list[0]['Attributes']['CustomUserData'].should.equal('some data')170 endpoint_list[0]['EndpointArn'].should.equal(endpoint_arn)171@mock_sns172def test_get_endpoint_attributes():173 conn = boto3.client('sns', region_name='us-east-1')174 platform_application = conn.create_platform_application(175 Name="my-application",176 Platform="APNS",177 Attributes={},178 )179 application_arn = platform_application['PlatformApplicationArn']180 endpoint = conn.create_platform_endpoint(181 PlatformApplicationArn=application_arn,182 Token="some_unique_id",183 CustomUserData="some user data",184 Attributes={185 "Enabled": 'false',186 "CustomUserData": "some data",187 },188 )189 endpoint_arn = endpoint['EndpointArn']190 attributes = conn.get_endpoint_attributes(191 EndpointArn=endpoint_arn)['Attributes']192 attributes.should.equal({193 "Token": "some_unique_id",194 "Enabled": 'false',195 "CustomUserData": "some data",196 })197@mock_sns198def test_get_missing_endpoint_attributes():199 conn = boto3.client('sns', region_name='us-east-1')200 conn.get_endpoint_attributes.when.called_with(201 EndpointArn="a-fake-arn").should.throw(ClientError)202@mock_sns203def test_set_endpoint_attributes():204 conn = boto3.client('sns', region_name='us-east-1')205 platform_application = conn.create_platform_application(206 Name="my-application",207 Platform="APNS",208 Attributes={},209 )210 application_arn = platform_application['PlatformApplicationArn']211 endpoint = conn.create_platform_endpoint(212 PlatformApplicationArn=application_arn,213 Token="some_unique_id",214 CustomUserData="some user data",215 Attributes={216 "Enabled": 'false',217 "CustomUserData": "some data",218 },219 )220 endpoint_arn = endpoint['EndpointArn']221 conn.set_endpoint_attributes(EndpointArn=endpoint_arn,222 Attributes={"CustomUserData": "other data"}223 )224 attributes = conn.get_endpoint_attributes(225 EndpointArn=endpoint_arn)['Attributes']226 attributes.should.equal({227 "Token": "some_unique_id",228 "Enabled": 'false',229 "CustomUserData": "other data",230 })231@mock_sns232def test_publish_to_platform_endpoint():233 conn = boto3.client('sns', region_name='us-east-1')234 platform_application = conn.create_platform_application(235 Name="my-application",236 Platform="APNS",237 Attributes={},238 )239 application_arn = platform_application['PlatformApplicationArn']240 endpoint = conn.create_platform_endpoint(241 PlatformApplicationArn=application_arn,242 Token="some_unique_id",243 CustomUserData="some user data",244 Attributes={245 "Enabled": 'true',246 },247 )248 endpoint_arn = endpoint['EndpointArn']249 conn.publish(Message="some message",250 MessageStructure="json", TargetArn=endpoint_arn)251@mock_sns252def test_publish_to_disabled_platform_endpoint():253 conn = boto3.client('sns', region_name='us-east-1')254 platform_application = conn.create_platform_application(255 Name="my-application",256 Platform="APNS",257 Attributes={},258 )259 application_arn = platform_application['PlatformApplicationArn']260 endpoint = conn.create_platform_endpoint(261 PlatformApplicationArn=application_arn,262 Token="some_unique_id",263 CustomUserData="some user data",264 Attributes={265 "Enabled": 'false',266 },267 )268 endpoint_arn = endpoint['EndpointArn']...

Full Screen

Full Screen

test_application.py

Source:test_application.py Github

copy

Full Screen

...3from boto.exception import BotoServerError4from moto import mock_sns_deprecated5import sure # noqa6@mock_sns_deprecated7def test_create_platform_application():8 conn = boto.connect_sns()9 platform_application = conn.create_platform_application(10 name="my-application",11 platform="APNS",12 attributes={13 "PlatformCredential": "platform_credential",14 "PlatformPrincipal": "platform_principal",15 },16 )17 application_arn = platform_application['CreatePlatformApplicationResponse'][18 'CreatePlatformApplicationResult']['PlatformApplicationArn']19 application_arn.should.equal(20 'arn:aws:sns:us-east-1:123456789012:app/APNS/my-application')21@mock_sns_deprecated22def test_get_platform_application_attributes():23 conn = boto.connect_sns()24 platform_application = conn.create_platform_application(25 name="my-application",26 platform="APNS",27 attributes={28 "PlatformCredential": "platform_credential",29 "PlatformPrincipal": "platform_principal",30 },31 )32 arn = platform_application['CreatePlatformApplicationResponse'][33 'CreatePlatformApplicationResult']['PlatformApplicationArn']34 attributes = conn.get_platform_application_attributes(arn)['GetPlatformApplicationAttributesResponse'][35 'GetPlatformApplicationAttributesResult']['Attributes']36 attributes.should.equal({37 "PlatformCredential": "platform_credential",38 "PlatformPrincipal": "platform_principal",39 })40@mock_sns_deprecated41def test_get_missing_platform_application_attributes():42 conn = boto.connect_sns()43 conn.get_platform_application_attributes.when.called_with(44 "a-fake-arn").should.throw(BotoServerError)45@mock_sns_deprecated46def test_set_platform_application_attributes():47 conn = boto.connect_sns()48 platform_application = conn.create_platform_application(49 name="my-application",50 platform="APNS",51 attributes={52 "PlatformCredential": "platform_credential",53 "PlatformPrincipal": "platform_principal",54 },55 )56 arn = platform_application['CreatePlatformApplicationResponse'][57 'CreatePlatformApplicationResult']['PlatformApplicationArn']58 conn.set_platform_application_attributes(arn,59 {"PlatformPrincipal": "other"}60 )61 attributes = conn.get_platform_application_attributes(arn)['GetPlatformApplicationAttributesResponse'][62 'GetPlatformApplicationAttributesResult']['Attributes']63 attributes.should.equal({64 "PlatformCredential": "platform_credential",65 "PlatformPrincipal": "other",66 })67@mock_sns_deprecated68def test_list_platform_applications():69 conn = boto.connect_sns()70 conn.create_platform_application(71 name="application1",72 platform="APNS",73 )74 conn.create_platform_application(75 name="application2",76 platform="APNS",77 )78 applications_repsonse = conn.list_platform_applications()79 applications = applications_repsonse['ListPlatformApplicationsResponse'][80 'ListPlatformApplicationsResult']['PlatformApplications']81 applications.should.have.length_of(2)82@mock_sns_deprecated83def test_delete_platform_application():84 conn = boto.connect_sns()85 conn.create_platform_application(86 name="application1",87 platform="APNS",88 )89 conn.create_platform_application(90 name="application2",91 platform="APNS",92 )93 applications_repsonse = conn.list_platform_applications()94 applications = applications_repsonse['ListPlatformApplicationsResponse'][95 'ListPlatformApplicationsResult']['PlatformApplications']96 applications.should.have.length_of(2)97 application_arn = applications[0]['PlatformApplicationArn']98 conn.delete_platform_application(application_arn)99 applications_repsonse = conn.list_platform_applications()100 applications = applications_repsonse['ListPlatformApplicationsResponse'][101 'ListPlatformApplicationsResult']['PlatformApplications']102 applications.should.have.length_of(1)103@mock_sns_deprecated104def test_create_platform_endpoint():105 conn = boto.connect_sns()106 platform_application = conn.create_platform_application(107 name="my-application",108 platform="APNS",109 )110 application_arn = platform_application['CreatePlatformApplicationResponse'][111 'CreatePlatformApplicationResult']['PlatformApplicationArn']112 endpoint = conn.create_platform_endpoint(113 platform_application_arn=application_arn,114 token="some_unique_id",115 custom_user_data="some user data",116 attributes={117 "Enabled": False,118 },119 )120 endpoint_arn = endpoint['CreatePlatformEndpointResponse'][121 'CreatePlatformEndpointResult']['EndpointArn']122 endpoint_arn.should.contain(123 "arn:aws:sns:us-east-1:123456789012:endpoint/APNS/my-application/")124@mock_sns_deprecated125def test_get_list_endpoints_by_platform_application():126 conn = boto.connect_sns()127 platform_application = conn.create_platform_application(128 name="my-application",129 platform="APNS",130 )131 application_arn = platform_application['CreatePlatformApplicationResponse'][132 'CreatePlatformApplicationResult']['PlatformApplicationArn']133 endpoint = conn.create_platform_endpoint(134 platform_application_arn=application_arn,135 token="some_unique_id",136 custom_user_data="some user data",137 attributes={138 "CustomUserData": "some data",139 },140 )141 endpoint_arn = endpoint['CreatePlatformEndpointResponse'][142 'CreatePlatformEndpointResult']['EndpointArn']143 endpoint_list = conn.list_endpoints_by_platform_application(144 platform_application_arn=application_arn145 )['ListEndpointsByPlatformApplicationResponse']['ListEndpointsByPlatformApplicationResult']['Endpoints']146 endpoint_list.should.have.length_of(1)147 endpoint_list[0]['Attributes']['CustomUserData'].should.equal('some data')148 endpoint_list[0]['EndpointArn'].should.equal(endpoint_arn)149@mock_sns_deprecated150def test_get_endpoint_attributes():151 conn = boto.connect_sns()152 platform_application = conn.create_platform_application(153 name="my-application",154 platform="APNS",155 )156 application_arn = platform_application['CreatePlatformApplicationResponse'][157 'CreatePlatformApplicationResult']['PlatformApplicationArn']158 endpoint = conn.create_platform_endpoint(159 platform_application_arn=application_arn,160 token="some_unique_id",161 custom_user_data="some user data",162 attributes={163 "Enabled": False,164 "CustomUserData": "some data",165 },166 )167 endpoint_arn = endpoint['CreatePlatformEndpointResponse'][168 'CreatePlatformEndpointResult']['EndpointArn']169 attributes = conn.get_endpoint_attributes(endpoint_arn)['GetEndpointAttributesResponse'][170 'GetEndpointAttributesResult']['Attributes']171 attributes.should.equal({172 "Token": "some_unique_id",173 "Enabled": 'False',174 "CustomUserData": "some data",175 })176@mock_sns_deprecated177def test_get_missing_endpoint_attributes():178 conn = boto.connect_sns()179 conn.get_endpoint_attributes.when.called_with(180 "a-fake-arn").should.throw(BotoServerError)181@mock_sns_deprecated182def test_set_endpoint_attributes():183 conn = boto.connect_sns()184 platform_application = conn.create_platform_application(185 name="my-application",186 platform="APNS",187 )188 application_arn = platform_application['CreatePlatformApplicationResponse'][189 'CreatePlatformApplicationResult']['PlatformApplicationArn']190 endpoint = conn.create_platform_endpoint(191 platform_application_arn=application_arn,192 token="some_unique_id",193 custom_user_data="some user data",194 attributes={195 "Enabled": False,196 "CustomUserData": "some data",197 },198 )199 endpoint_arn = endpoint['CreatePlatformEndpointResponse'][200 'CreatePlatformEndpointResult']['EndpointArn']201 conn.set_endpoint_attributes(endpoint_arn,202 {"CustomUserData": "other data"}203 )204 attributes = conn.get_endpoint_attributes(endpoint_arn)['GetEndpointAttributesResponse'][205 'GetEndpointAttributesResult']['Attributes']206 attributes.should.equal({207 "Token": "some_unique_id",208 "Enabled": 'False',209 "CustomUserData": "other data",210 })211@mock_sns_deprecated212def test_delete_endpoint():213 conn = boto.connect_sns()214 platform_application = conn.create_platform_application(215 name="my-application",216 platform="APNS",217 )218 application_arn = platform_application['CreatePlatformApplicationResponse'][219 'CreatePlatformApplicationResult']['PlatformApplicationArn']220 endpoint = conn.create_platform_endpoint(221 platform_application_arn=application_arn,222 token="some_unique_id",223 custom_user_data="some user data",224 attributes={225 "Enabled": False,226 "CustomUserData": "some data",227 },228 )229 endpoint_arn = endpoint['CreatePlatformEndpointResponse'][230 'CreatePlatformEndpointResult']['EndpointArn']231 endpoint_list = conn.list_endpoints_by_platform_application(232 platform_application_arn=application_arn233 )['ListEndpointsByPlatformApplicationResponse']['ListEndpointsByPlatformApplicationResult']['Endpoints']234 endpoint_list.should.have.length_of(1)235 conn.delete_endpoint(endpoint_arn)236 endpoint_list = conn.list_endpoints_by_platform_application(237 platform_application_arn=application_arn238 )['ListEndpointsByPlatformApplicationResponse']['ListEndpointsByPlatformApplicationResult']['Endpoints']239 endpoint_list.should.have.length_of(0)240@mock_sns_deprecated241def test_publish_to_platform_endpoint():242 conn = boto.connect_sns()243 platform_application = conn.create_platform_application(244 name="my-application",245 platform="APNS",246 )247 application_arn = platform_application['CreatePlatformApplicationResponse'][248 'CreatePlatformApplicationResult']['PlatformApplicationArn']249 endpoint = conn.create_platform_endpoint(250 platform_application_arn=application_arn,251 token="some_unique_id",252 custom_user_data="some user data",253 attributes={254 "Enabled": True,255 },256 )257 endpoint_arn = endpoint['CreatePlatformEndpointResponse'][...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful