Revision fc7747df7177f2f610c55c9709a81e7b0b618806 authored by Jochen Kupperschmidt on 03 January 2026, 00:21:02 UTC, committed by Jochen Kupperschmidt on 03 January 2026, 00:21:02 UTC
1 parent 2e587a4
test_product_with_quantity.py
"""
:Copyright: 2014-2025 Jochen Kupperschmidt
:License: Revised BSD (see `LICENSE` file for details)
"""
from moneyed import EUR, Money
import pytest
from byceps.services.shop.product.models import ProductWithQuantity
@pytest.mark.parametrize(
('quantity', 'expected_amount'),
[
(1, Money('1.99', EUR)),
(2, Money('3.98', EUR)),
(6, Money('11.94', EUR)),
],
)
def test_init_with_positive_quantity(
make_product, quantity: int, expected_amount: Money
):
product = make_product()
pwq = ProductWithQuantity(product, quantity)
assert pwq.product == product
assert pwq.quantity == quantity
assert pwq.amount == expected_amount
def test_init_with_zero_quantity(make_product):
with pytest.raises(ValueError):
ProductWithQuantity(make_product(), 0)
def test_init_with_negative_quantity(make_product):
with pytest.raises(ValueError):
ProductWithQuantity(make_product(), -1)

Computing file changes ...