本文整理汇总了Python中socorro.external.postgresql.products.ProductVersions.get方法的典型用法代码示例。如果您正苦于以下问题:Python ProductVersions.get方法的具体用法?Python ProductVersions.get怎么用?Python ProductVersions.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类socorro.external.postgresql.products.ProductVersions
的用法示例。
在下文中一共展示了ProductVersions.get方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_filter_by_start_date
# 需要导入模块: from socorro.external.postgresql.products import ProductVersions [as 别名]
# 或者: from socorro.external.postgresql.products.ProductVersions import get [as 别名]
def test_filter_by_start_date(self):
productversions = ProductVersions(config=self.config)
now = self.now.date()
res = productversions.get(start_date='>=' + now.isoformat())
eq_(res['total'], 4)
res = productversions.get(start_date='<' + now.isoformat())
eq_(res['total'], 1)
示例2: test_filter_by_featured
# 需要导入模块: from socorro.external.postgresql.products import ProductVersions [as 别名]
# 或者: from socorro.external.postgresql.products.ProductVersions import get [as 别名]
def test_filter_by_featured(self):
productversions = ProductVersions(config=self.config)
res = productversions.get(is_featured=True)
assert len(res['hits']) == 1
assert res['total'] == 1
assert all(x['is_featured'] for x in res['hits'])
res = productversions.get(is_featured=False)
assert res['total'] == 4
assert len(res['hits']) == 4
assert all(not x['is_featured'] for x in res['hits'])
示例3: test_filter_by_featured
# 需要导入模块: from socorro.external.postgresql.products import ProductVersions [as 别名]
# 或者: from socorro.external.postgresql.products.ProductVersions import get [as 别名]
def test_filter_by_featured(self):
productversions = ProductVersions(config=self.config)
res = productversions.get(is_featured=True)
eq_(len(res['hits']), 1)
eq_(res['total'], 1)
ok_(all(x['is_featured'] for x in res['hits']))
res = productversions.get(is_featured=False)
eq_(res['total'], 4)
eq_(len(res['hits']), 4)
ok_(all(not x['is_featured'] for x in res['hits']))
示例4: test_filter_by_build_type
# 需要导入模块: from socorro.external.postgresql.products import ProductVersions [as 别名]
# 或者: from socorro.external.postgresql.products.ProductVersions import get [as 别名]
def test_filter_by_build_type(self):
productversions = ProductVersions(config=self.config)
res = productversions.get(
build_type=['Beta'],
)
eq_(res['total'], 1)
for hit in res['hits']:
eq_(hit['build_type'], 'Beta')
res = productversions.get(
build_type=['JUNK'],
)
eq_(res['total'], 0)
示例5: test_filter_by_build_type
# 需要导入模块: from socorro.external.postgresql.products import ProductVersions [as 别名]
# 或者: from socorro.external.postgresql.products.ProductVersions import get [as 别名]
def test_filter_by_build_type(self):
productversions = ProductVersions(config=self.config)
res = productversions.get(
build_type=['Beta'],
)
assert res['total'] == 1
for hit in res['hits']:
assert hit['build_type'] == 'Beta'
res = productversions.get(
build_type=['JUNK'],
)
assert res['total'] == 0
示例6: test_filter_by_is_rapid_beta
# 需要导入模块: from socorro.external.postgresql.products import ProductVersions [as 别名]
# 或者: from socorro.external.postgresql.products.ProductVersions import get [as 别名]
def test_filter_by_is_rapid_beta(self):
productversions = ProductVersions(config=self.config)
res = true_results = productversions.get(is_rapid_beta=True)
assert res['total'] == 1
for hit in res['hits']:
assert hit['is_rapid_beta']
res = false_results = productversions.get(is_rapid_beta=False)
assert res['total'] == 4
for hit in res['hits']:
assert not hit['is_rapid_beta']
both_results = productversions.get()
assert both_results['total'] == true_results['total'] + false_results['total']
示例7: test_get_basic
# 需要导入模块: from socorro.external.postgresql.products import ProductVersions [as 别名]
# 或者: from socorro.external.postgresql.products.ProductVersions import get [as 别名]
def test_get_basic(self):
productversions = ProductVersions(config=self.config)
now = self.now.date()
lastweek = now - datetime.timedelta(days=7)
# Find one exact match for one product and one version
params = {
"product": "Firefox",
"version": "8.0",
}
res = productversions.get(**params)
res_expected = {
"hits": [{
"is_featured": False,
"version": "8.0",
"throttle": 10.0,
"start_date": lastweek,
"end_date": lastweek,
"has_builds": False,
"product": "Firefox",
"build_type": "Release",
"is_rapid_beta": False,
}],
"total": 1
}
eq_(res['total'], res_expected['total'])
eq_(
sorted(res['hits'][0]),
sorted(res_expected['hits'][0])
)
eq_(res['hits'], res_expected['hits'])
示例8: test_filter_by_is_rapid_beta
# 需要导入模块: from socorro.external.postgresql.products import ProductVersions [as 别名]
# 或者: from socorro.external.postgresql.products.ProductVersions import get [as 别名]
def test_filter_by_is_rapid_beta(self):
productversions = ProductVersions(config=self.config)
res = true_results = productversions.get(is_rapid_beta=True)
eq_(res['total'], 1)
for hit in res['hits']:
ok_(hit['is_rapid_beta'])
res = false_results = productversions.get(is_rapid_beta=False)
eq_(res['total'], 4)
for hit in res['hits']:
ok_(not hit['is_rapid_beta'])
both_results = productversions.get()
eq_(
both_results['total'],
true_results['total'] + false_results['total']
)
示例9: test_filter_by_end_date
# 需要导入模块: from socorro.external.postgresql.products import ProductVersions [as 别名]
# 或者: from socorro.external.postgresql.products.ProductVersions import get [as 别名]
def test_filter_by_end_date(self):
productversions = ProductVersions(config=self.config)
now = self.now.date()
nextweek = now + datetime.timedelta(days=7)
res = productversions.get(end_date='=' + nextweek.isoformat())
eq_(res['total'], 3)
for hit in res['hits']:
eq_(hit['end_date'], nextweek)
示例10: test_get_with_one_product_multiple_versions
# 需要导入模块: from socorro.external.postgresql.products import ProductVersions [as 别名]
# 或者: from socorro.external.postgresql.products.ProductVersions import get [as 别名]
def test_get_with_one_product_multiple_versions(self):
productversions = ProductVersions(config=self.config)
now = self.now.date()
nextweek = now + datetime.timedelta(days=7)
params = {
"product": "Fennec",
"version": ["11.0.1", "12.0b1"],
}
res = productversions.get(**params)
res_expected = {
"hits": [
{
"is_featured": False,
"version": "12.0b1",
"throttle": 100.0,
"start_date": now,
"end_date": nextweek,
"has_builds": True,
"product": "Fennec",
"build_type": "Beta",
"is_rapid_beta": False,
},
{
"is_featured": False,
"version": "11.0.1",
"throttle": 10.0,
"start_date": now,
"end_date": now,
"has_builds": False,
"product": "Fennec",
"build_type": "Release",
"is_rapid_beta": False,
}
],
"total": 2
}
eq_(res['total'], res_expected['total'])
eq_(
sorted(res['hits'][0]),
sorted(res_expected['hits'][0])
)
eq_(res['hits'][0], res_expected['hits'][0])
eq_(res['hits'][1], res_expected['hits'][1])
示例11: test_filter_by_active
# 需要导入模块: from socorro.external.postgresql.products import ProductVersions [as 别名]
# 或者: from socorro.external.postgresql.products.ProductVersions import get [as 别名]
def test_filter_by_active(self):
productversions = ProductVersions(config=self.config)
now = self.now.date()
nextweek = now + datetime.timedelta(days=7)
res = active_results = productversions.get(active=True)
eq_(res['total'], 4)
res_expected = {
"hits":
[
{
"product": "Firefox",
"version": "9.0",
"start_date": now,
"end_date": nextweek,
"throttle": 100.00,
"is_featured": True,
"build_type": "Nightly",
"has_builds": True,
"is_rapid_beta": False,
},
{
"product": "Thunderbird",
"version": "10.0.2b",
"start_date": now,
"end_date": nextweek,
"throttle": 10.00,
"is_featured": False,
"build_type": "Release",
"has_builds": False,
"is_rapid_beta": True,
},
{
"product": "Fennec",
"version": "12.0b1",
"start_date": now,
"end_date": nextweek,
"throttle": 100.00,
"is_featured": False,
"build_type": "Beta",
"has_builds": True,
"is_rapid_beta": False,
},
{
"product": "Fennec",
"version": "11.0.1",
"start_date": now,
"end_date": now,
"throttle": 10.00,
"is_featured": False,
"build_type": "Release",
"has_builds": False,
"is_rapid_beta": False,
},
],
"total": 3
}
eq_(res['hits'][0], res_expected['hits'][0])
eq_(res['hits'][1], res_expected['hits'][1])
eq_(res['hits'][2], res_expected['hits'][2])
eq_(res['hits'][3], res_expected['hits'][3])
for hit in res['hits']:
ok_(hit['end_date'] >= now, hit)
res = not_active_results = productversions.get(active=False)
eq_(res['total'], 1)
both_results = productversions.get()
eq_(
both_results['total'],
active_results['total'] + not_active_results['total']
)
示例12: test_get_no_parameter_returning_all
# 需要导入模块: from socorro.external.postgresql.products import ProductVersions [as 别名]
# 或者: from socorro.external.postgresql.products.ProductVersions import get [as 别名]
def test_get_no_parameter_returning_all(self):
productversions = ProductVersions(config=self.config)
now = self.now.date()
lastweek = now - datetime.timedelta(days=7)
nextweek = now + datetime.timedelta(days=7)
# Test products list is returned with no parameters
# Note that the expired version is not returned
res = productversions.get()
res_expected = {
"hits":
[
{
"product": "Firefox",
"version": "9.0",
"start_date": now,
"end_date": nextweek,
"throttle": 100.00,
"is_featured": True,
"build_type": "Nightly",
"has_builds": True,
"is_rapid_beta": False,
},
{
"product": "Firefox",
"version": "8.0",
"start_date": lastweek,
"end_date": lastweek,
"throttle": 10.00,
"is_featured": False,
"build_type": "Release",
"has_builds": False,
"is_rapid_beta": False,
},
{
"product": "Thunderbird",
"version": "10.0.2b",
"start_date": now,
"end_date": nextweek,
"throttle": 10.00,
"is_featured": False,
"build_type": "Release",
"has_builds": False,
"is_rapid_beta": True,
},
{
"product": "Fennec",
"version": "12.0b1",
"start_date": now,
"end_date": nextweek,
"throttle": 100.00,
"is_featured": False,
"build_type": "Beta",
"has_builds": True,
"is_rapid_beta": False,
},
{
"product": "Fennec",
"version": "11.0.1",
"start_date": now,
"end_date": now,
"throttle": 10.00,
"is_featured": False,
"build_type": "Release",
"has_builds": False,
"is_rapid_beta": False,
}
],
"total": 5
}
eq_(res['total'], res_expected['total'])
assert res['total'] == len(res['hits'])
# same keys
keys = set(res['hits'][0].keys())
expected_keys = set(res_expected['hits'][0].keys())
eq_(keys, expected_keys)
eq_(len(res['hits']), len(res_expected['hits']))
eq_(res['hits'], res_expected['hits'])