本文整理匯總了Python中stoqlib.domain.production.ProductionProducedItem.get_or_create方法的典型用法代碼示例。如果您正苦於以下問題:Python ProductionProducedItem.get_or_create方法的具體用法?Python ProductionProducedItem.get_or_create怎麽用?Python ProductionProducedItem.get_or_create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類stoqlib.domain.production.ProductionProducedItem
的用法示例。
在下文中一共展示了ProductionProducedItem.get_or_create方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_get_or_create_multiple_with_null
# 需要導入模塊: from stoqlib.domain.production import ProductionProducedItem [as 別名]
# 或者: from stoqlib.domain.production.ProductionProducedItem import get_or_create [as 別名]
def test_get_or_create_multiple_with_null(self):
# Check if get_or_creating is working properly when using references
# with null values.
item_a = ProductionProducedItem.get_or_create(
self.store, serial_number=456, product=None)
self.assertEquals(item_a.serial_number, 456)
self.assertEquals(item_a.product, None)
item_b = ProductionProducedItem.get_or_create(
self.store, serial_number=456, product=None)
self.assertEquals(item_a, item_b)
示例2: test_get_or_create_multiple
# 需要導入模塊: from stoqlib.domain.production import ProductionProducedItem [as 別名]
# 或者: from stoqlib.domain.production.ProductionProducedItem import get_or_create [as 別名]
def test_get_or_create_multiple(self):
# This test is for get_or_create call with more than one property
product = self.create_product()
# Make sure there is no item yet.
item = self.store.find(ProductionProducedItem, serial_number=123,
product=product).one()
self.assertEquals(item, None)
# First call to get_or_create should create the object.
item_a = ProductionProducedItem.get_or_create(
self.store, serial_number=123, product=product)
# And set the properties given
self.assertEquals(item_a.serial_number, 123)
self.assertEquals(item_a.product, product)
# The second call to get_or_create should return the same object
item_b = ProductionProducedItem.get_or_create(
self.store, serial_number=123, product=product)
self.assertEquals(item_a, item_b)