本文整理汇总了Python中socorro.external.postgresql.crashes.Crashes.get_signatures方法的典型用法代码示例。如果您正苦于以下问题:Python Crashes.get_signatures方法的具体用法?Python Crashes.get_signatures怎么用?Python Crashes.get_signatures使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类socorro.external.postgresql.crashes.Crashes
的用法示例。
在下文中一共展示了Crashes.get_signatures方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_signatures
# 需要导入模块: from socorro.external.postgresql.crashes import Crashes [as 别名]
# 或者: from socorro.external.postgresql.crashes.Crashes import get_signatures [as 别名]
def test_get_signatures(self):
tcbs = Crashes(config=self.config)
now = datetimeutil.utc_now()
today = datetime.datetime(now.year, now.month, now.day)
lastweek = today - datetime.timedelta(days=7)
tomorrow_str = (today + datetime.timedelta(days=1)).strftime('%Y-%m-%d')
today_str = today.strftime('%Y-%m-%d')
sixdaysago_str = (lastweek + datetime.timedelta(days=1)).strftime('%Y-%m-%d')
lastweek_str = lastweek.strftime('%Y-%m-%d')
lastweek_str_full = lastweek.strftime('%Y-%m-%d %H:%M:%S')
# Test 1: all TCBS for Firefox
params = {
"product": "Firefox",
"version": "8.0"
}
res = tcbs.get_signatures(**params)
res_expected = {
'totalPercentage': 1.0,
'end_date': tomorrow_str,
'start_date': sixdaysago_str,
'crashes': [
{
'count': 19L,
'mac_count': 1L,
'content_count': 0,
'first_report': lastweek_str,
'previousRank': 0,
'currentRank': 0,
'startup_percent': None,
'versions': 'plugin1, plugin2',
'first_report_exact': lastweek_str_full,
'percentOfTotal': 0.86363636363636398,
'changeInRank': 0,
'win_count': 12L,
'changeInPercentOfTotal': -0.13636363636363602,
'linux_count': 6L,
'hang_count': 5L,
'signature': 'signature1',
'versions_count': 2,
'previousPercentOfTotal': 1.0,
'plugin_count': 0
},
{
'count': 3L,
'mac_count': 1L,
'content_count': 0,
'first_report': lastweek_str,
'previousRank': 'null',
'currentRank': 1,
'startup_percent': None,
'versions': 'plugin1, plugin2, plugin3, plugin4, plugin5, plugin6',
'first_report_exact': lastweek_str_full,
'percentOfTotal': 0.13636363636363599,
'changeInRank': 'new',
'win_count': 1L,
'changeInPercentOfTotal': 'new',
'linux_count': 1L,
'hang_count': 0L,
'signature': 'signature2',
'versions_count': 6,
'previousPercentOfTotal': 'null',
'plugin_count': 0
}
],
'totalNumberOfCrashes': 22L
}
self.assertEqual(res, res_expected)
# Test 2: Limit to one crash type
params = {
"product": "Firefox",
"version": "8.0",
"crash_type": "hang"
}
res = tcbs.get_signatures(**params)
res_expected = {
'totalPercentage': 1.0,
'end_date': tomorrow_str,
'start_date': sixdaysago_str,
'crashes': [
{
'count': 5L,
'mac_count': 0L,
'content_count': 0,
'first_report': lastweek_str,
'previousRank': 'null',
'currentRank': 0,
'startup_percent': None,
'versions': 'plugin1, plugin2',
'first_report_exact': lastweek_str_full,
'percentOfTotal': 1.0,
'changeInRank': 'new',
'win_count': 0L,
'changeInPercentOfTotal': 'new',
'linux_count': 5L,
'hang_count': 5L,
'signature': 'signature1',
#.........这里部分代码省略.........
示例2: test_get_signatures
# 需要导入模块: from socorro.external.postgresql.crashes import Crashes [as 别名]
# 或者: from socorro.external.postgresql.crashes.Crashes import get_signatures [as 别名]
def test_get_signatures(self):
tcbs = Crashes(config=self.config)
now = self.now
today = datetime.datetime(now.year, now.month, now.day)
lastweek = today - datetime.timedelta(days=7)
tomorrow_str = (today + datetime.timedelta(days=1)).strftime("%Y-%m-%d")
sixdaysago_str = (lastweek + datetime.timedelta(days=1)).strftime("%Y-%m-%d")
lastweek_str = lastweek.strftime("%Y-%m-%d")
lastweek_str_full = lastweek.strftime("%Y-%m-%d %H:%M:%S")
# Test 1: all TCBS for Firefox
params = {"product": "Firefox", "version": "8.0"}
res = tcbs.get_signatures(**params)
res_expected = {
"totalPercentage": 1.0,
"end_date": tomorrow_str,
"start_date": sixdaysago_str,
"crashes": [
{
"count": 19L,
"mac_count": 1L,
"content_count": 0,
"first_report": lastweek_str,
"previousRank": 0,
"currentRank": 0,
"startup_percent": None,
"versions": "plugin1, plugin2",
"first_report_exact": lastweek_str_full,
"percentOfTotal": 0.86363636363636398,
"changeInRank": 0,
"win_count": 12L,
"changeInPercentOfTotal": -0.13636363636363602,
"linux_count": 6L,
"hang_count": 5L,
"signature": "signature1",
"versions_count": 2,
"previousPercentOfTotal": 1.0,
"plugin_count": 0,
"is_gc_count": 11L,
},
{
"count": 3L,
"mac_count": 1L,
"content_count": 0,
"first_report": lastweek_str,
"previousRank": "null",
"currentRank": 1,
"startup_percent": None,
"versions": "plugin1, plugin2, plugin3, plugin4, plugin5, plugin6",
"first_report_exact": lastweek_str_full,
"percentOfTotal": 0.13636363636363599,
"changeInRank": "new",
"win_count": 1L,
"changeInPercentOfTotal": "new",
"linux_count": 1L,
"hang_count": 0L,
"signature": "signature2",
"versions_count": 6,
"previousPercentOfTotal": "null",
"plugin_count": 0,
"is_gc_count": 1L,
},
],
"totalNumberOfCrashes": 22L,
}
self.assertEqual(res, res_expected)
# Test 2: Limit to one crash type
params = {"product": "Firefox", "version": "8.0", "crash_type": "hang"}
res = tcbs.get_signatures(**params)
res_expected = {
"totalPercentage": 1.0,
"end_date": tomorrow_str,
"start_date": sixdaysago_str,
"crashes": [
{
"count": 5L,
"mac_count": 0L,
"content_count": 0,
"first_report": lastweek_str,
"previousRank": "null",
"currentRank": 0,
"startup_percent": None,
"versions": "plugin1, plugin2",
"first_report_exact": lastweek_str_full,
"percentOfTotal": 1.0,
"changeInRank": "new",
"win_count": 0L,
"changeInPercentOfTotal": "new",
"linux_count": 5L,
"hang_count": 5L,
"signature": "signature1",
"versions_count": 2,
"previousPercentOfTotal": "null",
"plugin_count": 0,
"is_gc_count": 10L,
}
],
#.........这里部分代码省略.........