def testGetAmountOfProducts_1(self): """As manager """ pm = IProductManagement(self.shop.groups.group_1) self.assertEqual(len(pm.getProducts()), 2) pm = IProductManagement(self.shop.groups.group_2) self.assertEqual(len(pm.getProducts()), 1)
def testGetAllProducts(self): """ """ pm = IProductManagement(self.portal.myshop.categories.category_1) product_ids = [p.getId() for p in pm.getAllProducts()] self.assertEqual(product_ids, ["product_1", "product_2"]) pm = IProductManagement(self.portal.myshop.categories.category_1.category_11) product_ids = [p.getId() for p in pm.getAllProducts()] self.assertEqual(product_ids, ["product_1", "product_2"])
def testGetAmountOfProducts_2(self): """As anonymous. Note that only products are counted for which the user has the View permission. """ self.logout() pm = IProductManagement(self.shop.groups.group_1) self.assertEqual(len(pm.getProducts()), 0) pm = IProductManagement(self.shop.groups.group_2) self.assertEqual(len(pm.getProducts()), 0)
def testGetProducts_1(self): """As manager """ pm = IProductManagement(self.shop.groups.group_1) product_ids = [p.getId() for p in pm.getProducts()] self.assertEqual(product_ids, ["product_1", "product_2"]) pm = IProductManagement(self.shop.groups.group_2) product_ids = [p.getId() for p in pm.getProducts()] self.assertEqual(product_ids, ["product_1"])
def testGetAmountOfProducts_3(self): """As anonymous, with product_2 published. """ wftool = getToolByName(self.shop, "portal_workflow") wftool.doActionFor(self.product_2, "publish") self.logout() pm = IProductManagement(self.shop.groups.group_1) self.assertEqual(len(pm.getProducts()), 1) pm = IProductManagement(self.shop.groups.group_2) self.assertEqual(len(pm.getProducts()), 0)
def testGetProducts_2(self): """As anonymous. Note hat only products return for which the user has the View permission. """ self.logout() pm = IProductManagement(self.shop.groups.group_1) product_ids = [p.getId() for p in pm.getProducts()] self.assertEqual(product_ids, []) pm = IProductManagement(self.shop.groups.group_2) product_ids = [p.getId() for p in pm.getProducts()] self.assertEqual(product_ids, [])
def testGetTotalAmountOfProducts(self): """ """ pm = IProductManagement(self.portal.myshop.categories.category_1) self.assertEqual(pm.getTotalAmountOfProducts(), 2) pm = IProductManagement(self.portal.myshop.categories.category_2) self.assertEqual(pm.getTotalAmountOfProducts(), 0) pm = IProductManagement(self.portal.myshop.categories.category_1.category_11) self.assertEqual(pm.getTotalAmountOfProducts(), 2)
def testGetProducts(self): """ """ pm = IProductManagement(self.portal.myshop.categories.category_1) self.assertEqual(pm.getProducts(), []) pm = IProductManagement(self.portal.myshop.categories.category_2) self.assertEqual(pm.getProducts(), []) pm = IProductManagement(self.portal.myshop.categories.category_1.category_11) product_ids = [p.getId() for p in pm.getProducts()] self.assertEqual(product_ids, ["product_1", "product_2"])
def testGetProducts_3(self): """As anonymous, with product_2 published. """ wftool = getToolByName(self.shop, "portal_workflow") wftool.doActionFor(self.product_2, "publish") self.logout() pm = IProductManagement(self.shop.groups.group_1) product_ids = [p.getId() for p in pm.getProducts()] for id in ["product_1", "product_2"]: self.failUnless(id not in product_ids) pm = IProductManagement(self.shop.groups.group_2) product_ids = [p.getId() for p in pm.getProducts()] self.assertEqual(product_ids, [])
def testGetProducts(self): """ """ pm = IProductManagement(self.shop) self.failIf(pm.getProducts() == 0)
def testGetTotalAmountOfProducts(self): """ """ pm = IProductManagement(self.shop) self.assertRaises(Exception, pm.getTotalAmountOfProducts)