Changeset - 2f77f5bb23ee
[Not reviewed]
0 6 0
Christopher Neugebauer - 8 years ago 2016-04-06 07:24:25
chrisjrn@gmail.com
Replaces .active = False; .save() pattern in tests with a test controller method
6 files changed with 55 insertions and 51 deletions:
0 comments (0 inline, 0 general)
registrasion/tests/cart_controller_helper.py
Show inline comments
...
 
@@ -25,2 +25,6 @@ class TestingCartController(CartController):
 
            old_quantity = 0
 
        self.set_quantity(product, old_quantity + quantity)
 

	
 
    def next_cart(self):
 
        self.cart.active = False
 
        self.cart.save()
registrasion/tests/test_cart.py
Show inline comments
...
 
@@ -75,10 +75,10 @@ class RegistrationCartTestCase(SetTimeMixin, TestCase):
 
        # Burn through some carts -- this made some past EC tests fail
 
        current_cart = TestingCartController.for_user(cls.USER_1)
 
        current_cart.cart.active = False
 
        current_cart.cart.save()
 

	
 
        current_cart.next_cart()
 

	
 
        current_cart = TestingCartController.for_user(cls.USER_2)
 
        current_cart.cart.active = False
 
        current_cart.cart.save()
 

	
 
        current_cart.next_cart()
 

	
 
    @classmethod
...
 
@@ -143,6 +143,6 @@ class BasicCartTests(RegistrationCartTestCase):
 
        current_cart = TestingCartController.for_user(self.USER_1)
 

	
 
        current_cart.cart.active = False
 
        current_cart.cart.save()
 

	
 
        current_cart.next_cart()
 

	
 
        old_cart = current_cart
...
 
@@ -215,6 +215,6 @@ class BasicCartTests(RegistrationCartTestCase):
 
            current_cart.add_to_cart(self.PROD_1, 10)
 

	
 
        current_cart.cart.active = False
 
        current_cart.cart.save()
 

	
 
        current_cart.next_cart()
 

	
 
        current_cart = TestingCartController.for_user(self.USER_1)
...
 
@@ -273,6 +273,6 @@ class BasicCartTests(RegistrationCartTestCase):
 
            current_cart.add_to_cart(self.PROD_3, 1)
 

	
 
        current_cart.cart.active = False
 
        current_cart.cart.save()
 

	
 
        current_cart.next_cart()
 

	
 
        current_cart = TestingCartController.for_user(self.USER_1)
...
 
@@ -299,6 +299,6 @@ class BasicCartTests(RegistrationCartTestCase):
 

	
 
        # The limits should extend across carts...
 
        current_cart.cart.active = False
 
        current_cart.cart.save()
 

	
 
        current_cart.next_cart()
 

	
 
        current_cart = TestingCartController.for_user(self.USER_1)
...
 
@@ -326,6 +326,6 @@ class BasicCartTests(RegistrationCartTestCase):
 
        self.assertTrue(item in prods)
 

	
 
        current_cart.cart.active = False
 
        current_cart.cart.save()
 

	
 
        current_cart.next_cart()
 

	
 
        current_cart = TestingCartController.for_user(self.USER_1)
registrasion/tests/test_ceilings.py
Show inline comments
...
 
@@ -92,6 +92,6 @@ class CeilingsTestCases(RegistrationCartTestCase):
 

	
 
        # User 2 pays for their cart
 
        second_cart.cart.active = False
 
        second_cart.cart.save()
 

	
 
        second_cart.next_cart()
 

	
 
        # User 1 should not be able to add item to their cart
...
 
@@ -129,6 +129,6 @@ class CeilingsTestCases(RegistrationCartTestCase):
 

	
 
        # Paid cart outside the reservation window
 
        second_cart.cart.active = False
 
        second_cart.cart.save()
 

	
 
        second_cart.next_cart()
 
        self.add_timedelta(self.RESERVATION + datetime.timedelta(seconds=1))
 
        with self.assertRaises(ValidationError):
...
 
@@ -141,6 +141,6 @@ class CeilingsTestCases(RegistrationCartTestCase):
 
        first_cart.add_to_cart(self.PROD_1, 1)
 

	
 
        first_cart.cart.active = False
 
        first_cart.cart.save()
 

	
 
        first_cart.next_cart()
 

	
 
        second_cart = TestingCartController.for_user(self.USER_2)
...
 
@@ -149,5 +149,5 @@ class CeilingsTestCases(RegistrationCartTestCase):
 

	
 
        first_cart.cart.released = True
 
        first_cart.cart.save()
 
        first_cart.next_cart()
 

	
 
        second_cart.add_to_cart(self.PROD_1, 1)
...
 
@@ -177,6 +177,6 @@ class CeilingsTestCases(RegistrationCartTestCase):
 
        self.assertEqual(1, len(cart.cart.discountitem_set.all()))
 

	
 
        cart.cart.active = False
 
        cart.cart.save()
 

	
 
        cart.next_cart()
 

	
 
        # The second cart has no voucher attached, so should apply the
registrasion/tests/test_discount.py
Show inline comments
...
 
@@ -169,6 +169,6 @@ class DiscountTestCase(RegistrationCartTestCase):
 
        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
...
 
@@ -178,6 +178,6 @@ class DiscountTestCase(RegistrationCartTestCase):
 
        # The discount should be applied.
 
        self.assertEqual(1, len(cart.cart.discountitem_set.all()))
 
        cart.cart.active = False
 
        cart.cart.save()
 

	
 
        cart.next_cart()
 

	
 
        # The discount should respect the total quantity across all
...
 
@@ -198,6 +198,6 @@ class DiscountTestCase(RegistrationCartTestCase):
 
        # This would exhaust discount if present
 
        cart.add_to_cart(self.PROD_2, 2)
 
        cart.cart.active = False
 
        cart.cart.save()
 

	
 
        cart.next_cart()
 

	
 
        self.add_discount_prod_1_includes_prod_2()
...
 
@@ -347,6 +347,6 @@ class DiscountTestCase(RegistrationCartTestCase):
 
        discounts = discount.available_discounts(self.USER_1, [self.CAT_2], [])
 
        self.assertEqual(2, discounts[0].quantity)
 
        cart.cart.active = False
 
        cart.cart.save()
 

	
 
        cart.next_cart()
 

	
 
    def test_discount_quantity_is_correct_after_first_purchase(self):
...
 
@@ -358,6 +358,6 @@ class DiscountTestCase(RegistrationCartTestCase):
 
        discounts = discount.available_discounts(self.USER_1, [self.CAT_2], [])
 
        self.assertEqual(1, discounts[0].quantity)
 
        cart.cart.active = False
 
        cart.cart.save()
 

	
 
        cart.next_cart()
 

	
 
    def test_discount_is_gone_after_quantity_exhausted(self):
...
 
@@ -389,10 +389,10 @@ class DiscountTestCase(RegistrationCartTestCase):
 

	
 
        cart.cart.active = False  # Keep discount enabled
 
        cart.cart.save()
 
        cart.next_cart()
 

	
 
        cart = TestingCartController.for_user(self.USER_1)
 
        cart.add_to_cart(self.PROD_2, 2)  # The discount will be exhausted
 
        cart.cart.active = False
 
        cart.cart.save()
 

	
 
        cart.next_cart()
 

	
 
        discounts = discount.available_discounts(
...
 
@@ -404,5 +404,5 @@ class DiscountTestCase(RegistrationCartTestCase):
 

	
 
        cart.cart.released = True
 
        cart.cart.save()
 
        cart.next_cart()
 

	
 
        discounts = discount.available_discounts(
registrasion/tests/test_enabling_condition.py
Show inline comments
...
 
@@ -69,6 +69,6 @@ class EnablingConditionTestCases(RegistrationCartTestCase):
 
        current_cart = TestingCartController.for_user(self.USER_1)
 
        current_cart.add_to_cart(self.PROD_2, 1)
 
        current_cart.cart.active = False
 
        current_cart.cart.save()
 

	
 
        current_cart.next_cart()
 

	
 
        # Create new cart and try to add PROD_1
...
 
@@ -104,6 +104,6 @@ class EnablingConditionTestCases(RegistrationCartTestCase):
 
        current_cart = TestingCartController.for_user(self.USER_1)
 
        current_cart.add_to_cart(self.PROD_3, 1)
 
        current_cart.cart.active = False
 
        current_cart.cart.save()
 

	
 
        current_cart.next_cart()
 

	
 
        # Create new cart and try to add PROD_1
...
 
@@ -242,6 +242,6 @@ class EnablingConditionTestCases(RegistrationCartTestCase):
 
        cart.add_to_cart(self.PROD_3, 1)
 

	
 
        cart.cart.active = False
 
        cart.cart.save()
 

	
 
        cart.next_cart()
 

	
 
        cart_2 = TestingCartController.for_user(self.USER_1)
...
 
@@ -250,5 +250,5 @@ class EnablingConditionTestCases(RegistrationCartTestCase):
 

	
 
        cart.cart.released = True
 
        cart.cart.save()
 
        cart.next_cart()
 

	
 
        with self.assertRaises(ValidationError):
...
 
@@ -261,6 +261,6 @@ class EnablingConditionTestCases(RegistrationCartTestCase):
 
        cart.add_to_cart(self.PROD_2, 1)
 

	
 
        cart.cart.active = False
 
        cart.cart.save()
 

	
 
        cart.next_cart()
 

	
 
        cart_2 = TestingCartController.for_user(self.USER_1)
...
 
@@ -269,5 +269,5 @@ class EnablingConditionTestCases(RegistrationCartTestCase):
 

	
 
        cart.cart.released = True
 
        cart.cart.save()
 
        cart.next_cart()
 

	
 
        with self.assertRaises(ValidationError):
registrasion/tests/test_voucher.py
Show inline comments
...
 
@@ -35,6 +35,6 @@ class VoucherTestCases(RegistrationCartTestCase):
 
        self.add_timedelta(rego.Voucher.RESERVATION_DURATION * 2)
 
        cart_2.apply_voucher(voucher.code)
 
        cart_2.cart.active = False
 
        cart_2.cart.save()
 

	
 
        cart_2.next_cart()
 

	
 
        # After the reservation duration, even though the voucher has applied,
...
 
@@ -126,6 +126,6 @@ class VoucherTestCases(RegistrationCartTestCase):
 
        current_cart.apply_voucher(voucher.code)
 

	
 
        current_cart.cart.active = False
 
        current_cart.cart.save()
 

	
 
        current_cart.next_cart()
 

	
 
        current_cart = TestingCartController.for_user(self.USER_1)
0 comments (0 inline, 0 general)