本文整理汇总了Python中shoppingcart.models.OrderItem.purchased_items_btw_dates方法的典型用法代码示例。如果您正苦于以下问题:Python OrderItem.purchased_items_btw_dates方法的具体用法?Python OrderItem.purchased_items_btw_dates怎么用?Python OrderItem.purchased_items_btw_dates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shoppingcart.models.OrderItem
的用法示例。
在下文中一共展示了OrderItem.purchased_items_btw_dates方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_purchased_items_btw_dates
# 需要导入模块: from shoppingcart.models import OrderItem [as 别名]
# 或者: from shoppingcart.models.OrderItem import purchased_items_btw_dates [as 别名]
def test_purchased_items_btw_dates(self):
purchases = OrderItem.purchased_items_btw_dates(self.now - self.FIVE_MINS, self.now + self.FIVE_MINS)
self.assertEqual(len(purchases), 2)
self.assertIn(self.reg.orderitem_ptr, purchases)
self.assertIn(self.cert_item.orderitem_ptr, purchases)
no_purchases = OrderItem.purchased_items_btw_dates(self.now + self.FIVE_MINS,
self.now + self.FIVE_MINS + self.FIVE_MINS)
self.assertFalse(no_purchases)
示例2: test_purchased_csv
# 需要导入模块: from shoppingcart.models import OrderItem [as 别名]
# 或者: from shoppingcart.models.OrderItem import purchased_items_btw_dates [as 别名]
def test_purchased_csv(self):
"""
Tests that a generated purchase report CSV is as we expect
"""
# coerce the purchase times to self.test_time so that the test can match.
# It's pretty hard to patch datetime.datetime b/c it's a python built-in, which is immutable, so we
# make the times match this way
for item in OrderItem.purchased_items_btw_dates(self.now - self.FIVE_MINS, self.now + self.FIVE_MINS):
item.fulfilled_time = self.test_time
item.save()
# add annotation to the
csv_file = StringIO.StringIO()
OrderItem.csv_purchase_report_btw_dates(csv_file, self.now - self.FIVE_MINS, self.now + self.FIVE_MINS)
csv = csv_file.getvalue()
csv_file.close()
# Using excel mode csv, which automatically ends lines with \r\n, so need to convert to \n
self.assertEqual(csv.replace('\r\n', '\n').strip(), self.CORRECT_CSV.strip())