本文整理汇总了Python中socorro.external.postgresql.crashes.Crashes.get_count_by_day方法的典型用法代码示例。如果您正苦于以下问题:Python Crashes.get_count_by_day方法的具体用法?Python Crashes.get_count_by_day怎么用?Python Crashes.get_count_by_day使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类socorro.external.postgresql.crashes.Crashes
的用法示例。
在下文中一共展示了Crashes.get_count_by_day方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_count_by_day
# 需要导入模块: from socorro.external.postgresql.crashes import Crashes [as 别名]
# 或者: from socorro.external.postgresql.crashes.Crashes import get_count_by_day [as 别名]
def test_get_count_by_day(self):
crashes = Crashes(config=self.config)
now = datetime.datetime.utcnow()
yesterday = now - datetime.timedelta(1)
tomorrow = now + datetime.timedelta(1)
now = now.strftime("%Y-%m-%d")
yesterday = yesterday.strftime("%Y-%m-%d")
tomorrow = tomorrow.strftime("%Y-%m-%d")
params = {
'signature': 'js',
'start_date': now
}
expected = {
'hits': {now: 3},
'total': 1
}
res = crashes.get_count_by_day(**params)
eq_(res, expected)
params = {
'signature': 'nothing',
'start_date': now
}
expected = {
'hits': {now: 0},
'total': 1
}
res = crashes.get_count_by_day(**params)
eq_(res, expected)
params = {
'signature': 'js',
'start_date': yesterday,
'end_date': tomorrow
}
expected = {
'hits': {
yesterday: 2,
now: 3
},
'total': 2
}
res = crashes.get_count_by_day(**params)
eq_(res, expected)