本文整理汇总了Python中stoqlib.domain.views.ProductFullStockView类的典型用法代码示例。如果您正苦于以下问题:Python ProductFullStockView类的具体用法?Python ProductFullStockView怎么用?Python ProductFullStockView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ProductFullStockView类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: testPostSearchCallback
def testPostSearchCallback(self):
self.clean_domain([ProductSupplierInfo, ProductStockItem, Storable,
Product])
branch = self.create_branch()
for i in range(20):
self.create_product(branch=branch, stock=5)
for i in range(10):
self.create_product(branch=branch, stock=10)
# Get just the products we created here
sresults = self.store.find(ProductFullStockView)
postresults = ProductFullStockView.post_search_callback(sresults)
self.assertEqual(postresults[0], ('count', 'sum'))
self.assertEqual(
# Total stock = (10 * 10) + (20 * 5) = 200
self.store.execute(postresults[1]).get_one(), (30, 200))
sresults = sresults.find(ProductFullStockView.stock > 5)
postresults = ProductFullStockView.post_search_callback(sresults)
self.assertEqual(postresults[0], ('count', 'sum'))
self.assertEqual(
# Total stock = (10 * 10) = 100
self.store.execute(postresults[1]).get_one(), (10, 100))
开发者ID:marianaanselmo,项目名称:stoq,代码行数:25,代码来源:test_views.py
示例2: testPrice
def testPrice(self):
p1 = self.create_product()
results = ProductFullStockView.find_by_branch(self.store, None).find(
ProductFullStockView.product_id == p1.id)
self.failUnless(list(results))
pv = results[0]
self.assertEquals(pv.price, 10)
# Set a sale price
sellable = p1.sellable
sellable.on_sale_price = Decimal('5.55')
# And a interval that includes today
yesterday = localtoday().date() - datetime.timedelta(days=1)
tomorrow = localtoday().date() + datetime.timedelta(days=1)
sellable.on_sale_start_date = yesterday
sellable.on_sale_end_date = tomorrow
results = ProductFullStockView.find_by_branch(self.store, None).find(
ProductFullStockView.product_id == p1.id)
self.assertEquals(results[0].price, Decimal('5.55'))
# Testing with a sale price set, but in the past
date1 = localtoday().date() - datetime.timedelta(days=10)
date2 = localtoday().date() - datetime.timedelta(days=5)
sellable.on_sale_start_date = date1
sellable.on_sale_end_date = date2
results = ProductFullStockView.find_by_branch(self.store, None).find(
ProductFullStockView.product_id == p1.id)
self.assertEquals(results[0].price, 10)
开发者ID:marianaanselmo,项目名称:stoq,代码行数:31,代码来源:test_views.py
示例3: testSelectByBranch
def testSelectByBranch(self):
branch = self.create_branch()
p1 = self.create_product(branch=branch, stock=1)
results = ProductFullStockView.find_by_branch(self.store, branch)
self.failUnless(list(results))
# FIXME: Storm does not support count() with group_by
# self.assertEquals(results.count(), 1)
self.assertEquals(len(list(results)), 1)
results = ProductFullStockView.find_by_branch(self.store, branch)
results = results.find(ProductFullStockView.product_id == p1.id)
self.failUnless(list(results))
self.assertEquals(len(list(results)), 1)
开发者ID:marianaanselmo,项目名称:stoq,代码行数:14,代码来源:test_views.py
示例4: test_select_by_branch
def test_select_by_branch(self):
branch = self.create_branch()
p1 = self.create_product(branch=branch, stock=1)
results = ProductFullStockView.find_by_branch(self.store, branch)
self.failUnless(list(results))
# FIXME: Storm does not support count() with group_by
# self.assertEquals(results.count(), 1)
# The results should have 11 items. 10 for the products that already
# exists, and 1 more for the one we created
self.assertEquals(len(list(results)), 11)
results = ProductFullStockView.find_by_branch(self.store, branch)
results = results.find(ProductFullStockView.product_id == p1.id)
self.failUnless(list(results))
self.assertEquals(len(list(results)), 1)
开发者ID:dionimf,项目名称:stoq,代码行数:16,代码来源:test_views.py
示例5: test_stock_cost
def test_stock_cost(self):
branch = self.create_branch()
p1 = self.create_product(branch=branch, stock=1)
p2 = self.create_product()
results = ProductFullStockView.find_by_branch(self.store, None).find(ProductFullStockView.product_id == p1.id)
self.failUnless(list(results))
pv = results[0]
self.assertEquals(pv.stock_cost, 10)
branch = get_current_branch(self.store)
results = ProductFullStockView.find_by_branch(self.store, None).find(ProductFullStockView.product_id == p2.id)
self.failUnless(list(results))
pv = results[0]
self.assertEquals(pv.stock_cost, 0)
开发者ID:rg3915,项目名称:stoq,代码行数:16,代码来源:test_views.py
示例6: test_unit_description
def test_unit_description(self):
p1 = self.create_product()
p1.sellable.unit = self.create_sellable_unit()
p1.sellable.unit.description = u"kg"
p2 = self.create_product()
results = ProductFullStockView.find_by_branch(self.store, None)
results = results.find(ProductFullStockView.product_id == p1.id)
self.failUnless(list(results))
product_view = results[0]
self.assertEquals(product_view.get_unit_description(), u"kg")
results = ProductFullStockView.find_by_branch(self.store, None).find(ProductFullStockView.product_id == p2.id)
self.failUnless(list(results))
product_view = results[0]
self.assertEquals(product_view.get_unit_description(), u"un")
开发者ID:rg3915,项目名称:stoq,代码行数:17,代码来源:test_views.py
示例7: test_get_product_and_category_description
def test_get_product_and_category_description(self):
p1 = self.create_product()
p1.sellable.category = self.create_sellable_category()
p1.sellable.category.description = u"category"
p2 = self.create_product()
results = ProductFullStockView.find_by_branch(self.store, None).find(ProductFullStockView.product_id == p1.id)
self.failUnless(list(results))
pv = results[0]
desc = pv.get_product_and_category_description()
self.assertEquals(desc, u"[category] Description")
results = ProductFullStockView.find_by_branch(self.store, None).find(ProductFullStockView.product_id == p2.id)
self.failUnless(list(results))
pv = results[0]
desc = pv.get_product_and_category_description()
self.assertEquals(desc, u"Description")
开发者ID:rg3915,项目名称:stoq,代码行数:18,代码来源:test_views.py
示例8: test_highjacked_equality
def test_highjacked_equality(self):
self.clean_domain([StockTransactionHistory, ProductStockItem, Storable, ProductSupplierInfo, Product])
branch = self.create_branch()
self.create_product(branch=branch, stock=1)
res = self.store.find(ProductFullStockView)
res_by_branch = ProductFullStockView.find_by_branch(self.store, branch)
self.assertEqual(res[0], res_by_branch[0])
self.assertEqual(res_by_branch[0], res[0])
product = self.create_product()
other_viewable = self.store.find(ProductFullStockView, Sellable.id == product.sellable.id).one()
self.assertNotEqual(res[0], other_viewable)
self.assertNotEqual(res[0], object())
开发者ID:amaurihamasu,项目名称:stoq,代码行数:16,代码来源:test_views.py
注:本文中的stoqlib.domain.views.ProductFullStockView类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论