本文整理汇总了Python中models.Stock.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Stock.delete方法的具体用法?Python Stock.delete怎么用?Python Stock.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Stock
的用法示例。
在下文中一共展示了Stock.delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_stock_no_duplicate
# 需要导入模块: from models import Stock [as 别名]
# 或者: from models.Stock import delete [as 别名]
def test_create_stock_no_duplicate(self):
"""Makes sure stock don't have the same stock_id when creating."""
Category.create(category_id='001', description='Testing Stock')
create_stock('001', 'Testing stock', 1, '001', 9.99)
from peewee import IntegrityError
with self.assertRaises(IntegrityError):
create_stock('001', 'Testing stock', 1, '001', 9.99)
q = Stock.delete().where(Stock.stock_id == '001')
q.execute()
t = Category.delete().where(Category.category_id == '001')
t.execute()
示例2: test_create_stock
# 需要导入模块: from models import Stock [as 别名]
# 或者: from models.Stock import delete [as 别名]
def test_create_stock(self):
"""Make sure it create a stock."""
Category.create(category_id='001', description='Testing Stock')
create_stock('001', 'Testing stock', 1, '001', 9.99)
s = Stock.select().where(Stock.stock_id == '001')
t = Stock.delete().where(Stock.stock_id == '001')
t.execute()
t = Category.delete().where(Category.category_id == '001')
t.execute()
self.assertEqual(str(s), ("<class 'models.Stock'> SELECT `t1`.`id`,"
" `t1`.`stock_id`, `t1`.`description`,"
" `t1`.`quantity`, `t1`.`category_id`,"
" `t1`.`price` FROM `stock` AS t1"
" WHERE (`t1`.`stock_id` = %s) ['001']"))
示例3: test_create_incoming
# 需要导入模块: from models import Stock [as 别名]
# 或者: from models.Stock import delete [as 别名]
def test_create_incoming(self):
"""Create an incoming record."""
Category.create(category_id='001', description='Testing Stock')
create_stock('001', 'Testing stock', 1, '001', 9.99)
create_incoming_stock(stock="001", date="2015-07-22", quantity=13, price=13.99)
p = IncomingStock.select().where(IncomingStock.stock == '001')
q = IncomingStock.delete().where(IncomingStock.stock == '001')
q.execute()
s = Stock.select().where(Stock.stock_id == '001')
t = Stock.delete().where(Stock.stock_id == '001')
t.execute()
t = Category.delete().where(Category.category_id == '001')
t.execute()
self.assertEqual(str(p), ("<class 'models.IncomingStock'> SELECT `t1`.`id`, `t1`.`stock_id`, "
"`t1`.`date`, `t1`.`price`, `t1`.`cost` FROM `incomingstock` AS t1 WHERE "
"(`t1`.`stock_id` = %s) ['001']"))