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


Python Crashes.get_signature_history方法代码示例

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


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

示例1: test_get_signature_history

# 需要导入模块: from socorro.external.postgresql.crashes import Crashes [as 别名]
# 或者: from socorro.external.postgresql.crashes.Crashes import get_signature_history [as 别名]
    def test_get_signature_history(self):
        api = Crashes(config=self.config)
        now = self.now
        lastweek = now - datetime.timedelta(days=7)

        params = {
            "product": "Firefox",
            "version": "8.0",
            "signature": "signature1",
            "start_date": lastweek,
            "end_date": now,
        }
        res = api.get_signature_history(**params)

        self.assertEqual(len(res["hits"]), 2)
        self.assertEqual(len(res["hits"]), res["total"])

        date = datetimeutil.date_to_string(now.date())
        self.assertEqual(res["hits"][0]["date"], date)
        self.assertEqual(res["hits"][1]["date"], date)

        self.assertEqual(res["hits"][0]["count"], 5)
        self.assertEqual(res["hits"][1]["count"], 14)

        self.assertEqual(round(res["hits"][0]["percent_of_total"], 2), round(5.0 / 19.0 * 100, 2))
        self.assertEqual(round(res["hits"][1]["percent_of_total"], 2), round(14.0 / 19.0 * 100, 2))

        # Test no results
        params = {
            "product": "Firefox",
            "version": "9.0",
            "signature": "signature1",
            "start_date": lastweek,
            "end_date": now,
        }
        res = api.get_signature_history(**params)
        res_expected = {"hits": [], "total": 0}
        self.assertEqual(res, res_expected)

        # Test default date parameters
        params = {"product": "Fennec", "version": "11.0.1", "signature": "signature3"}
        res = api.get_signature_history(**params)
        res_expected = {"hits": [{"date": now.date().isoformat(), "count": 14, "percent_of_total": 100}], "total": 1}
        self.assertEqual(res, res_expected)

        # Test missing parameters
        self.assertRaises(MissingOrBadArgumentError, api.get_signature_history)
        self.assertRaises(MissingOrBadArgumentError, api.get_signature_history, **{"product": "Firefox"})
        self.assertRaises(
            MissingOrBadArgumentError, api.get_signature_history, **{"product": "Firefox", "version": "8.0"}
        )
        self.assertRaises(
            MissingOrBadArgumentError, api.get_signature_history, **{"signature": "signature1", "version": "8.0"}
        )
开发者ID:smillaedler,项目名称:socorro,代码行数:56,代码来源:test_crashes_signatures.py


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