mirror of
https://github.com/ae-utbm/sith.git
synced 2026-03-13 23:25:00 +00:00
unify eboutic and regular counter price selection
This commit is contained in:
@@ -16,7 +16,7 @@ from counter.forms import (
|
||||
ScheduledProductActionForm,
|
||||
ScheduledProductActionFormSet,
|
||||
)
|
||||
from counter.models import Product, ScheduledProductAction
|
||||
from counter.models import Product, ProductType, ScheduledProductAction
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@@ -47,8 +47,7 @@ def test_create_actions_alongside_product():
|
||||
form = ProductForm(
|
||||
data={
|
||||
"name": "foo",
|
||||
"description": "bar",
|
||||
"product_type": product.product_type_id,
|
||||
"product_type": ProductType.objects.first(),
|
||||
"club": product.club_id,
|
||||
"code": "FOO",
|
||||
"purchase_price": 1.0,
|
||||
@@ -63,6 +62,7 @@ def test_create_actions_alongside_product():
|
||||
"action-0-trigger_at": trigger_at,
|
||||
},
|
||||
)
|
||||
form.is_valid()
|
||||
assert form.is_valid()
|
||||
product = form.save()
|
||||
action = ScheduledProductAction.objects.last()
|
||||
|
||||
@@ -39,6 +39,7 @@ from counter.models import (
|
||||
Counter,
|
||||
Customer,
|
||||
Permanency,
|
||||
ProductType,
|
||||
Refilling,
|
||||
ReturnableProduct,
|
||||
Selling,
|
||||
@@ -238,31 +239,38 @@ class TestCounterClick(TestFullClickBase):
|
||||
old_subscriber_group = Group.objects.get(
|
||||
id=settings.SITH_GROUP_OLD_SUBSCRIBERS_ID
|
||||
)
|
||||
_product_recipe = product_recipe.extend(product_type=baker.make(ProductType))
|
||||
|
||||
cls.gift = price_recipe.make(amount=-1.5, groups=[subscriber_group])
|
||||
cls.gift = price_recipe.make(
|
||||
amount=-1.5, groups=[subscriber_group], product=_product_recipe.make()
|
||||
)
|
||||
cls.beer = price_recipe.make(
|
||||
groups=[subscriber_group],
|
||||
amount=1.5,
|
||||
product=product_recipe.make(limit_age=18),
|
||||
product=_product_recipe.make(limit_age=18),
|
||||
)
|
||||
cls.beer_tap = price_recipe.make(
|
||||
groups=[subscriber_group],
|
||||
amount=1.5,
|
||||
product=product_recipe.make(limit_age=18, tray=True),
|
||||
product=_product_recipe.make(limit_age=18, tray=True),
|
||||
)
|
||||
cls.snack = price_recipe.make(
|
||||
groups=[subscriber_group, old_subscriber_group],
|
||||
amount=1.5,
|
||||
product=product_recipe.make(limit_age=0),
|
||||
product=_product_recipe.make(limit_age=0),
|
||||
)
|
||||
cls.stamps = price_recipe.make(
|
||||
groups=[subscriber_group],
|
||||
amount=1.5,
|
||||
product=product_recipe.make(limit_age=0),
|
||||
product=_product_recipe.make(limit_age=0),
|
||||
)
|
||||
ReturnableProduct.objects.all().delete()
|
||||
cls.cons = price_recipe.make(amount=1, groups=[subscriber_group])
|
||||
cls.dcons = price_recipe.make(amount=-1, groups=[subscriber_group])
|
||||
cls.cons = price_recipe.make(
|
||||
amount=1, groups=[subscriber_group], product=_product_recipe.make()
|
||||
)
|
||||
cls.dcons = price_recipe.make(
|
||||
amount=-1, groups=[subscriber_group], product=_product_recipe.make()
|
||||
)
|
||||
baker.make(
|
||||
ReturnableProduct,
|
||||
product=cls.cons.product,
|
||||
@@ -575,18 +583,17 @@ class TestCounterClick(TestFullClickBase):
|
||||
group = baker.make(Group)
|
||||
customer = baker.make(Customer)
|
||||
group.users.add(customer.user)
|
||||
_product_recipe = product_recipe.extend(
|
||||
counters=[counter], product_type=baker.make(ProductType)
|
||||
)
|
||||
price_recipe.make(
|
||||
_quantity=2,
|
||||
product=iter(
|
||||
product_recipe.make(archived=True, counters=[counter], _quantity=2)
|
||||
),
|
||||
product=iter(_product_recipe.make(archived=True, _quantity=2)),
|
||||
groups=[group],
|
||||
)
|
||||
unarchived_prices = price_recipe.make(
|
||||
_quantity=2,
|
||||
product=iter(
|
||||
product_recipe.make(archived=False, counters=[counter], _quantity=2)
|
||||
),
|
||||
product=iter(_product_recipe.make(archived=False, _quantity=2)),
|
||||
groups=[group],
|
||||
)
|
||||
customer_prices = counter.get_prices_for(customer)
|
||||
|
||||
Reference in New Issue
Block a user