本文整理汇总了Python中socorro.external.postgresql.crashes.Crashes.get_exploitability方法的典型用法代码示例。如果您正苦于以下问题:Python Crashes.get_exploitability方法的具体用法?Python Crashes.get_exploitability怎么用?Python Crashes.get_exploitability使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类socorro.external.postgresql.crashes.Crashes
的用法示例。
在下文中一共展示了Crashes.get_exploitability方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_exploitibility_by_product
# 需要导入模块: from socorro.external.postgresql.crashes import Crashes [as 别名]
# 或者: from socorro.external.postgresql.crashes.Crashes import get_exploitability [as 别名]
def test_get_exploitibility_by_product(self):
crashes = Crashes(config=self.config)
res_expected = {
"hits": [
{
"signature": "canIhaveYourSignature()",
"null_count": 0,
"none_count": 1,
"low_count": 2,
"medium_count": 3,
"high_count": 4
},
{
"signature": "ofCourseYouCan()",
"null_count": 5,
"none_count": 7,
"low_count": 2,
"medium_count": 2,
"high_count": 0
},
],
"total": 2,
}
res = crashes.get_exploitability(product='Firefox')
eq_(res, res_expected)
示例2: test_get_exploitibility_by_report_date
# 需要导入模块: from socorro.external.postgresql.crashes import Crashes [as 别名]
# 或者: from socorro.external.postgresql.crashes.Crashes import get_exploitability [as 别名]
def test_get_exploitibility_by_report_date(self):
crashes = Crashes(config=self.config)
yesterday_date = (self.now - datetime.timedelta(days=1)).date()
yesterday = datetimeutil.date_to_string(yesterday_date)
res_expected = {
"hits": [
{
"signature": "canIhaveYourSignature()",
"null_count": 2,
"none_count": 2,
"low_count": 2,
"medium_count": 2,
"high_count": 2
},
{
"signature": "ofCourseYouCan()",
"null_count": 4,
"none_count": 3,
"low_count": 2,
"medium_count": 1,
"high_count": 0
}
],
"total": 2,
}
res = crashes.get_exploitability(
start_date=yesterday,
end_date=yesterday
)
eq_(res, res_expected)
示例3: test_get_exploitibility
# 需要导入模块: from socorro.external.postgresql.crashes import Crashes [as 别名]
# 或者: from socorro.external.postgresql.crashes.Crashes import get_exploitability [as 别名]
def test_get_exploitibility(self):
crashes = Crashes(config=self.config)
res_expected = {
"hits": [
{
"signature": "canIhaveYourSignature()",
"null_count": 2,
"none_count": 3,
"low_count": 4,
"medium_count": 5,
"high_count": 6
},
{
"signature": "ofCourseYouCan()",
"null_count": 5,
"none_count": 7,
"low_count": 2,
"medium_count": 2,
"high_count": 0
}
],
"total": 2,
}
res = crashes.get_exploitability()
self.assertEqual(res, res_expected)
示例4: test_get_exploitibility_by_product_and_version
# 需要导入模块: from socorro.external.postgresql.crashes import Crashes [as 别名]
# 或者: from socorro.external.postgresql.crashes.Crashes import get_exploitability [as 别名]
def test_get_exploitibility_by_product_and_version(self):
crashes = Crashes(config=self.config)
res_expected = {
"hits": [
{
"signature": "ofCourseYouCan()",
"null_count": 1,
"none_count": 4,
"low_count": 0,
"medium_count": 1,
"high_count": 0
}
],
"total": 1,
}
res = crashes.get_exploitability(product='Firefox', version='14.0b')
eq_(res, res_expected)
示例5: test_get_exploitibility_with_pagination
# 需要导入模块: from socorro.external.postgresql.crashes import Crashes [as 别名]
# 或者: from socorro.external.postgresql.crashes.Crashes import get_exploitability [as 别名]
def test_get_exploitibility_with_pagination(self):
crashes = Crashes(config=self.config)
yesterday_date = (self.now - datetime.timedelta(days=1)).date()
day_before_yesterday = (self.now - datetime.timedelta(days=2)).date()
j = 100 # some number so it's not used by other tests or fixtures
rand = lambda: random.randint(0, 10)
exploit_values = []
signature_values = []
for day in day_before_yesterday, yesterday_date, self.now:
for i in range(10):
exploit_values.append(
"(%s, 3, 'Signature%s%s', '%s', %s, %s, %s, %s, %s)" % (
j + 1, j, i, day,
rand(), rand(), rand(), rand(), rand()
)
)
signature_values.append(
"(%s, 'Signature%s%s', %s, '%s')" % (
j + 1, j, i, day.strftime('%Y%m%d%H'), day
)
)
j += 1
cursor = self.connection.cursor()
insert = """
INSERT INTO signatures
(signature_id, signature, first_build, first_report)
VALUES
"""
insert += ',\n'.join(signature_values)
cursor.execute(insert)
insert = """
INSERT INTO exploitability_reports
(signature_id, product_version_id, signature, report_date,
null_count, none_count, low_count, medium_count, high_count)
VALUES
"""
insert += ',\n'.join(exploit_values)
cursor.execute(insert)
self.connection.commit()
res = crashes.get_exploitability()
eq_(len(res['hits']), res['total'])
ok_(res['total'] >= 3 * 10)
res = crashes.get_exploitability(
start_date=yesterday_date,
end_date=self.now
)
eq_(len(res['hits']), res['total'])
ok_(res['total'] >= 2 * 10)
ok_(res['total'] < 3 * 10)
# passing a `page` without `batch` will yield an error
assert_raises(
MissingArgumentError,
crashes.get_exploitability,
page=2
)
# `page` starts on one so anything smaller is bad
assert_raises(
BadArgumentError,
crashes.get_exploitability,
page=0,
batch=15
)
# Note, `page=1` is on number line starting on 1
res = crashes.get_exploitability(
page=1,
batch=15
)
self.assertNotEqual(len(res['hits']), res['total'])
eq_(len(res['hits']), 15)
ok_(res['total'] >= 3 * 10)
# since it's ordered by "medium + high"...
med_or_highs = [
x['medium_count'] + x['high_count']
for x in res['hits']
]
eq_(
med_or_highs[0],
max(med_or_highs)
)
eq_(
med_or_highs[-1],
min(med_or_highs)
)