本文整理汇总了Python中socorro.external.postgresql.products.ProductVersions类的典型用法代码示例。如果您正苦于以下问题:Python ProductVersions类的具体用法?Python ProductVersions怎么用?Python ProductVersions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ProductVersions类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_get_basic
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'])
开发者ID:4thAce,项目名称:socorro,代码行数:32,代码来源:test_products.py
示例2: test_post_bad_product_name
def test_post_bad_product_name(self):
products = ProductVersions(config=self.config)
ok_(not products.post(
product='Spaces not allowed',
version='',
))
开发者ID:adngdb,项目名称:socorro,代码行数:7,代码来源:test_products.py
示例3: test_filter_by_start_date
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)
开发者ID:4thAce,项目名称:socorro,代码行数:8,代码来源:test_products.py
示例4: test_filter_by_end_date
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)
开发者ID:4thAce,项目名称:socorro,代码行数:9,代码来源:test_products.py
示例5: test_filter_by_featured
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']))
开发者ID:4thAce,项目名称:socorro,代码行数:11,代码来源:test_products.py
示例6: test_filter_by_featured
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'])
开发者ID:stephendonner,项目名称:socorro,代码行数:11,代码来源:test_products.py
示例7: test_filter_by_build_type
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)
开发者ID:4thAce,项目名称:socorro,代码行数:14,代码来源:test_products.py
示例8: test_filter_by_build_type
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
开发者ID:stephendonner,项目名称:socorro,代码行数:14,代码来源:test_products.py
示例9: test_filter_by_is_rapid_beta
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']
开发者ID:stephendonner,项目名称:socorro,代码行数:15,代码来源:test_products.py
示例10: test_get_with_one_product_multiple_versions
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])
开发者ID:4thAce,项目名称:socorro,代码行数:45,代码来源:test_products.py
示例11: test_filter_by_is_rapid_beta
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']
)
开发者ID:4thAce,项目名称:socorro,代码行数:18,代码来源:test_products.py
示例12: test_post
def test_post(self):
products = ProductVersions(config=self.config)
assert products.post(product='KillerApp', version='1.0')
# let's check certain things got written to certain tables
cursor = self.connection.cursor()
try:
# expect there to be a new product
cursor.execute(
'select product_name from products '
"where product_name=%s",
('KillerApp',)
)
product_name, = cursor.fetchone()
assert product_name, 'KillerApp'
finally:
self.connection.rollback()
开发者ID:stephendonner,项目名称:socorro,代码行数:18,代码来源:test_products.py
示例13: test_filter_by_active
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']
)
开发者ID:4thAce,项目名称:socorro,代码行数:72,代码来源:test_products.py
示例14: test_get_no_parameter_returning_all
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'])
开发者ID:4thAce,项目名称:socorro,代码行数:80,代码来源:test_products.py
注:本文中的socorro.external.postgresql.products.ProductVersions类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论