def test_send_confirmation_emails_without_addresses_for_order( mocked_templated_email, order, site_settings, digital_content ): assert not order.lines.count() template = emails.CONFIRM_ORDER_TEMPLATE add_variant_to_draft_order(order, digital_content.product_variant, quantity=1) order.shipping_address = None order.shipping_method = None order.billing_address = None order.save(update_fields=["shipping_address", "shipping_method", "billing_address"]) redirect_url = "https://www.example.com" emails.send_order_confirmation(order.pk, redirect_url) email_data = emails.collect_data_for_email(order.pk, template, redirect_url) recipients = [order.get_customer_email()] expected_call_kwargs = { "context": email_data["context"], "from_email": site_settings.default_from_email, "template_name": template, } mocked_templated_email.assert_called_once_with( recipient_list=recipients, **expected_call_kwargs ) # Render the email to ensure there is no error email_connection = get_connection() email_connection.get_email_message(to=recipients, **expected_call_kwargs)
def test_send_confirmation_using_templated_email(mocked_templated_email): emails.send_order_confirmation(EMAIL, URL) context = {'site_name': SITE_NAME, 'url': URL} mocked_templated_email.assert_called_once_with( recipient_list=[EMAIL], context=context, from_email=EMAIL_FROM, template_name=emails.CONFIRM_ORDER_TEMPLATE)
def test_send_confirmation_using_templated_email( mocked_templated_email, order): emails.send_order_confirmation(EMAIL, URL, order.pk) context = { 'protocol': 'http', 'domain': DOMAIN, 'site_name': SITE_NAME, 'url': URL, 'order': order} mocked_templated_email.assert_called_once_with( recipient_list=[EMAIL], context=context, from_email=EMAIL_FROM, template_name=emails.CONFIRM_ORDER_TEMPLATE)
def test_send_email_order_confirmation(mocked_templated_email, order, site_settings): template = emails.CONFIRM_ORDER_TEMPLATE redirect_url = "https://www.example.com" emails.send_order_confirmation(order.pk, redirect_url) email_data = emails.collect_data_for_email(order.pk, template, redirect_url) recipients = [order.get_customer_email()] expected_call_kwargs = { "context": email_data["context"], "from_email": site_settings.default_from_email, "template_name": template, } mocked_templated_email.assert_called_once_with( recipient_list=recipients, **expected_call_kwargs ) # Render the email to ensure there is no error email_connection = get_connection() email_connection.get_email_message(to=recipients, **expected_call_kwargs)