Best Python code snippet using slash
sendGrid.py
Source:sendGrid.py
...29 to_emails=self.to,30 subject=self.subject,31 html_content=self.html_content)32 def send_reset_password(self, toEmail, recoveryPwd):33 template = self._get_html_template(RESET_PASSWORD_TEMPLATE)34 self.html_content = template.replace("%recovery_pwd", recoveryPwd)35 self.subject = RESET_PASSWORD_SUBJECT36 self._set_message()37 self.send()38 def send_verify_email(self, toEmail, name):39 try:40 link = auth.generate_email_verification_link(toEmail)41 template = self._get_html_template(VERIFY_EMAIL_TEMPLATE)42 self.html_content = template.replace("%link", link).replace("%name", name)43 self.subject = VERIFY_EMAIL_SUBJECT44 self._set_message()45 self.send()46 except Exception as e:47 self.logger.error(e)48 def _get_html_template(self, template):49 f = open(template, "r")50 htmlContent = f.read()...
rendering.py
Source:rendering.py
...19 ('#42e4e7', '#e74542',),20 ('#bed0ff', '#83785b',),21 )22 return choice(_support_color_pairs)23def _get_html_template() -> Template:24 env_template = Environment(25 loader=FileSystemLoader(TEMPLATES_DIR),26 autoescape=True27 )28 return env_template.get_template(TEMPLATE_NAME)29def render_html_email(feeds: Tuple[FeedEntity]) -> str:30 template = _get_html_template()31 title_bg_color, title_font_color = color_randomizer()32 email = template.render(33 title_bg_color=title_bg_color,34 title_font_color=title_font_color,35 feed_datetime=TODAY_DATETIME,36 feeds=feeds37 )38 logging.info('Email feed was prepared.')...
email_service.py
Source:email_service.py
...3class EmailServiceImpl:4 def __init__(self, sendgrid):5 self.sendgrid = sendgrid6 @staticmethod7 def _get_html_template(template_name, context):8 templates = {9 'confirm_email': '<a href="{confirm_link}">Click here to confirm email</a>'10 }11 return templates[template_name].format(**context)12 def send_email_address_confirmation(self, email_address, email_token):13 ctx = {14 'confirm_link': '{}://{}:{}/auth/confirm_email/{}'.format(15 settings.WEB_PROTOCOL,16 settings.WEB_HOSTNAME,17 settings.WEB_PORT,18 email_token19 )20 }21 message = Mail(22 from_email='guido.dassori@gmail.com',23 to_emails=email_address,24 subject='Would you please confirm your email address',25 html_content=self._get_html_template('confirm_email', ctx))26 response = self.sendgrid.send(message)...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!