本文整理汇总了Python中socorro.external.postgresql.crashes.Crashes.get_frequency方法的典型用法代码示例。如果您正苦于以下问题:Python Crashes.get_frequency方法的具体用法?Python Crashes.get_frequency怎么用?Python Crashes.get_frequency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类socorro.external.postgresql.crashes.Crashes
的用法示例。
在下文中一共展示了Crashes.get_frequency方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_frequency
# 需要导入模块: from socorro.external.postgresql.crashes import Crashes [as 别名]
# 或者: from socorro.external.postgresql.crashes.Crashes import get_frequency [as 别名]
def test_get_frequency(self):
self.config.webapi = util.DotDict()
self.config.webapi.platforms = (
{
"id": "windows",
"name": "Windows NT"
},
{
"id": "linux",
"name": "Linux"
}
)
crashes = Crashes(config=self.config)
# .....................................................................
# Test 1
params = {
"signature": "js"
}
res_expected = {
"hits": [
{
"build_date": "2012033117",
"count": 1,
"frequency": 1.0,
"total": 1,
"count_windows": 1,
"frequency_windows": 1.0,
"count_linux": 0,
"frequency_linux": 0
},
{
"build_date": "2012033116",
"count": 2,
"frequency": 1.0,
"total": 2,
"count_windows": 1,
"frequency_windows": 1.0,
"count_linux": 1,
"frequency_linux": 1.0
}
],
"total": 2
}
res = crashes.get_frequency(**params)
eq_(res, res_expected)
# .....................................................................
# Test 2
params = {
"signature": "blah"
}
res_expected = {
"hits": [
{
"build_date": "2012033117",
"count": 1,
"frequency": 1.0,
"total": 1,
"count_windows": 0,
"frequency_windows": 0.0,
"count_linux": 0,
"frequency_linux": 0.0
}
],
"total": 1
}
res = crashes.get_frequency(**params)
eq_(res, res_expected)
# .....................................................................
# Verify that it is not possible to break the query.
params = {
"signature": "sig'"
}
res = crashes.get_frequency(**params)
eq_(res["total"], 0)
示例2: test_get_frequency
# 需要导入模块: from socorro.external.postgresql.crashes import Crashes [as 别名]
# 或者: from socorro.external.postgresql.crashes.Crashes import get_frequency [as 别名]
def test_get_frequency(self):
self.config.platforms = (
{
"id": "windows",
"name": "Windows NT"
},
{
"id": "linux",
"name": "Linux"
}
)
crashes = Crashes(config=self.config)
#......................................................................
# Test 1
params = {
"signature": "js"
}
res_expected = {
"hits": [
{
"build_date": "2012033117",
"count": 1,
"frequency": 1.0,
"total": 1,
"count_windows": 1,
"frequency_windows": 1.0,
"count_linux": 0,
"frequency_linux": 0
},
{
"build_date": "2012033116",
"count": 2,
"frequency": 1.0,
"total": 2,
"count_windows": 1,
"frequency_windows": 1.0,
"count_linux": 1,
"frequency_linux": 1.0
}
],
"total": 2
}
res = crashes.get_frequency(**params)
self.assertEqual(res, res_expected)
#......................................................................
# Test 2
params = {
"signature": "blah"
}
res_expected = {
"hits": [
{
"build_date": "2012033117",
"count": 1,
"frequency": 1.0,
"total": 1,
"count_windows": 0,
"frequency_windows": 0.0,
"count_linux": 0,
"frequency_linux": 0.0
}
],
"total": 1
}
res = crashes.get_frequency(**params)
self.assertEqual(res, res_expected)