Fix invalid handling of variations with quota-level vouchers

This commit is contained in:
Raphael Michel
2019-04-25 11:54:03 +02:00
parent 13bf975dd5
commit ef600ceddb
4 changed files with 81 additions and 1 deletions

View File

@@ -650,6 +650,15 @@ class VoucherTestCase(BaseQuotaTestCase):
self.assertTrue(v.applies_to(self.var1.item, self.var1))
self.assertFalse(v.applies_to(self.var1.item, self.var2))
def test_voucher_applicability_variation_through_quota(self):
self.quota.variations.add(self.var1)
self.quota.items.add(self.var1.item)
v = Voucher.objects.create(quota=self.quota, event=self.event)
self.assertFalse(v.applies_to(self.item1))
self.assertTrue(v.applies_to(self.var1.item)) # semantics unclear
self.assertTrue(v.applies_to(self.var1.item, self.var1))
self.assertFalse(v.applies_to(self.var1.item, self.var2))
def test_voucher_no_item_with_quota(self):
with self.assertRaises(ValidationError):
v = Voucher(quota=self.quota, item=self.item1, event=self.event)