@@ -165,23 +165,23 @@ class DiscountTestCase(RegistrationCartTestCase):
def test_discount_applies_across_carts(self):
self.add_discount_prod_1_includes_prod_2()
# Enable the discount during the first cart.
cart = TestingCartController.for_user(self.USER_1)
cart.add_to_cart(self.PROD_1, 1)
cart.cart.active = False
cart.cart.save()
cart.next_cart()
# Use the discount in the second cart
cart.add_to_cart(self.PROD_2, 1)
# The discount should be applied.
self.assertEqual(1, len(cart.cart.discountitem_set.all()))
# The discount should respect the total quantity across all
# of the user's carts.
cart.add_to_cart(self.PROD_2, 2)
@@ -194,14 +194,14 @@ class DiscountTestCase(RegistrationCartTestCase):
def test_discount_applies_only_once_enabled(self):
# This would exhaust discount if present
discount_items = list(cart.cart.discountitem_set.all())
@@ -343,27 +343,25 @@ class DiscountTestCase(RegistrationCartTestCase):
cart.add_to_cart(self.PROD_1, 1) # Enable the discount
cart.add_to_cart(self.PROD_3, 1) # Exhaust the quantity
discounts = discount.available_discounts(self.USER_1, [self.CAT_2], [])
self.assertEqual(2, discounts[0].quantity)
inv = InvoiceController.for_cart(cart.cart)
inv.pay("Dummy reference", inv.invoice.value)
self.assertTrue(inv.invoice.paid)
def test_discount_quantity_is_correct_after_first_purchase(self):
self.test_discount_quantity_is_correct_before_first_purchase()
self.assertEqual(1, discounts[0].quantity)
def test_discount_is_gone_after_quantity_exhausted(self):
self.test_discount_quantity_is_correct_after_first_purchase()
self.assertEqual(0, len(discounts))
@@ -387,28 +385,28 @@ class DiscountTestCase(RegistrationCartTestCase):
[],
[self.PROD_2],
)
self.assertEqual(1, len(discounts))
cart.cart.active = False # Keep discount enabled
cart.add_to_cart(self.PROD_2, 2) # The discount will be exhausted
discounts = discount.available_discounts(
self.USER_1,
cart.cart.released = True