Пример #1
0
def test_get_voucher_discount_all_products_not_applicable(
    prices,
    total,
    min_amount_spent,
    total_quantity,
    min_checkout_items_quantity,
    discount_value_type,
    discount_value,
    voucher_type,
    apply_once_per_order,
):
    prices = [Money(price, "USD") for price in prices]
    voucher = Voucher(
        code="unique",
        type=voucher_type,
        discount_value_type=discount_value_type,
        discount_value=discount_value,
        apply_once_per_order=apply_once_per_order,
        min_amount_spent=get_min_amount_spent(min_amount_spent),
        min_checkout_items_quantity=min_checkout_items_quantity,
    )
    voucher.save()
    total = Money(total, "USD")
    with pytest.raises(NotApplicable):
        get_products_voucher_discount(voucher, prices, total, total_quantity)
Пример #2
0
def test_get_voucher_discount_all_products(
    prices,
    total,
    min_amount_spent,
    total_quantity,
    min_checkout_items_quantity,
    discount_value_type,
    discount_value,
    voucher_type,
    apply_once_per_order,
    expected_value,
):
    prices = [Money(price, "USD") for price in prices]
    voucher = Voucher(
        code="unique",
        type=voucher_type,
        discount_value_type=discount_value_type,
        discount_value=discount_value,
        apply_once_per_order=apply_once_per_order,
        min_amount_spent=get_min_amount_spent(min_amount_spent),
        min_checkout_items_quantity=min_checkout_items_quantity,
    )
    voucher.save()
    total = Money(total, "USD")
    discount = get_products_voucher_discount(voucher, prices, total,
                                             total_quantity)
    assert discount == Money(expected_value, "USD")
def test_get_voucher_discount_all_products(
        prices, discount_value_type, discount_value, voucher_type,
        expected_value):
    prices = [
        TaxedMoney(net=Money(price, 'USD'), gross=Money(price, 'USD'))
        for price in prices]
    voucher = Voucher(
        code='unique', type=voucher_type,
        discount_value_type=discount_value_type,
        discount_value=discount_value, apply_once_per_order=True)
    voucher.save()
    discount = get_products_voucher_discount(voucher, prices)
    assert discount == Money(expected_value, 'USD')
Пример #4
0
def test_get_voucher_discount_all_products(
    prices, discount_value_type, discount_value, voucher_type, expected_value
):
    prices = [Money(price, "USD") for price in prices]
    voucher = Voucher(
        code="unique",
        type=voucher_type,
        discount_value_type=discount_value_type,
        discount_value=discount_value,
    )
    voucher.save()
    discount = get_products_voucher_discount(voucher, prices)
    assert discount == Money(expected_value, "USD")
Пример #5
0
def test_get_voucher_discount_all_products(
        prices, discount_value_type, discount_value, voucher_type,
        expected_value):
    prices = [
        TaxedMoney(net=Money(price, 'USD'), gross=Money(price, 'USD'))
        for price in prices]
    voucher = Voucher(
        code='unique', type=voucher_type,
        discount_value_type=discount_value_type,
        discount_value=discount_value, apply_once_per_order=True)
    voucher.save()
    discount = get_products_voucher_discount(voucher, prices)
    assert discount == Money(expected_value, 'USD')