本文整理汇总了Python中stoqlib.domain.product.Storable.get_balance_for_branch方法的典型用法代码示例。如果您正苦于以下问题:Python Storable.get_balance_for_branch方法的具体用法?Python Storable.get_balance_for_branch怎么用?Python Storable.get_balance_for_branch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stoqlib.domain.product.Storable
的用法示例。
在下文中一共展示了Storable.get_balance_for_branch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_balance
# 需要导入模块: from stoqlib.domain.product import Storable [as 别名]
# 或者: from stoqlib.domain.product.Storable import get_balance_for_branch [as 别名]
def test_get_balance(self):
p = self.create_product()
b1 = self.create_branch()
b2 = self.create_branch()
b3 = self.create_branch()
storable = Storable(store=self.store, product=p)
self.assertEqual(storable.get_balance_for_branch(b1), 0)
self.assertEqual(storable.get_balance_for_branch(b2), 0)
self.assertEqual(storable.get_balance_for_branch(b3), 0)
self.assertEqual(storable.get_total_balance(), 0)
# Only b1 and b2 will increase stock
storable.increase_stock(5, b1, 0, None)
storable.increase_stock(10, b2, 0, None)
self.assertEqual(storable.get_balance_for_branch(b1), 5)
self.assertEqual(storable.get_balance_for_branch(b2), 10)
self.assertEqual(storable.get_balance_for_branch(b3), 0)
self.assertEqual(storable.get_total_balance(), 15)
# b1 will decrease *all* it's stock
storable.decrease_stock(5, b1, 0, None)
self.assertEqual(storable.get_balance_for_branch(b1), 0)
self.assertEqual(storable.get_balance_for_branch(b2), 10)
self.assertEqual(storable.get_balance_for_branch(b3), 0)
self.assertEqual(storable.get_total_balance(), 10)