How to use get_source_from_raw method in localstack

Best Python code snippet using localstack_python

ses_starter.py

Source:ses_starter.py Github

copy

Full Screen

...6from localstack.utils.common import to_str7from localstack.services.infra import start_moto_server8LOGGER = logging.getLogger(__name__)9def apply_patches():10 def get_source_from_raw(raw_data):11 entities = raw_data.split('\n')12 for entity in entities:13 if 'From: ' in entity:14 return entity.replace('From: ', '').strip()15 return None16 email_responses_send_raw_email_orig = email_responses.send_raw_email17 def email_responses_send_raw_email(self):18 (source, ) = self.querystring.get('Source', [''])19 if source.strip():20 return email_responses_send_raw_email_orig(self)21 raw_data = to_str(base64.b64decode(self.querystring.get('RawMessage.Data')[0]))22 LOGGER.debug('Raw email:\n%s' % raw_data)23 source = get_source_from_raw(raw_data)24 if not source:25 raise MessageRejectedError('Source not specified')26 self.querystring['Source'] = [source]27 return email_responses_send_raw_email_orig(self)28 email_responses.send_raw_email = email_responses_send_raw_email29 email_responses_send_email_orig = email_responses.send_email30 def email_responses_send_email(self):31 bodydatakey = 'Message.Body.Text.Data'32 if 'Message.Body.Html.Data' in self.querystring:33 bodydatakey = 'Message.Body.Html.Data'34 body = self.querystring.get(bodydatakey)[0]35 source = self.querystring.get('Source')[0]36 subject = self.querystring.get('Message.Subject.Data')[0]37 destinations = {'ToAddresses': [], 'CcAddresses': [], 'BccAddresses': []}...

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