Changeset - 8e1f79951315
[Not reviewed]
0 1 0
Christopher Neugebauer - 8 years ago 2016-09-03 06:11:28
chrisjrn@gmail.com
Test case for issue #68
1 file changed with 27 insertions and 0 deletions:
0 comments (0 inline, 0 general)
registrasion/tests/test_flag.py
Show inline comments
...
 
@@ -6,6 +6,7 @@ from registrasion.models import commerce
 
from registrasion.models import conditions
 
from registrasion.controllers.category import CategoryController
 
from controller_helpers import TestingCartController
 
from controller_helpers import TestingInvoiceController
 
from registrasion.controllers.product import ProductController
 

	
 
from test_cart import RegistrationCartTestCase
...
 
@@ -350,3 +351,29 @@ class FlagTestCases(RegistrationCartTestCase):
 
        # and also PROD_1, which is now exhausted for user.
 
        items = commerce.ProductItem.objects.filter(cart=cart.cart)
 
        self.assertTrue([i for i in items if i.product == self.PROD_1])
 

	
 
    def test_oops(self):
 
        ''' Flags should be enabled, even if *some* enabling products are cnx.
 
        Tests issue #68.
 
        '''
 

	
 
        self.add_product_flag()
 
        cart1 = TestingCartController.for_user(self.USER_1)
 

	
 
        with self.assertRaises(ValidationError):
 
            # Can't do this without PROD_2
 
            cart1.add_to_cart(self.PROD_1, 1)
 

	
 
        cart1.add_to_cart(self.PROD_2, 1)
 

	
 
        inv = TestingInvoiceController.for_cart(cart1.cart)
 
        inv.pay("Lol", inv.invoice.value)
 

	
 
        cart2 = TestingCartController.for_user(self.USER_1)
 
        cart2.add_to_cart(self.PROD_2, 1)
 

	
 
        inv.refund()
 

	
 
        # Even though cart1 has been cancelled, we have the item in cart2.
 
        # So we should be able to add PROD_1, which depends on PROD_2
 
        cart2.add_to_cart(self.PROD_1, 1)
0 comments (0 inline, 0 general)