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


Python Service.history方法代码示例

本文整理汇总了Python中models.Service.history方法的典型用法代码示例。如果您正苦于以下问题:Python Service.history方法的具体用法?Python Service.history怎么用?Python Service.history使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Service的用法示例。


在下文中一共展示了Service.history方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: HistoryTest

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import history [as 别名]
class HistoryTest(TestbedTest):

    def setUp(self):
        super(HistoryTest, self).setUp()
        Status.load_defaults()
        self.service = Service(slug="account", name="Account",
                               description="The BEST SERVICE")
        self.service.put()

    def test_history_order(self):
        start = date(2011, 4, 13)
        up = Status.get_by_slug("up")
        history = self.service.history(5, up, start=start)
        self.assertEquals(len(history), 5)

        history_days = [ h["day"] for h in history ]
        expected = [
            date(2011, 4, 12),
            date(2011, 4, 11),
            date(2011, 4, 10),
            date(2011, 4, 9),
            date(2011, 4, 8),
            ]

        self.assertEquals(history_days, expected)

    def test_history_order_early_month(self):
        start = date(2011, 4, 2)
        up = Status.get_by_slug("up")
        history = self.service.history(5, up, start=start)

        history_days = [ h["day"] for h in history ]
        expected = [
            date(2011, 4, 1),
            date(2011, 3, 31),
            date(2011, 3, 30),
            date(2011, 3, 29),
            date(2011, 3, 28),
            ]

        self.assertEquals(history_days, expected)

        for h in history:
            self.assertFalse(h["information"])


    def test_history_order_late_month(self):
        start = date(2011, 4, 5)
        up = Status.get_by_slug("up")
        history = self.service.history(5, up, start=start)

        history_days = [ h["day"] for h in history ]
        expected = [
            date(2011, 4, 4),
            date(2011, 4, 3),
            date(2011, 4, 2),
            date(2011, 4, 1),
            date(2011, 3, 31),
            ]

        self.assertEquals(history_days, expected)

    def test_history_no_errors_boundary(self):
        down = Status.get_by_slug("down")
        up = Status.get_by_slug("up")

        now = datetime(2011, 4, 5)
        event = Event(status=down, service=self.service, start=now, message="HEY")
        event.put()

        history = self.service.history(5, up, start=date(2011, 4, 5))
        self.assertEquals(history[0]["information"], False)

    def test_history_one_error(self):
        down = Status.get_by_slug("down")
        up = Status.get_by_slug("up")

        now = datetime(2011, 4, 4, 12)
        event = Event(status=down, service=self.service, start=now, message="HEY")
        event.put()

        history = self.service.history(5, up, start=date(2011, 4, 5))

        self.assertEquals(history[0]["information"], True)
        self.assertEquals(history[0]["name"], "information")

    def test_history_one_error_boundary(self):
        down = Status.get_by_slug("down")
        up = Status.get_by_slug("up")

        now = datetime(2011, 3, 31)
        event = Event(status=down, service=self.service, start=now, message="HEY")
        event.put()

        history = self.service.history(5, up, start=date(2011, 4, 5))

        self.assertEquals(history[4]["information"], True)
        self.assertEquals(history[4]["name"], "information")

    def test_history_count(self):
#.........这里部分代码省略.........
开发者ID:2do,项目名称:stashboard,代码行数:103,代码来源:test_history.py


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