本文整理汇总了Python中stoqlib.domain.sellable.Sellable.remove方法的典型用法代码示例。如果您正苦于以下问题:Python Sellable.remove方法的具体用法?Python Sellable.remove怎么用?Python Sellable.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stoqlib.domain.sellable.Sellable
的用法示例。
在下文中一共展示了Sellable.remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testCreateEvent
# 需要导入模块: from stoqlib.domain.sellable import Sellable [as 别名]
# 或者: from stoqlib.domain.sellable.Sellable import remove [as 别名]
def testCreateEvent(self):
store_list = []
p_data = _ProductEventData()
ProductCreateEvent.connect(p_data.on_create)
ProductEditEvent.connect(p_data.on_edit)
ProductRemoveEvent.connect(p_data.on_delete)
try:
# Test product being created
store = new_store()
store_list.append(store)
sellable = Sellable(
store=store,
description=u'Test 1234',
price=Decimal(2),
)
product = Product(
store=store,
sellable=sellable,
)
store.commit()
self.assertTrue(p_data.was_created)
self.assertFalse(p_data.was_edited)
self.assertFalse(p_data.was_deleted)
self.assertEqual(p_data.product, product)
p_data.reset()
# Test product being edited and emmiting the event just once
store = new_store()
store_list.append(store)
sellable = store.fetch(sellable)
product = store.fetch(product)
sellable.notes = u'Notes'
sellable.description = u'Test 666'
product.weight = Decimal(10)
store.commit()
self.assertTrue(p_data.was_edited)
self.assertFalse(p_data.was_created)
self.assertFalse(p_data.was_deleted)
self.assertEqual(p_data.product, product)
self.assertEqual(p_data.emmit_count, 1)
p_data.reset()
# Test product being edited, editing Sellable
store = new_store()
store_list.append(store)
sellable = store.fetch(sellable)
product = store.fetch(product)
sellable.notes = u'Notes for test'
store.commit()
self.assertTrue(p_data.was_edited)
self.assertFalse(p_data.was_created)
self.assertFalse(p_data.was_deleted)
self.assertEqual(p_data.product, product)
self.assertEqual(p_data.emmit_count, 1)
p_data.reset()
# Test product being edited, editing Product itself
store = new_store()
store_list.append(store)
sellable = store.fetch(sellable)
product = store.fetch(product)
product.weight = Decimal(1)
store.commit()
self.assertTrue(p_data.was_edited)
self.assertFalse(p_data.was_created)
self.assertFalse(p_data.was_deleted)
self.assertEqual(p_data.product, product)
self.assertEqual(p_data.emmit_count, 1)
p_data.reset()
# Test product being edited, editing Product itself
store = new_store()
store_list.append(store)
sellable = store.fetch(sellable)
product = store.fetch(product)
product.weight = Decimal(1)
store.commit()
#self.assertTrue(p_data.was_edited)
self.assertFalse(p_data.was_created)
self.assertFalse(p_data.was_deleted)
#self.assertEqual(p_data.product, product)
#self.assertEqual(p_data.emmit_count, 1)
p_data.reset()
finally:
# Test product being removed
store = new_store()
store_list.append(store)
sellable = store.fetch(sellable)
product = store.fetch(product)
sellable.remove()
store.commit()
self.assertTrue(p_data.was_deleted)
self.assertFalse(p_data.was_created)
self.assertFalse(p_data.was_edited)
self.assertEqual(p_data.product, product)
self.assertEqual(p_data.emmit_count, 1)
p_data.reset()
#.........这里部分代码省略.........
示例2: test_events
# 需要导入模块: from stoqlib.domain.sellable import Sellable [as 别名]
# 或者: from stoqlib.domain.sellable.Sellable import remove [as 别名]
def test_events(self):
store_list = []
p_data = _ServiceEventData()
ServiceCreateEvent.connect(p_data.on_create)
ServiceEditEvent.connect(p_data.on_edit)
ServiceRemoveEvent.connect(p_data.on_delete)
try:
# Test service being created
store = new_store()
store_list.append(store)
sellable = Sellable(
store=store,
description=u'Test 1234',
price=decimal.Decimal(2),
)
service = Service(
store=store,
sellable=sellable,
)
store.commit()
self.assertTrue(p_data.was_created)
self.assertFalse(p_data.was_edited)
self.assertFalse(p_data.was_deleted)
self.assertEqual(p_data.service, service)
p_data.reset()
# Test service being edited and emmiting the event just once
store = new_store()
store_list.append(store)
sellable = store.fetch(sellable)
service = store.fetch(service)
sellable.notes = u'Notes'
sellable.description = u'Test 666'
service.weight = decimal.Decimal(10)
store.commit()
self.assertTrue(p_data.was_edited)
self.assertFalse(p_data.was_created)
self.assertFalse(p_data.was_deleted)
self.assertEqual(p_data.service, service)
self.assertEqual(p_data.emit_count, 1)
p_data.reset()
# Test service being edited, editing Sellable
store = new_store()
store_list.append(store)
sellable = store.fetch(sellable)
service = store.fetch(service)
sellable.notes = u'Notes for test'
store.commit()
self.assertTrue(p_data.was_edited)
self.assertFalse(p_data.was_created)
self.assertFalse(p_data.was_deleted)
self.assertEqual(p_data.service, service)
self.assertEqual(p_data.emit_count, 1)
p_data.reset()
finally:
# Test service being removed
store = new_store()
store_list.append(store)
sellable = store.fetch(sellable)
service = store.fetch(service)
sellable.remove()
store.commit()
self.assertTrue(p_data.was_deleted)
self.assertFalse(p_data.was_created)
self.assertFalse(p_data.was_edited)
self.assertEqual(p_data.service, service)
self.assertEqual(p_data.emit_count, 1)
p_data.reset()
for store in store_list:
store.close()