本文整理汇总了Python中stoqlib.domain.production.ProductionProducedItem类的典型用法代码示例。如果您正苦于以下问题:Python ProductionProducedItem类的具体用法?Python ProductionProducedItem怎么用?Python ProductionProducedItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ProductionProducedItem类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_is_valid_serial_range
def test_is_valid_serial_range(self):
pitem = ProductionProducedItem(store=self.store)
pitem.product = self.create_product()
self.assertTrue(ProductionProducedItem.is_valid_serial_range(
pitem.product, 1, 2, self.store))
pitem.serial_number = 1
self.assertFalse(ProductionProducedItem.is_valid_serial_range(
pitem.product, 1, 2, self.store))
示例2: test_get_last_serial_number
def test_get_last_serial_number(self):
pitem = ProductionProducedItem(store=self.store)
pitem.product = self.create_product()
last = ProductionProducedItem.get_last_serial_number(pitem.product, self.store)
self.assertEquals(last, 0)
pitem.serial_number = 10
last = ProductionProducedItem.get_last_serial_number(pitem.product, self.store)
self.assertEquals(last, 10)
示例3: test_get_or_create_multiple_with_null
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)
示例4: on_serial_number__validate
def on_serial_number__validate(self, widget, value):
qty = self._parent.quantity.read()
if qty is ValueUnset:
qty = 0
first = value
last = value + qty - 1
if not ProductionProducedItem.is_valid_serial_range(self._product,
first, last, self.store):
return ValidationError(_('There already is a serial number in '
'the range %d - %d') % (first, last))
示例5: test_get_or_create_multiple
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)
示例6: test_send_to_stock
def test_send_to_stock(self):
pitem = ProductionProducedItem(store=self.store)
pitem.order = self.create_production_order()
pitem.product = self.create_storable().product
pitem.send_to_stock()
self.assertTrue(
self.store.find(StockTransactionHistory,
object_id=pitem.id,
type=StockTransactionHistory.TYPE_PRODUCTION_SENT).one())
pitem.send_to_stock()
self.assertTrue(
self.store.find(StockTransactionHistory,
object_id=pitem.id,
type=StockTransactionHistory.TYPE_PRODUCTION_SENT).one())
示例7: create_model
def create_model(self, store):
serial = ProductionProducedItem.get_last_serial_number(
self._product, store)
return Settable(serial_number=serial + 1)
示例8: test_get_pending_tests
def test_get_pending_tests(self):
pitem = ProductionProducedItem(store=self.store)
pitem.product = self.create_product()
self.assertEqual(pitem.get_pending_tests(), [])