How to use describe_active_receipt_rule_set method in localstack

Best Python code snippet using localstack_python

ses_wait_for_verification_and_create_rule_set.py

Source: ses_wait_for_verification_and_create_rule_set.py Github

copy

Full Screen

...43 email_address = 'admin@' + self.domain44 response_data['EmailAddress'] = email_address45 response_data['Domain'] = self.domain46 if self.request_type == 'Create':47 result = self.ses.describe_active_receipt_rule_set()48 rule_exists = False49 rule_names = []50 if 'Metadata' in result and 'Name' in result['Metadata']:51 self.rule_set_name = result['Metadata']['Name']52 rule_names = list(map(lambda rule: rule['Name'], result['Rules']))53 rule_exists = self.rule_name in rule_names54 else:55 self.ses.create_receipt_rule_set(RuleSetName=self.rule_set_name)56 self.ses.set_active_receipt_rule_set(RuleSetName=self.rule_set_name)57 if not rule_exists:58 self.create_rule(email_address, rule_names)59 elif self.request_type == 'Delete':60 result = self.ses.describe_active_receipt_rule_set()61 if 'Metadata' in result and 'Name' in result['Metadata']:62 print('Active rule set exists')63 active_rule_set_name = result['Metadata']['Name']64 rule_names = list(map(lambda rule: rule['Name'], result['Rules']))65 rule_exists = self.rule_name in rule_names66 if rule_exists:67 print('Rule ' + self.rule_name + ' exists. Deleting it...')68 self.ses.delete_receipt_rule(RuleSetName=active_rule_set_name, RuleName=self.rule_name)69 if active_rule_set_name == self.rule_set_name:70 print('RuleSet was created by stack. Deleting it...')71 self.ses.set_active_receipt_rule_set()72 self.ses.delete_receipt_rule_set(RuleSetName=active_rule_set_name)73 cfnresponse.send(self.event, self.context, cfnresponse.SUCCESS, response_data)74 except Exception as e:...

Full Screen

Full Screen

test_active_rule_set_provider.py

Source: test_active_rule_set_provider.py Github

copy

Full Screen

1import uuid2import datetime3from dateutil.tz import tzutc4import botocore5from botocore.stub import Stubber6from active_rule_set_provider import handler, provider7def test_create_no_existing_rule_set():8 ses = botocore.session.get_session().create_client("ses")9 stubber = Stubber(ses)10 stubber.add_response(11 "describe_active_receipt_rule_set", no_active_receipt_rule_set_response12 )13 stubber.add_response(14 "set_active_receipt_rule_set",15 no_active_receipt_rule_set_response,16 {"RuleSetName": "lists.binx.io"},17 )18 stubber.activate()19 provider._ses = ses20 request = Request("Create", "lists.binx.io")21 response = handler(request, {})22 assert response["Status"] == "SUCCESS", response["Reason"]23 stubber.assert_no_pending_responses()24def test_create_fails_existing_rule_set():25 ses = botocore.session.get_session().create_client("ses")26 stubber = Stubber(ses)27 stubber.add_response(28 "describe_active_receipt_rule_set", active_receipt_rule_set_response29 )30 stubber.activate()31 provider._ses = ses32 request = Request("Create", "lists.binx.io")33 response = handler(request, {})34 assert response["Status"] == "FAILED", response["Reason"]35 assert (36 response["Reason"]37 == "active receipt rule set is already set in region eu-west-1 - lists.binx.io"38 )39 stubber.assert_no_pending_responses()40def test_update_receipt_rule_set():41 ses = botocore.session.get_session().create_client("ses")42 stubber = Stubber(ses)43 stubber.add_response(44 "set_active_receipt_rule_set",45 no_active_receipt_rule_set_response,46 {"RuleSetName": "lists.xebia.com"},47 )48 stubber.activate()49 provider._ses = ses50 request = Request("Update", "lists.xebia.com")51 response = handler(request, {})52 assert response["Status"] == "SUCCESS", response["Reason"]53 stubber.assert_no_pending_responses()54def test_update_receipt_change_region_with_existing_rule_set():55 ses = botocore.session.get_session().create_client("ses")56 stubber = Stubber(ses)57 stubber.add_response(58 "describe_active_receipt_rule_set", active_receipt_rule_set_response59 )60 stubber.activate()61 provider._ses = ses62 request = Request("Update", "lists.xebia.com")63 request["OldResourceProperties"] = {"Region": "us-east-1"}64 response = handler(request, {})65 assert response["Status"] == "FAILED"66 assert (67 response["Reason"]68 == "active receipt rule set is already set in region eu-west-1 - lists.binx.io"69 )70 stubber.assert_no_pending_responses()71def test_activate_receipt_rule_with_rule_set_present():72 ses = botocore.session.get_session().create_client("ses")73 stubber = Stubber(ses)74 stubber.add_response(75 "describe_active_receipt_rule_set", active_receipt_rule_set_response76 )77 stubber.activate()78 provider._ses = ses79 request = Request("Create", "lists.binx.io")80 response = handler(request, {})81 assert response["Status"] == "FAILED", response["Reason"]82 stubber.assert_no_pending_responses()83def test_delete():84 ses = botocore.session.get_session().create_client("ses")85 stubber = Stubber(ses)86 stubber.add_response(87 "set_active_receipt_rule_set", no_active_receipt_rule_set_response, {}88 )89 stubber.activate()90 provider._ses = ses91 request = Request(92 "Delete",93 "lists.binx.io",94 physical_resource_id="active-receipt-rule-set@eu-west-1",95 )96 response = handler(request, {})97 assert response["Status"] == "SUCCESS", response["Reason"]98 stubber.assert_no_pending_responses()99class Request(dict):100 def __init__(101 self,102 request_type,103 ruleset_set_name=None,104 region="eu-west-1",105 physical_resource_id=None,106 ):107 request_id = "request-%s" % uuid.uuid4()108 self.update(109 {110 "RequestType": request_type,111 "ResponseURL": "https:/​/​httpbin.org/​put",112 "StackId": "arn:aws:cloudformation:us-west-2:EXAMPLE/​stack-name/​guid",113 "RequestId": request_id,114 "ResourceType": "Custom::SESActiveReceiptRuleSet",115 "LogicalResourceId": "MyReceiptRuleSet",116 "ResourceProperties": {117 "RuleSetName": ruleset_set_name,118 "Region": region,119 },120 }121 )122 self["PhysicalResourceId"] = (123 physical_resource_id124 if physical_resource_id125 else "initial-%s" % str(uuid.uuid4())126 )127active_receipt_rule_set_response = {128 "Metadata": {129 "Name": "lists.binx.io",130 "CreatedTimestamp": datetime.datetime(131 2019, 11, 15, 23, 23, 18, 370000, tzinfo=tzutc()132 ),133 },134 "Rules": [135 {136 "Name": "lists.binx.io",137 "Enabled": True,138 "TlsPolicy": "Require",139 "Recipients": ["lists.binx.io"],140 "Actions": [141 {142 "S3Action": {143 "BucketName": "dev-mailing-list-archive-binx-io",144 "ObjectKeyPrefix": "/​incoming/​",145 }146 }147 ],148 "ScanEnabled": True,149 }150 ],151 "ResponseMetadata": {152 "RequestId": "84009ed0-52b5-48ce-8a3b-897a3ff72ef1",153 "HTTPStatusCode": 200,154 "HTTPHeaders": {155 "x-amzn-requestid": "84009ed0-52b5-48ce-8a3b-897a3ff72ef1",156 "content-type": "text/​xml",157 "content-length": "999",158 "date": "Sat, 16 Nov 2019 17:57:52 GMT",159 },160 "RetryAttempts": 0,161 },162}163no_active_receipt_rule_set_response = {164 "ResponseMetadata": {165 "RequestId": "2c7bd3fe-730c-4d24-b9a5-1942193a091a",166 "HTTPStatusCode": 200,167 "HTTPHeaders": {168 "x-amzn-requestid": "2c7bd3fe-730c-4d24-b9a5-1942193a091a",169 "content-type": "text/​xml",170 "content-length": "275",171 "date": "Sat, 16 Nov 2019 17:58:29 GMT",172 },173 "RetryAttempts": 0,174 }...

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