mirror of
https://framagit.org/la-chariotte/la-chariotte.git
synced 2025-05-02 03:42:26 +02:00
correct test unit
This commit is contained in:
parent
39dcaf637d
commit
8b79492508
3 changed files with 44 additions and 6 deletions
|
@ -395,7 +395,7 @@ class ExportGroupedOrderToCSVView(GroupedOrderExportView):
|
||||||
row.append(str(order.price).replace(".", ","))
|
row.append(str(order.price).replace(".", ","))
|
||||||
row.append(order.author.email)
|
row.append(order.author.email)
|
||||||
row.append(f"'{order.author.phone}")
|
row.append(f"'{order.author.phone}")
|
||||||
row.append(f'\'{order.created_date.strftime("%d %B %Y %H:%M:%S")}')
|
row.append(f'\'{order.created_date.strftime("%d %B %Y %H:%M")}')
|
||||||
row.append(f"'{order.note}")
|
row.append(f"'{order.note}")
|
||||||
writer.writerow(row)
|
writer.writerow(row)
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ from django import http
|
||||||
from django.contrib.auth.mixins import UserPassesTestMixin
|
from django.contrib.auth.mixins import UserPassesTestMixin
|
||||||
from django.shortcuts import get_object_or_404, render
|
from django.shortcuts import get_object_or_404, render
|
||||||
from django.urls import reverse, reverse_lazy
|
from django.urls import reverse, reverse_lazy
|
||||||
from django.views import generic
|
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
from django.views import generic
|
||||||
|
|
||||||
from la_chariotte.mail.utils import send_order_confirmation_mail
|
from la_chariotte.mail.utils import send_order_confirmation_mail
|
||||||
|
|
||||||
|
@ -49,7 +49,12 @@ def place_order(request, code):
|
||||||
author = OrderAuthor.objects.create(
|
author = OrderAuthor.objects.create(
|
||||||
first_name=first_name, last_name=last_name, email=email, phone=phone
|
first_name=first_name, last_name=last_name, email=email, phone=phone
|
||||||
)
|
)
|
||||||
order = Order.objects.create(author=author, grouped_order=grouped_order, note=note, created_date=timezone.now())
|
order = Order.objects.create(
|
||||||
|
author=author,
|
||||||
|
grouped_order=grouped_order,
|
||||||
|
note=note,
|
||||||
|
created_date=timezone.now(),
|
||||||
|
)
|
||||||
|
|
||||||
# add items to the order
|
# add items to the order
|
||||||
error_message = None
|
error_message = None
|
||||||
|
|
|
@ -1631,6 +1631,7 @@ class TestExportGroupedOrderToCSVView:
|
||||||
content = response.content.decode("utf-8")
|
content = response.content.decode("utf-8")
|
||||||
csv_reader = csv.reader(StringIO(content))
|
csv_reader = csv.reader(StringIO(content))
|
||||||
body = list(csv_reader)
|
body = list(csv_reader)
|
||||||
|
created_date = f'\'{timezone.now().strftime("%d %B %Y %H:%M")}'
|
||||||
assert body == [
|
assert body == [
|
||||||
[
|
[
|
||||||
"",
|
"",
|
||||||
|
@ -1640,11 +1641,43 @@ class TestExportGroupedOrderToCSVView:
|
||||||
"Prix de la commande",
|
"Prix de la commande",
|
||||||
"Mail",
|
"Mail",
|
||||||
"Téléphone",
|
"Téléphone",
|
||||||
|
"Date et Heure",
|
||||||
|
"Note",
|
||||||
],
|
],
|
||||||
["", "Prix unitaire TTC (€)", "2,00", "9,00"],
|
["", "Prix unitaire TTC (€)", "2,00", "9,00"],
|
||||||
["Nom", "Prénom"],
|
["Nom", "Prénom"],
|
||||||
["alescargot", "bob", "1", "0", "2,00", "bob2@escargot.fr", "'000"],
|
[
|
||||||
["alescargot", "bobby", "0", "1", "9,00", "bob3@escargot.fr", "'000"],
|
"alescargot",
|
||||||
["lescargot", "bob", "3", "2", "24,00", "bob@escargot.fr", "'000"],
|
"bob",
|
||||||
|
"1",
|
||||||
|
"0",
|
||||||
|
"2,00",
|
||||||
|
"bob2@escargot.fr",
|
||||||
|
"'000",
|
||||||
|
created_date,
|
||||||
|
"'None",
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"alescargot",
|
||||||
|
"bobby",
|
||||||
|
"0",
|
||||||
|
"1",
|
||||||
|
"9,00",
|
||||||
|
"bob3@escargot.fr",
|
||||||
|
"'000",
|
||||||
|
created_date,
|
||||||
|
"'None",
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"lescargot",
|
||||||
|
"bob",
|
||||||
|
"3",
|
||||||
|
"2",
|
||||||
|
"24,00",
|
||||||
|
"bob@escargot.fr",
|
||||||
|
"'000",
|
||||||
|
created_date,
|
||||||
|
"'None",
|
||||||
|
],
|
||||||
["", "TOTAL", "4", "3", "35,00"],
|
["", "TOTAL", "4", "3", "35,00"],
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue