Ejemplo n.º 1
0
def test_send_fulfillment_emails_with_tracking_number_as_url(
        mocked_templated_email, template, send_email, fulfilled_order,
        site_settings):
    fulfillment = fulfilled_order.fulfillments.first()
    fulfillment.tracking_number = "https://www.example.com"
    fulfillment.save()
    assert fulfillment.is_tracking_number_url
    send_email(order_pk=fulfilled_order.pk, fulfillment_pk=fulfillment.pk)
    email_data = emails.collect_data_for_fullfillment_email(
        fulfilled_order.pk, template, fulfillment.pk)

    recipients = [fulfilled_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)
Ejemplo n.º 2
0
def test_collect_data_for_fullfillment_email(fulfilled_order):
    template = emails.CONFIRM_FULFILLMENT_TEMPLATE
    fulfillment = fulfilled_order.fulfillments.first()
    email_data = emails.collect_data_for_fullfillment_email(
        fulfilled_order.pk, template, fulfillment.pk)
    email_context = email_data['context']
    assert email_context['fulfillment'] == fulfillment
Ejemplo n.º 3
0
def test_collect_data_for_fullfillment_email(fulfilled_order):
    template = emails.CONFIRM_FULFILLMENT_TEMPLATE
    fulfillment = fulfilled_order.fulfillments.first()
    fulfillment_data = emails.collect_data_for_fullfillment_email(
        fulfilled_order.pk, template, fulfillment.pk)
    email_context = fulfillment_data["context"]
    assert email_context["fulfillment"] == fulfillment
    email_data = emails.collect_data_for_email(fulfilled_order.pk, template)
    assert all(
        [key in email_context for key, item in email_data["context"].items()])
Ejemplo n.º 4
0
def test_collect_data_for_fullfillment_email(fulfilled_order):
    template = emails.CONFIRM_FULFILLMENT_TEMPLATE
    fulfillment = fulfilled_order.fulfillments.first()
    fulfillment_data = emails.collect_data_for_fullfillment_email(
        fulfilled_order.pk, template, fulfillment.pk
    )
    email_context = fulfillment_data["context"]
    assert email_context["fulfillment"] == fulfillment
    email_data = emails.collect_data_for_email(fulfilled_order.pk, template)
    assert all([key in email_context for key, item in email_data["context"].items()])
Ejemplo n.º 5
0
def test_send_fulfillment_emails(mocked_templated_email, template, send_email,
                                 fulfilled_order):
    fulfillment = fulfilled_order.fulfillments.first()
    send_email(order_pk=fulfilled_order.pk, fulfillment_pk=fulfillment.pk)
    email_data = emails.collect_data_for_fullfillment_email(
        fulfilled_order.pk, template, fulfillment.pk)
    mocked_templated_email.assert_called_once_with(
        recipient_list=[fulfilled_order.get_user_current_email()],
        context=email_data['context'],
        from_email=settings.ORDER_FROM_EMAIL,
        template_name=template)
Ejemplo n.º 6
0
def test_send_fulfillment_emails(
        mocked_templated_email, template, send_email, fulfilled_order):
    fulfillment = fulfilled_order.fulfillments.first()
    send_email(order_pk=fulfilled_order.pk, fulfillment_pk=fulfillment.pk)
    email_data = emails.collect_data_for_fullfillment_email(
        fulfilled_order.pk, template, fulfillment.pk)

    recipients = [fulfilled_order.get_user_current_email()]

    expected_call_kwargs = {
        'context': email_data['context'],
        'from_email': settings.ORDER_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)
Ejemplo n.º 7
0
def test_send_fulfillment_emails(
        mocked_templated_email, template, send_email, fulfilled_order,
        settings):
    fulfillment = fulfilled_order.fulfillments.first()
    send_email(order_pk=fulfilled_order.pk, fulfillment_pk=fulfillment.pk)
    email_data = emails.collect_data_for_fullfillment_email(
        fulfilled_order.pk, template, fulfillment.pk)

    recipients = [fulfilled_order.get_user_current_email()]

    expected_call_kwargs = {
        'context': email_data['context'],
        'from_email': settings.ORDER_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)