mirror of
https://github.com/pretix/pretix.git
synced 2026-05-03 14:54:04 +00:00
Refs #145 -- Vouchers that grant discounts
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import datetime
|
||||
import sys
|
||||
from datetime import timedelta
|
||||
from decimal import Decimal
|
||||
|
||||
import pytest
|
||||
from django.conf import settings
|
||||
@@ -406,6 +407,29 @@ class QuotaTestCase(BaseQuotaTestCase):
|
||||
v.clean()
|
||||
|
||||
|
||||
class VoucherTestCase(BaseQuotaTestCase):
|
||||
|
||||
def test_calculate_price_none(self):
|
||||
v = Voucher.objects.create(event=self.event, price_mode='none', value=Decimal('10.00'))
|
||||
v.calculate_price(Decimal('23.42')) == Decimal('23.42')
|
||||
|
||||
def test_calculate_price_set_empty(self):
|
||||
v = Voucher.objects.create(event=self.event, price_mode='set')
|
||||
v.calculate_price(Decimal('23.42')) == Decimal('23.42')
|
||||
|
||||
def test_calculate_price_set(self):
|
||||
v = Voucher.objects.create(event=self.event, price_mode='set', value=Decimal('10.00'))
|
||||
v.calculate_price(Decimal('23.42')) == Decimal('10.00')
|
||||
|
||||
def test_calculate_price_subtract(self):
|
||||
v = Voucher.objects.create(event=self.event, price_mode='subtract', value=Decimal('10.00'))
|
||||
v.calculate_price(Decimal('23.42')) == Decimal('13.42')
|
||||
|
||||
def test_calculate_price_percent(self):
|
||||
v = Voucher.objects.create(event=self.event, price_mode='percent', value=Decimal('23.00'))
|
||||
v.calculate_price(Decimal('100.00')) == Decimal('77.00')
|
||||
|
||||
|
||||
class OrderTestCase(BaseQuotaTestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
Reference in New Issue
Block a user