def testDeleteItem(self): """ """ self.logout() cm = ICartManagement(self.shop) cart = cm.createCart() im = IItemManagement(cart) im.addItem(self.product_1, properties=()) self.assertEqual(len(im.getItems()), 1) im.addItem(self.product_2, properties=(), quantity=3) self.assertEqual(len(im.getItems()), 2) # Try to delete non existing id result = im.deleteItem("3") self.assertEqual(result, False) # Still 2 items in there self.assertEqual(len(im.getItems()), 2) # delete first item result = im.deleteItem("0") self.assertEqual(result, True) self.assertEqual(len(im.getItems()), 1) # delete second item result = im.deleteItem("1") self.assertEqual(result, True) self.assertEqual(len(im.getItems()), 0)
def testDeleteItem(self): """ """ self.login("newmember") view = getMultiAdapter((self.shop.products.product_1, self.shop.products.product_1.REQUEST), name="addToCart") view.addToCart() cart = ICartManagement(self.shop).getCart() im = IItemManagement(cart) im.deleteItem("0") self.failIf(hasattr(cart, "0")) self.assertEqual(im.deleteItem("0"), False)