mirror of
https://github.com/ae-utbm/sith.git
synced 2025-08-29 12:15:44 +00:00
Apply review comments
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
@@ -9,16 +9,13 @@ from django.utils.timezone import localdate
|
|||||||
from model_bakery import baker
|
from model_bakery import baker
|
||||||
from pytest_django.asserts import assertRedirects
|
from pytest_django.asserts import assertRedirects
|
||||||
|
|
||||||
from club.models import Club
|
|
||||||
from core.baker_recipes import subscriber_user
|
from core.baker_recipes import subscriber_user
|
||||||
from core.models import Group, User
|
from core.models import Group, User
|
||||||
from counter.baker_recipes import product_recipe
|
from counter.baker_recipes import product_recipe, refill_recipe, sale_recipe
|
||||||
from counter.models import (
|
from counter.models import (
|
||||||
Counter,
|
Counter,
|
||||||
Customer,
|
Customer,
|
||||||
ProductType,
|
ProductType,
|
||||||
Refilling,
|
|
||||||
Selling,
|
|
||||||
get_eboutic,
|
get_eboutic,
|
||||||
)
|
)
|
||||||
from counter.tests.test_counter import BasketItem
|
from counter.tests.test_counter import BasketItem
|
||||||
@@ -45,12 +42,12 @@ def test_eboutic_access_unregistered(client: Client):
|
|||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_eboutic_access_new_customer(client: Client):
|
def test_eboutic_access_new_customer(client: Client):
|
||||||
user = baker.make(User)
|
user = baker.make(User)
|
||||||
assert Customer.objects.filter(user=user).first() is None
|
assert not Customer.objects.filter(user=user).exists()
|
||||||
|
|
||||||
client.force_login(user)
|
client.force_login(user)
|
||||||
|
|
||||||
assert client.get(reverse("eboutic:main")).status_code == 200
|
assert client.get(reverse("eboutic:main")).status_code == 200
|
||||||
assert Customer.objects.filter(user=user).first()
|
assert Customer.objects.filter(user=user).exists()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
@@ -69,22 +66,33 @@ def test_eboutic_access_old_customer(client: Client):
|
|||||||
("sellings", "refillings", "expected"),
|
("sellings", "refillings", "expected"),
|
||||||
(
|
(
|
||||||
([], [], None),
|
([], [], None),
|
||||||
([datetime(2025, 3, 7, 1, 2, 3)], [], datetime(2025, 3, 7, 1, 2, 3)),
|
|
||||||
([], [datetime(2025, 3, 7, 1, 2, 3)], datetime(2025, 3, 7, 1, 2, 3)),
|
|
||||||
(
|
(
|
||||||
[datetime(2025, 2, 7, 1, 2, 3)],
|
[datetime(2025, 3, 7, 1, 2, 3, tzinfo=timezone.utc)],
|
||||||
[datetime(2025, 3, 7, 1, 2, 3)],
|
[],
|
||||||
datetime(2025, 3, 7, 1, 2, 3),
|
datetime(2025, 3, 7, 1, 2, 3, tzinfo=timezone.utc),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[datetime(2025, 3, 7, 1, 2, 3)],
|
[],
|
||||||
[datetime(2025, 2, 7, 1, 2, 3)],
|
[datetime(2025, 3, 7, 1, 2, 3, tzinfo=timezone.utc)],
|
||||||
datetime(2025, 3, 7, 1, 2, 3),
|
datetime(2025, 3, 7, 1, 2, 3, tzinfo=timezone.utc),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[datetime(2025, 3, 7, 1, 2, 3), datetime(2025, 2, 7, 1, 2, 3)],
|
[datetime(2025, 2, 7, 1, 2, 3, tzinfo=timezone.utc)],
|
||||||
[datetime(2025, 3, 7, 1, 2, 3)],
|
[datetime(2025, 3, 7, 1, 2, 3, tzinfo=timezone.utc)],
|
||||||
datetime(2025, 3, 7, 1, 2, 3),
|
datetime(2025, 3, 7, 1, 2, 3, tzinfo=timezone.utc),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
[datetime(2025, 3, 7, 1, 2, 3, tzinfo=timezone.utc)],
|
||||||
|
[datetime(2025, 2, 7, 1, 2, 3, tzinfo=timezone.utc)],
|
||||||
|
datetime(2025, 3, 7, 1, 2, 3, tzinfo=timezone.utc),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
[
|
||||||
|
datetime(2025, 3, 7, 1, 2, 3, tzinfo=timezone.utc),
|
||||||
|
datetime(2025, 2, 7, 1, 2, 3, tzinfo=timezone.utc),
|
||||||
|
],
|
||||||
|
[datetime(2025, 3, 7, 1, 2, 3, tzinfo=timezone.utc)],
|
||||||
|
datetime(2025, 3, 7, 1, 2, 3, tzinfo=timezone.utc),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -96,24 +104,16 @@ def test_eboutic_basket_expiry(
|
|||||||
):
|
):
|
||||||
eboutic = get_eboutic()
|
eboutic = get_eboutic()
|
||||||
|
|
||||||
user = baker.make(User)
|
customer = baker.make(Customer)
|
||||||
customer = Customer.get_or_create(user)[0]
|
|
||||||
|
|
||||||
client.force_login(user)
|
client.force_login(customer.user)
|
||||||
|
|
||||||
for date in sellings:
|
for date in sellings:
|
||||||
baker.make(
|
sale_recipe.make(
|
||||||
Selling,
|
customer=customer, counter=eboutic, date=date, is_validated=True
|
||||||
customer=customer,
|
|
||||||
counter=eboutic,
|
|
||||||
club=baker.make(Club),
|
|
||||||
seller=user,
|
|
||||||
date=date,
|
|
||||||
is_validated=True, # Ignore not enough money warnings
|
|
||||||
)
|
)
|
||||||
|
|
||||||
for date in refillings:
|
for date in refillings:
|
||||||
baker.make(Refilling, customer=customer, counter=eboutic, date=date)
|
refill_recipe.make(customer=customer, counter=eboutic, date=date)
|
||||||
|
|
||||||
assert (
|
assert (
|
||||||
f'x-data="basket({int(expected.timestamp() * 1000) if expected else "null"})"'
|
f'x-data="basket({int(expected.timestamp() * 1000) if expected else "null"})"'
|
||||||
|
Reference in New Issue
Block a user