当前位置: 首页>>代码示例>>Python>>正文


Python OrderItem.purchased_items_btw_dates方法代码示例

本文整理汇总了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)
开发者ID:DavidGrahamFL,项目名称:edx-platform,代码行数:10,代码来源:test_models.py

示例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())
开发者ID:DavidGrahamFL,项目名称:edx-platform,代码行数:20,代码来源:test_models.py


注:本文中的shoppingcart.models.OrderItem.purchased_items_btw_dates方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。