def getStockInformation(self): """ """ shop = self._getShop() sm = IStockManagement(shop) pvm = IProductVariantsManagement(self.context) if pvm.hasVariants() == False: stock_information = sm.getStockInformationFor(self.context) else: product_variant = pvm.getSelectedVariant() # First, we try to get information for the selected product variant stock_information = sm.getStockInformationFor(product_variant) # If nothing is found, we try to get information for parent product # variants object. if stock_information is None: stock_information = sm.getStockInformationFor(self.context) if stock_information is None: return None return IData(stock_information).asDict()
def afterSetUp(self): """ """ super(TestStockInformationData, self).afterSetUp() container = self.shop["stock-information"] container.invokeFactory("StockInformation", id="s1") sm = IStockManagement(self.shop) self.si = sm.getStockInformationFor(self.shop.products.product_1)
def testgetStockInformationFor_1(self): """ """ container = self.shop["stock-information"] container.invokeFactory("StockInformation", id="s1") sm = IStockManagement(self.shop) valid_stock_information = sm.getStockInformationFor(self.shop.products.product_1) self.assertEqual(valid_stock_information.getId(), "s1")
def testgetStockInformationFor_1(self): """ """ container = self.shop["stock-information"] container.invokeFactory("StockInformation", id="s1") sm = IStockManagement(self.shop) valid_stock_information = sm.getStockInformationFor( self.shop.products.product_1) self.assertEqual(valid_stock_information.getId(), "s1")