File diff c9a62db774c5 → 8ad265a65a08
registrasion/tests/test_voucher.py
Show inline comments
...
 
@@ -116,41 +116,43 @@ class VoucherTestCases(RegistrationCartTestCase):
 
        current_cart = TestingCartController.for_user(self.USER_1)
 
        current_cart.apply_voucher(voucher.code)
 
        current_cart.apply_voucher(voucher.code)
 

	
 
        # You can apply the code twice, but it will only add to the cart once.
 
        self.assertEqual(1, current_cart.cart.vouchers.count())
 

	
 
    def test_voucher_can_only_be_applied_once_across_multiple_carts(self):
 
        voucher = self.new_voucher(limit=2)
 
        current_cart = TestingCartController.for_user(self.USER_1)
 
        current_cart.apply_voucher(voucher.code)
 

	
 
        inv = InvoiceController.for_cart(current_cart.cart)
 
        inv.pay("Hello!", inv.invoice.value)
 
        current_cart.cart.active = False
 
        current_cart.cart.save()
 

	
 
        current_cart = TestingCartController.for_user(self.USER_1)
 

	
 
        with self.assertRaises(ValidationError):
 
            current_cart.apply_voucher(voucher.code)
 

	
 
        return current_cart
 

	
 
    def test_refund_releases_used_vouchers(self):
 
        voucher = self.new_voucher(limit=2)
 
        current_cart = TestingCartController.for_user(self.USER_1)
 
        current_cart.apply_voucher(voucher.code)
 
        current_cart.add_to_cart(self.PROD_1, 1)
 

	
 
        inv = InvoiceController.for_cart(current_cart.cart)
 
        inv.pay("Hello!", inv.invoice.value)
 
        if not inv.invoice.paid:
 
            inv.pay("Hello!", inv.invoice.value)
 

	
 
        current_cart = TestingCartController.for_user(self.USER_1)
 
        with self.assertRaises(ValidationError):
 
            current_cart.apply_voucher(voucher.code)
 

	
 
        inv.refund("Hello!", inv.invoice.value)
 
        current_cart.apply_voucher(voucher.code)
 

	
 
    def test_fix_simple_errors_does_not_remove_limited_voucher(self):
 
        voucher = self.new_voucher(code="VOUCHER")
 
        current_cart = TestingCartController.for_user(self.USER_1)
 
        current_cart.apply_voucher(voucher.code)