def test_sending_email_without_html(self): """Html content is not attached when html block is missing""" self.render_mock.return_value = {SUBJECT: sentinel.subject, TEXT: sentinel.text} send_email(address=sentinel.address, template_name=sentinel.template_name, context=sentinel.context) self.assert_email_constructed() self.email_mock().send.assert_called_once()
def test_sending_email_without_html(self): """Html content is not attached when html block is missing""" self.render_mock.return_value = { SUBJECT: sentinel.subject, TEXT: sentinel.text } send_email(address=sentinel.address, template_name=sentinel.template_name, context=sentinel.context) self.assert_email_constructed() self.email_mock().send.assert_called_once()
def test_sending_email_with_html(self): """Html content is attached when html block present""" self.render_mock.return_value = {SUBJECT: sentinel.subject, TEXT: sentinel.text, HTML: sentinel.html} send_email(address=sentinel.address, template_name=sentinel.template_name, context=sentinel.context) self.assert_email_constructed() self.email_mock().attach_alternative.assert_called_once_with( sentinel.html, 'text/html') self.email_mock().send.assert_called_once()
def test_sending_email_with_html(self): """Html content is attached when html block present""" self.render_mock.return_value = { SUBJECT: sentinel.subject, TEXT: sentinel.text, HTML: sentinel.html } send_email(address=sentinel.address, template_name=sentinel.template_name, context=sentinel.context) self.assert_email_constructed() self.email_mock().attach_alternative.assert_called_once_with( sentinel.html, 'text/html') self.email_mock().send.assert_called_once()
def send_confirmation_email(self): email = self.order.get_user_email() order_url = build_absolute_uri( reverse('order:details', kwargs={'token': self.order.token})) context = {'order_url': order_url} send_email(email, 'payment/emails/confirm_email.txt', context)
def send_confirmation_email(self): email = self.get_user_email() payment_url = build_absolute_uri( reverse('order:payment:index', kwargs={'token': self.token})) context = {'payment_url': payment_url} send_email(email, 'order/emails/confirm_email.txt', context)
def send(self): email = self.cleaned_data['email'] request = self.create_request_instance() confirmation_url = self.local_host + request.get_confirmation_url() context = {'confirmation_url': confirmation_url} send_email(email, self.template, context)