本文整理汇总了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"}
)