How to use create_platform_endpoint method in localstack

Best Python code snippet using localstack_python

test_application_boto3.py

Source: test_application_boto3.py Github

copy

Full Screen

...96 applications_response = conn.list_platform_applications()97 applications = applications_response["PlatformApplications"]98 applications.should.have.length_of(1)99@mock_sns100def test_create_platform_endpoint():101 conn = boto3.client("sns", region_name="us-east-1")102 platform_application = conn.create_platform_application(103 Name="my-application", Platform="APNS", Attributes={}104 )105 application_arn = platform_application["PlatformApplicationArn"]106 endpoint = conn.create_platform_endpoint(107 PlatformApplicationArn=application_arn,108 Token="some_unique_id",109 CustomUserData="some user data",110 Attributes={"Enabled": "false"},111 )112 endpoint_arn = endpoint["EndpointArn"]113 endpoint_arn.should.contain(114 "arn:aws:sns:us-east-1:{}:endpoint/​APNS/​my-application/​".format(ACCOUNT_ID)115 )116@mock_sns117def test_create_duplicate_platform_endpoint():118 conn = boto3.client("sns", region_name="us-east-1")119 platform_application = conn.create_platform_application(120 Name="my-application", Platform="APNS", Attributes={}121 )122 application_arn = platform_application["PlatformApplicationArn"]123 endpoint = conn.create_platform_endpoint(124 PlatformApplicationArn=application_arn,125 Token="some_unique_id",126 CustomUserData="some user data",127 Attributes={"Enabled": "false"},128 )129 endpoint = conn.create_platform_endpoint.when.called_with(130 PlatformApplicationArn=application_arn,131 Token="some_unique_id",132 CustomUserData="some user data",133 Attributes={"Enabled": "false"},134 ).should.throw(ClientError)135@mock_sns136def test_get_list_endpoints_by_platform_application():137 conn = boto3.client("sns", region_name="us-east-1")138 platform_application = conn.create_platform_application(139 Name="my-application", Platform="APNS", Attributes={}140 )141 application_arn = platform_application["PlatformApplicationArn"]142 endpoint = conn.create_platform_endpoint(143 PlatformApplicationArn=application_arn,144 Token="some_unique_id",145 CustomUserData="some user data",146 Attributes={"CustomUserData": "some data"},147 )148 endpoint_arn = endpoint["EndpointArn"]149 endpoint_list = conn.list_endpoints_by_platform_application(150 PlatformApplicationArn=application_arn151 )["Endpoints"]152 endpoint_list.should.have.length_of(1)153 endpoint_list[0]["Attributes"]["CustomUserData"].should.equal("some data")154 endpoint_list[0]["EndpointArn"].should.equal(endpoint_arn)155@mock_sns156def test_get_endpoint_attributes():157 conn = boto3.client("sns", region_name="us-east-1")158 platform_application = conn.create_platform_application(159 Name="my-application", Platform="APNS", Attributes={}160 )161 application_arn = platform_application["PlatformApplicationArn"]162 endpoint = conn.create_platform_endpoint(163 PlatformApplicationArn=application_arn,164 Token="some_unique_id",165 CustomUserData="some user data",166 Attributes={"Enabled": "false", "CustomUserData": "some data"},167 )168 endpoint_arn = endpoint["EndpointArn"]169 attributes = conn.get_endpoint_attributes(EndpointArn=endpoint_arn)["Attributes"]170 attributes.should.equal(171 {"Token": "some_unique_id", "Enabled": "false", "CustomUserData": "some data"}172 )173@mock_sns174def test_get_missing_endpoint_attributes():175 conn = boto3.client("sns", region_name="us-east-1")176 conn.get_endpoint_attributes.when.called_with(177 EndpointArn="a-fake-arn"178 ).should.throw(ClientError)179@mock_sns180def test_set_endpoint_attributes():181 conn = boto3.client("sns", region_name="us-east-1")182 platform_application = conn.create_platform_application(183 Name="my-application", Platform="APNS", Attributes={}184 )185 application_arn = platform_application["PlatformApplicationArn"]186 endpoint = conn.create_platform_endpoint(187 PlatformApplicationArn=application_arn,188 Token="some_unique_id",189 CustomUserData="some user data",190 Attributes={"Enabled": "false", "CustomUserData": "some data"},191 )192 endpoint_arn = endpoint["EndpointArn"]193 conn.set_endpoint_attributes(194 EndpointArn=endpoint_arn, Attributes={"CustomUserData": "other data"}195 )196 attributes = conn.get_endpoint_attributes(EndpointArn=endpoint_arn)["Attributes"]197 attributes.should.equal(198 {"Token": "some_unique_id", "Enabled": "false", "CustomUserData": "other data"}199 )200@mock_sns201def test_publish_to_platform_endpoint():202 conn = boto3.client("sns", region_name="us-east-1")203 platform_application = conn.create_platform_application(204 Name="my-application", Platform="APNS", Attributes={}205 )206 application_arn = platform_application["PlatformApplicationArn"]207 endpoint = conn.create_platform_endpoint(208 PlatformApplicationArn=application_arn,209 Token="some_unique_id",210 CustomUserData="some user data",211 Attributes={"Enabled": "true"},212 )213 endpoint_arn = endpoint["EndpointArn"]214 conn.publish(215 Message="some message", MessageStructure="json", TargetArn=endpoint_arn216 )217@mock_sns218def test_publish_to_disabled_platform_endpoint():219 conn = boto3.client("sns", region_name="us-east-1")220 platform_application = conn.create_platform_application(221 Name="my-application", Platform="APNS", Attributes={}222 )223 application_arn = platform_application["PlatformApplicationArn"]224 endpoint = conn.create_platform_endpoint(225 PlatformApplicationArn=application_arn,226 Token="some_unique_id",227 CustomUserData="some user data",228 Attributes={"Enabled": "false"},229 )230 endpoint_arn = endpoint["EndpointArn"]231 conn.publish.when.called_with(232 Message="some message", MessageStructure="json", TargetArn=endpoint_arn233 ).should.throw(ClientError)234@mock_sns235def test_set_sms_attributes():236 conn = boto3.client("sns", region_name="us-east-1")237 conn.set_sms_attributes(238 attributes={"DefaultSMSType": "Transactional", "test": "test"}...

Full Screen

Full Screen

notification_helper.py

Source: notification_helper.py Github

copy

Full Screen

1from boto import sns,regioninfo2from credentials import *3conn = sns.SNSConnection(aws_access_key_id=aws_access_key_id,aws_secret_access_key=aws_secret_access_key,region=regioninfo.RegionInfo(None, name=region_name, endpoint=region_endpoint))4def create_platform_endpoint(token,devicetype,custom_user_data=None,attributes=None):5 """ 6 token is reg_id for GCM and for APNS it is device token 7 here platform_application_arn will be changed according to the devicetype8 """9 #if int(devicetype) == 0:10 platform_endpoint = conn.create_platform_endpoint(platform_application_arn=platform_application_arn_android,token=token)11 #else:12 #platform_endpoint = conn.create_platform_endpoint(platform_application_arn=platform_application_arn_ios,token=token)13 EndpointArn = platform_endpoint["CreatePlatformEndpointResponse"]["CreatePlatformEndpointResult"].get("EndpointArn",None)14 return EndpointArn15def get_topic_arn(topic_name):16 """ 17 this method gives TopicArn for a topic18 It creates the topic or returns the TopicArn19 if it already exists 20 """21 Topic = conn.create_topic(topic_name)22 TopicArn = Topic["CreateTopicResponse"]["CreateTopicResult"].get("TopicArn",None)23 return TopicArn24def subscribe_to_topic(TopicArn,EndpointArn,protocol='application'):25 """ 26 Pass the EndpointArn you get from create_platform_endpoint method ...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

13 Best Java Testing Frameworks For 2023

The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.

QA Innovation – Using the senseshaping concept to discover customer needs

QA Innovation - Using the senseshaping concept to discover customer needsQA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.

Best 23 Web Design Trends To Follow In 2023

Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.

Acquiring Employee Support for Change Management Implementation

Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.

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