Пример #1
0
def test_valid_voucher_limit(settings, limit, value):
    voucher = Voucher(code='unique',
                      type=VoucherType.SHIPPING,
                      discount_value_type=DiscountValueType.FIXED,
                      discount_value=Price(10, currency='USD'),
                      limit=limit)
    voucher.validate_limit(value)
Пример #2
0
def test_valid_voucher_limit(settings, limit, value):
    voucher = Voucher(
        code='unique', type=Voucher.SHIPPING_TYPE,
        discount_value_type=Voucher.DISCOUNT_VALUE_FIXED,
        discount_value=Price(10, currency='USD'),
        limit=limit)
    voucher.validate_limit(value)
Пример #3
0
def test_valid_voucher_limit(settings, limit, value):
    voucher = Voucher(
        code='unique', type=VoucherType.SHIPPING,
        discount_value_type=DiscountValueType.FIXED,
        discount_value=Money(10, currency='USD'),
        limit=limit)
    voucher.validate_limit(TaxedMoney(net=value, gross=value))
Пример #4
0
def test_valid_voucher_limit(settings, limit, value):
    voucher = Voucher(
        code='unique', type=VoucherType.SHIPPING,
        discount_value_type=DiscountValueType.FIXED,
        discount_value=Price(10, currency='USD'),
        limit=limit)
    voucher.validate_limit(value)
Пример #5
0
def test_voucher_limit_validation(settings, limit, value, valid):
    voucher = Voucher(
        code='unique', type=Voucher.SHIPPING_TYPE,
        discount_value_type=Voucher.DISCOUNT_VALUE_FIXED,
        discount_value=Price(10, currency='USD'),
        limit=limit)
    if valid:
        voucher.validate_limit(value)
    else:
        with pytest.raises(NotApplicable) as e:
            voucher.validate_limit(value)
            msg = 'This offer is only valid for orders over %(amount)s.' % {
                'amount': net(limit)}
            assert str(e.value) == msg
Пример #6
0
def test_voucher_limit_validation(settings, limit, value, valid):
    voucher = Voucher(code='unique',
                      type=Voucher.SHIPPING_TYPE,
                      discount_value_type=Voucher.DISCOUNT_VALUE_FIXED,
                      discount_value=Price(10, currency='USD'),
                      limit=limit)
    if valid:
        voucher.validate_limit(value)
    else:
        with pytest.raises(NotApplicable) as e:
            voucher.validate_limit(value)
            msg = 'This offer is only valid for orders over %(amount)s.' % {
                'amount': net(limit)
            }
            assert str(e.value) == msg