Пример #1
0
 def test_create_new_modifies_product_quantity(self):
     prod = Product.objects.create(name="Milk", quantity=10, price=1)
     ordered_quantity = 3
     Cart.create_new(key='1', quantity=ordered_quantity, prod_id=prod.id) 
     cart = Cart.objects.first()
     self.assertEqual(cart.products.first().quantity, prod.quantity-ordered_quantity)     
Пример #2
0
 def save(self, key):
     return Cart.create_new(key=key, quantity=int(self.data['quantity']), prod_id=int(self.data['prod_id'])) 
Пример #3
0
 def test_create_new(self):
     prod = Product.objects.create(name="Milk", quantity=10, price=1)
     Cart.create_new(key='1', quantity=2, prod_id=prod.id) 
     cart = Cart.objects.first()
     self.assertEqual(cart.products.first(), prod)