How to use verify_email_identity method in localstack

Best Python code snippet using localstack_python

test_ses.py

Source:test_ses.py Github

copy

Full Screen

...4from boto.exception import BotoServerError5import sure # noqa6from moto import mock_ses_deprecated7@mock_ses_deprecated8def test_verify_email_identity():9 conn = boto.connect_ses("the_key", "the_secret")10 conn.verify_email_identity("test@example.com")11 identities = conn.list_identities()12 address = identities["ListIdentitiesResponse"]["ListIdentitiesResult"][13 "Identities"14 ][0]15 address.should.equal("test@example.com")16@mock_ses_deprecated17def test_domain_verify():18 conn = boto.connect_ses("the_key", "the_secret")19 conn.verify_domain_dkim("domain1.com")20 conn.verify_domain_identity("domain2.com")21 identities = conn.list_identities()22 domains = list(23 identities["ListIdentitiesResponse"]["ListIdentitiesResult"]["Identities"]24 )25 domains.should.equal(["domain1.com", "domain2.com"])26@mock_ses_deprecated27def test_delete_identity():28 conn = boto.connect_ses("the_key", "the_secret")29 conn.verify_email_identity("test@example.com")30 conn.list_identities()["ListIdentitiesResponse"]["ListIdentitiesResult"][31 "Identities"32 ].should.have.length_of(1)33 conn.delete_identity("test@example.com")34 conn.list_identities()["ListIdentitiesResponse"]["ListIdentitiesResult"][35 "Identities"36 ].should.have.length_of(0)37@mock_ses_deprecated38def test_send_email():39 conn = boto.connect_ses("the_key", "the_secret")40 conn.send_email.when.called_with(41 "test@example.com", "test subject", "test body", "test_to@example.com"42 ).should.throw(BotoServerError)43 conn.verify_email_identity("test@example.com")44 conn.send_email(45 "test@example.com", "test subject", "test body", "test_to@example.com"46 )47 send_quota = conn.get_send_quota()48 sent_count = int(49 send_quota["GetSendQuotaResponse"]["GetSendQuotaResult"]["SentLast24Hours"]50 )51 sent_count.should.equal(1)52@mock_ses_deprecated53def test_send_html_email():54 conn = boto.connect_ses("the_key", "the_secret")55 conn.send_email.when.called_with(56 "test@example.com",57 "test subject",58 "<span>test body</span>",59 "test_to@example.com",60 format="html",61 ).should.throw(BotoServerError)62 conn.verify_email_identity("test@example.com")63 conn.send_email(64 "test@example.com",65 "test subject",66 "<span>test body</span>",67 "test_to@example.com",68 format="html",69 )70 send_quota = conn.get_send_quota()71 sent_count = int(72 send_quota["GetSendQuotaResponse"]["GetSendQuotaResult"]["SentLast24Hours"]73 )74 sent_count.should.equal(1)75@mock_ses_deprecated76def test_send_raw_email():77 conn = boto.connect_ses("the_key", "the_secret")78 message = email.mime.multipart.MIMEMultipart()79 message["Subject"] = "Test"80 message["From"] = "test@example.com"81 message["To"] = "to@example.com"82 # Message body83 part = email.mime.text.MIMEText("test file attached")84 message.attach(part)85 # Attachment86 part = email.mime.text.MIMEText("contents of test file here")87 part.add_header("Content-Disposition", "attachment; filename=test.txt")88 message.attach(part)89 conn.send_raw_email.when.called_with(90 source=message["From"], raw_message=message.as_string()91 ).should.throw(BotoServerError)92 conn.verify_email_identity("test@example.com")93 conn.send_raw_email(source=message["From"], raw_message=message.as_string())94 send_quota = conn.get_send_quota()95 sent_count = int(96 send_quota["GetSendQuotaResponse"]["GetSendQuotaResult"]["SentLast24Hours"]97 )98 sent_count.should.equal(1)99@mock_ses_deprecated100def test_get_send_statistics():101 conn = boto.connect_ses("the_key", "the_secret")102 conn.send_email.when.called_with(103 "test@example.com",104 "test subject",105 "<span>test body</span>",106 "test_to@example.com",107 format="html",108 ).should.throw(BotoServerError)109 # tests to verify rejects in get_send_statistics110 result = conn.get_send_statistics()111 reject_count = int(112 result["GetSendStatisticsResponse"]["GetSendStatisticsResult"][113 "SendDataPoints"114 ][0]["Rejects"]115 )116 delivery_count = int(117 result["GetSendStatisticsResponse"]["GetSendStatisticsResult"][118 "SendDataPoints"119 ][0]["DeliveryAttempts"]120 )121 reject_count.should.equal(1)122 delivery_count.should.equal(0)123 conn.verify_email_identity("test@example.com")124 conn.send_email(125 "test@example.com", "test subject", "test body", "test_to@example.com"126 )127 # tests to delivery attempts in get_send_statistics128 result = conn.get_send_statistics()129 reject_count = int(130 result["GetSendStatisticsResponse"]["GetSendStatisticsResult"][131 "SendDataPoints"132 ][0]["Rejects"]133 )134 delivery_count = int(135 result["GetSendStatisticsResponse"]["GetSendStatisticsResult"][136 "SendDataPoints"137 ][0]["DeliveryAttempts"]...

Full Screen

Full Screen

send_RI_expire_days_to_ses.py

Source:send_RI_expire_days_to_ses.py Github

copy

Full Screen

...23 ses_verified_emails = get_verified_email_addresses(ses_cli)24 for email in alert_to_emails:25 if ses_verified_emails:26 if email not in ses_verified_emails:27 verify_email_identity(ses_cli, email)28 ses_not_verified_emails.append(email)29 else:30 verify_email_identity(ses_cli, email)31 ses_not_verified_emails.append(email)32 if exp_list:33 alert_to_emails = list(set(alert_to_emails) - set(ses_not_verified_emails))34 for email in alert_to_emails:35 send_html_email(ses_cli, title, message, email, sender_email)36def get_reservation_expires(ec2_cli, days):37 ris = ec2_cli.describe_reserved_instances().get(38 'ReservedInstances', []39 )40 ri = [ r for r in ris if r['State']=='active' ]41 th = ['Instance Type', 'Scope', 'Count', 'Start', 'Expires', 'Term', 'Payment', 'Offering class', 'Charge', 'Plaform', 'State']42 table_head = '<table width="100%" border="0.5"><thead><tr>' + ''.join(['<th>'+t+'</th>' for t in th]) + '</tr></thead>'43 table_content = ''44 to_kst = datetime.timedelta(hours=9)45 46 for r in ri:47 start = (r['Start'] + to_kst).strftime('%Y-%m-%d %H:%M')48 end = (r['End'] + to_kst).strftime('%Y-%m-%d %H:%M')49 term = (r['End']-(datetime.datetime.now(datetime.timezone.utc) + to_kst)).days50 charge = r['RecurringCharges'][0]['Amount']51 charge_unit = r['RecurringCharges'][0]['Frequency']52 if term == days:53 if not table_content:54 table_content += '<tbody><tr>'55 td = [r['InstanceType'], r['Scope'], str(r['InstanceCount']), start, end, str(term) + ' days', r['OfferingType'], r['OfferingClass'], '$' + str(charge) + ' (' + charge_unit + ')', r['ProductDescription'], r['State']]56 table_content += ''.join(['<td>'+t+'</td>' for t in td])57 table_content += '</tr><tr>'58 if table_content:59 table_content = table_content[:-4]60 table_content += '</tbody></table>'61 return table_head,table_content62def get_verified_email_addresses(ses_cli):63 return ses_cli.list_verified_email_addresses().get(64 'VerifiedEmailAddresses', []65 )66def verify_email_identity(ses_cli, email):67 response = ses_cli.verify_email_identity(68 EmailAddress=email69 )70def send_html_email(ses_cli, title, message, email, s_email):71 CHARSET = "UTF-8"72 HTML_EMAIL_CONTENT = message73 response = ses_cli.send_email(74 Destination={75 "ToAddresses": [76 email,77 ],78 },79 Message={80 "Body": {81 "Html": {...

Full Screen

Full Screen

aws_test.py

Source:aws_test.py Github

copy

Full Screen

...11def test_ses_email(aws_credentials):12 ses = boto3.client("ses", region_name="us-east-1")13 logs = pd.DataFrame({"errors": ["ex1", "ex2", "ex3"]})14 send_aws_email(logs)15 assert ses.verify_email_identity(EmailAddress="jyablonski9@gmail.com")16@mock_ses17def test_ses_execution_logs(aws_credentials):18 ses = boto3.client("ses", region_name="us-east-1")19 logs = pd.DataFrame({"errors": ["ex1", "ex2", "ex3"]})20 execute_email_function(logs)21 assert ses.verify_email_identity(EmailAddress="jyablonski9@gmail.com")22@mock_ses23def test_ses_execution_no_logs(aws_credentials):24 ses = boto3.client("ses", region_name="us-east-1")25 logs = pd.DataFrame({"errors": []})26 send_aws_email(logs)27 assert ses.verify_email_identity(EmailAddress="jyablonski9@gmail.com")28@mock_s329def test_write_to_s3_validated(player_stats_data):30 conn = boto3.resource("s3", region_name="us-east-1")31 today = datetime.now().date()32 month = datetime.now().month33 month_prefix = get_leading_zeroes(month)34 player_stats_data.schema = "Validated"35 conn.create_bucket(Bucket="moto_test_bucket")36 write_to_s3("player_stats_data", player_stats_data, bucket="moto_test_bucket")37 bucket = conn.Bucket("moto_test_bucket")38 contents = [_.key for _ in bucket.objects.all()]39 assert (40 contents[0]41 == f"player_stats_data/validated/{month_prefix}/player_stats_data-{today}.parquet"...

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