Beispiel #1
0
def test_get_value_voucher_discount(
        total, limit, discount_value, discount_value_type, expected_value):
    voucher = Voucher(
        code='unique', type=VoucherType.VALUE,
        discount_value_type=discount_value_type,
        discount_value=discount_value,
        limit=Money(limit, 'USD') if limit is not None else None)
    total_price = TaxedMoney(
        net=Money(total, 'USD'), gross=Money(total, 'USD'))
    discount = get_value_voucher_discount(voucher, total_price)
    assert discount == Money(expected_value, 'USD')
Beispiel #2
0
def test_get_value_voucher_discount_not_applicable(
    total,
    min_amount_spent,
    total_quantity,
    min_checkout_items_quantity,
    discount_value,
    discount_value_type,
):
    voucher = Voucher(
        code="unique",
        type=VoucherType.ENTIRE_ORDER,
        discount_value_type=discount_value_type,
        discount_value=discount_value,
        min_amount_spent=get_min_amount_spent(min_amount_spent),
        min_checkout_items_quantity=min_checkout_items_quantity,
    )
    voucher.save()
    total_price = Money(total, "USD")
    with pytest.raises(NotApplicable):
        get_value_voucher_discount(voucher, total_price, total_quantity)
Beispiel #3
0
def test_get_value_voucher_discount(total, min_amount_spent, discount_value,
                                    discount_value_type, expected_value):
    voucher = Voucher(code='unique',
                      type=VoucherType.VALUE,
                      discount_value_type=discount_value_type,
                      discount_value=discount_value,
                      min_amount_spent=get_min_amount_spent(min_amount_spent))
    voucher.save()
    total_price = TaxedMoney(net=Money(total, 'USD'),
                             gross=Money(total, 'USD'))
    discount = get_value_voucher_discount(voucher, total_price)
    assert discount == Money(expected_value, 'USD')
Beispiel #4
0
def test_get_value_voucher_discount(
        total, min_amount_spent, discount_value, discount_value_type,
        expected_value):
    voucher = Voucher(
        code='unique', type=VoucherType.VALUE,
        discount_value_type=discount_value_type,
        discount_value=discount_value,
        min_amount_spent=get_min_amount_spent(min_amount_spent))
    voucher.save()
    total_price = TaxedMoney(
        net=Money(total, 'USD'), gross=Money(total, 'USD'))
    discount = get_value_voucher_discount(voucher, total_price)
    assert discount == Money(expected_value, 'USD')
Beispiel #5
0
def test_get_value_voucher_discount(
    total, min_amount_spent, discount_value, discount_value_type, expected_value
):
    voucher = Voucher(
        code="unique",
        type=VoucherType.ENTIRE_ORDER,
        discount_value_type=discount_value_type,
        discount_value=discount_value,
        min_amount_spent=get_min_amount_spent(min_amount_spent),
    )
    voucher.save()
    total_price = Money(total, "USD")
    discount = get_value_voucher_discount(voucher, total_price)
    assert discount == Money(expected_value, "USD")