mirror of
https://framagit.org/la-chariotte/la-chariotte.git
synced 2025-04-30 10:52:40 +02:00
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
import pytest
|
|
from django.urls import reverse
|
|
|
|
from la_chariotte import settings
|
|
from la_chariotte.order.models import GroupedOrder
|
|
|
|
pytestmark = pytest.mark.django_db
|
|
|
|
|
|
def test_send_order_confirmation_mail(mailoutbox, simple_grouped_order, client):
|
|
"""
|
|
When a user orders, they receive a confirmation email
|
|
"""
|
|
item = simple_grouped_order.item_set.first()
|
|
|
|
# the user places an order
|
|
order_url = reverse(
|
|
"order:order",
|
|
kwargs={
|
|
"code": simple_grouped_order.code,
|
|
},
|
|
)
|
|
response = client.post(
|
|
order_url,
|
|
{
|
|
f"quantity_{item.pk}": [4, 0],
|
|
"first_name": "Prénom",
|
|
"last_name": "Nom",
|
|
"phone": "0645632569",
|
|
"email": "test@example.com",
|
|
"note": "",
|
|
},
|
|
)
|
|
assert len(mailoutbox) == 1
|
|
m = mailoutbox[0]
|
|
assert (
|
|
m.subject
|
|
== f"[{settings.PROJECT_NAME}] Votre commande pour «Test grouped order»"
|
|
)
|
|
assert f"{settings.BASE_URL}" in m.alternatives[0][0]
|
|
assert m.alternatives[0][1] == "text/html"
|
|
assert "test@example.com" in mailoutbox[0].to
|