Esempio n. 1
0
def test_send_confirmation_emails_without_addresses_for_payment(
    mocked_templated_email, order, site_settings, digital_content
):

    assert not order.lines.count()

    template = emails.CONFIRM_PAYMENT_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"])

    emails.send_payment_confirmation(order.pk)
    email_data = emails.collect_data_for_email(order.pk, template)

    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)
Esempio n. 2
0
def test_send_order_payment_confirmation(mocked_templated_email):
    emails.send_payment_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_PAYMENT_TEMPLATE)
Esempio n. 3
0
def test_send_order_payment_confirmation(mocked_templated_email):
    emails.send_payment_confirmation(EMAIL, URL)
    context = {
        'protocol': 'http',
        'domain': DOMAIN,
        '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_PAYMENT_TEMPLATE)
Esempio n. 4
0
def test_send_email_payment_confirmation(mocked_templated_email, order, site_settings):
    template = emails.CONFIRM_PAYMENT_TEMPLATE
    emails.send_payment_confirmation(order.pk)
    email_data = emails.collect_data_for_email(order.pk, template)

    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)