本文整理匯總了Python中socorro.external.postgresql.products.Products.get方法的典型用法代碼示例。如果您正苦於以下問題:Python Products.get方法的具體用法?Python Products.get怎麽用?Python Products.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類socorro.external.postgresql.products.Products
的用法示例。
在下文中一共展示了Products.get方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_get_webapp_products
# 需要導入模塊: from socorro.external.postgresql.products import Products [as 別名]
# 或者: from socorro.external.postgresql.products.Products import get [as 別名]
def test_get_webapp_products(self):
api = Products(config=self.config)
res = api.get(type='webapp')
res_expected = {
'products': ['ClockOClock', 'EmailApp'],
'hits': {
'EmailApp': [
{
"product": "EmailApp",
"version": "0.2",
"start_date": None,
"end_date": None,
"throttle": 1.0,
"featured": False,
"release": "Beta",
"has_builds": False
},
{
"product": "EmailApp",
"version": "0.1",
"start_date": None,
"end_date": None,
"throttle": 1.0,
"featured": False,
"release": "Release",
"has_builds": False
}
],
'ClockOClock': [
{
"product": "ClockOClock",
"version": "1.0.18",
"start_date": None,
"end_date": None,
"throttle": 1.0,
"featured": False,
"release": "Release",
"has_builds": False
}
]
},
'total': 3
}
self.assertEqual(res, res_expected)
示例2: test_get
# 需要導入模塊: from socorro.external.postgresql.products import Products [as 別名]
# 或者: from socorro.external.postgresql.products.Products import get [as 別名]
def test_get(self):
products = Products(config=self.config)
now = datetimeutil.utc_now().date()
lastweek = now - datetime.timedelta(days=7)
now_str = datetimeutil.date_to_string(now)
lastweek_str = datetimeutil.date_to_string(lastweek)
#......................................................................
# Test 1: find one exact match for one product and one version
params = {
"versions": "Firefox:8.0"
}
res = products.get(**params)
res_expected = {
"hits": [
{
"product": "Firefox",
"version": "8.0",
"start_date": now_str,
"end_date": now_str,
"is_featured": False,
"build_type": "Release",
"throttle": 10.0,
"has_builds": False
}
],
"total": 1
}
self.assertEqual(res, res_expected)
#......................................................................
# Test 2: Find two different products with their correct verions
params = {
"versions": ["Firefox:8.0", "Thunderbird:10.0.2b"]
}
res = products.get(**params)
res_expected = {
"hits": [
{
"product": "Firefox",
"version": "8.0",
"start_date": now_str,
"end_date": now_str,
"is_featured": False,
"build_type": "Release",
"throttle": 10.0,
"has_builds": False
},
{
"product": "Thunderbird",
"version": "10.0.2b",
"start_date": now_str,
"end_date": now_str,
"is_featured": False,
"build_type": "Release",
"throttle": 10.0,
"has_builds": False
}
],
"total": 2
}
self.assertEqual(res, res_expected)
#......................................................................
# Test 3: empty result, no products:version found
params = {
"versions": "Firefox:14.0"
}
res = products.get(**params)
res_expected = {
"hits": [],
"total": 0
}
self.assertEqual(res, res_expected)
#......................................................................
# Test 4: Test products list is returned with no parameters
# Note that the expired version is not returned
params = {}
res = products.get(**params)
res_expected = {
"products": ["Firefox", "Thunderbird", "Fennec"],
"hits": {
"Firefox": [
{
"product": "Firefox",
"version": "8.0",
"start_date": now_str,
"end_date": now_str,
"throttle": 10.00,
"featured": False,
"release": "Release",
"has_builds": False
}
],
"Thunderbird": [
{
#.........這裏部分代碼省略.........
示例3: test_get
# 需要導入模塊: from socorro.external.postgresql.products import Products [as 別名]
# 或者: from socorro.external.postgresql.products.Products import get [as 別名]
def test_get(self):
products = Products(config=self.config)
now = self.now.date()
lastweek = now - datetime.timedelta(days=7)
nextweek = now + datetime.timedelta(days=7)
now_str = datetimeutil.date_to_string(now)
lastweek_str = datetimeutil.date_to_string(lastweek)
nextweek_str = datetimeutil.date_to_string(nextweek)
#......................................................................
# Test 1: find one exact match for one product and one version
params = {
"versions": "Firefox:8.0"
}
res = products.get(**params)
res_expected = {
"hits": [
{
"is_featured": False,
"version": "8.0",
"throttle": 10.0,
"start_date": now_str,
"end_date": now_str,
"has_builds": False,
"product": "Firefox",
"build_type": "Release"
}
],
"total": 1
}
# make sure the 'throttle' is a floating point number
ok_(isinstance(res['hits'][0]['throttle'], float))
eq_(
sorted(res['hits'][0]),
sorted(res_expected['hits'][0])
)
#......................................................................
# Test 2: Find two different products with their correct verions
params = {
"versions": ["Firefox:8.0", "Thunderbird:10.0.2b"]
}
res = products.get(**params)
res_expected = {
"hits": [
{
"product": "Firefox",
"version": "8.0",
"start_date": now_str,
"end_date": now_str,
"is_featured": False,
"build_type": "Release",
"throttle": 10.0,
"has_builds": True
},
{
"product": "Thunderbird",
"version": "10.0.2b",
"start_date": now_str,
"end_date": now_str,
"is_featured": False,
"build_type": "Release",
"throttle": 10.0,
"has_builds": False
}
],
"total": 2
}
eq_(
sorted(res['hits'][0]),
sorted(res_expected['hits'][0])
)
#......................................................................
# Test 3: empty result, no products:version found
params = {
"versions": "Firefox:14.0"
}
res = products.get(**params)
res_expected = {
"hits": [],
"total": 0
}
eq_(res, res_expected)
#......................................................................
# Test 4: Test products list is returned with no parameters
params = {}
res = products.get(**params)
res_expected = {
"products": ["Firefox", "Thunderbird", "Fennec"],
"hits": {
"Firefox": [
{
"product": "Firefox",
"version": "9.0",
"start_date": now_str,
"end_date": nextweek_str,
#.........這裏部分代碼省略.........
示例4: test_get
# 需要導入模塊: from socorro.external.postgresql.products import Products [as 別名]
# 或者: from socorro.external.postgresql.products.Products import get [as 別名]
def test_get(self):
products = Products(config=self.config)
now = datetimeutil.utc_now()
now = datetime.datetime(now.year, now.month, now.day)
now_str = datetimeutil.date_to_string(now)
#......................................................................
# Test 1: find one exact match for one product and one version
params = {
"versions": "Firefox:8.0"
}
res = products.get(**params)
res_expected = {
"hits": [
{
"product": "Firefox",
"version": "8.0",
"start_date": now_str,
"end_date": now_str,
"is_featured": False,
"build_type": "Release",
"throttle": 10.0
}
],
"total": 1
}
self.assertEqual(res, res_expected)
#......................................................................
# Test 2: Find two different products with their correct verions
params = {
"versions": ["Firefox:8.0", "Thunderbird:10.0.2b"]
}
res = products.get(**params)
res_expected = {
"hits": [
{
"product": "Firefox",
"version": "8.0",
"start_date": now_str,
"end_date": now_str,
"is_featured": False,
"build_type": "Release",
"throttle": 10.0
},
{
"product": "Thunderbird",
"version": "10.0.2b",
"start_date": now_str,
"end_date": now_str,
"is_featured": False,
"build_type": "Release",
"throttle": 10.0
}
],
"total": 2
}
self.assertEqual(res, res_expected)
#......................................................................
# Test 3: empty result, no products:version found
params = {
"versions": "Firefox:14.0"
}
res = products.get(**params)
res_expected = {
"hits": [],
"total": 0
}
self.assertEqual(res, res_expected)
#......................................................................
# Test 4: Test products list is returned with no parameters
params = {}
res = products.get(**params)
res_expected = {
"hits": [
{
"product_name": "Firefox",
"release_name": "firefox",
"sort": 1,
"rapid_release_version": "8.0"
},
{
"product_name": "Fennec",
"release_name": "mobile",
"sort": 3,
"rapid_release_version": "11.0"
},
{
"product_name": "Thunderbird",
"release_name": "thunderbird",
"sort": 2,
"rapid_release_version": "10.0"
}
],
"total": 3
#.........這裏部分代碼省略.........
示例5: test_get
# 需要導入模塊: from socorro.external.postgresql.products import Products [as 別名]
# 或者: from socorro.external.postgresql.products.Products import get [as 別名]
def test_get(self):
products = Products(config=self.config)
now = self.now.date()
now_str = datetimeutil.date_to_string(now)
# ......................................................................
# Test 1: find one exact match for one product and one version
params = {"versions": "Firefox:8.0"}
res = products.get(**params)
res_expected = {
"hits": [
{
"is_featured": False,
"version": "8.0",
"throttle": 10.0,
"start_date": now_str,
"end_date": now_str,
"has_builds": False,
"product": "Firefox",
"build_type": "Release",
}
],
"total": 1,
}
eq_(sorted(res["hits"][0]), sorted(res_expected["hits"][0]))
# ......................................................................
# Test 2: Find two different products with their correct verions
params = {"versions": ["Firefox:8.0", "Thunderbird:10.0.2b"]}
res = products.get(**params)
res_expected = {
"hits": [
{
"product": "Firefox",
"version": "8.0",
"start_date": now_str,
"end_date": now_str,
"is_featured": False,
"build_type": "Release",
"throttle": 10.0,
"has_builds": False,
},
{
"product": "Thunderbird",
"version": "10.0.2b",
"start_date": now_str,
"end_date": now_str,
"is_featured": False,
"build_type": "Release",
"throttle": 10.0,
"has_builds": False,
},
],
"total": 2,
}
eq_(sorted(res["hits"][0]), sorted(res_expected["hits"][0]))
# ......................................................................
# Test 3: empty result, no products:version found
params = {"versions": "Firefox:14.0"}
res = products.get(**params)
res_expected = {"hits": [], "total": 0}
eq_(res, res_expected)
# ......................................................................
# Test 4: Test products list is returned with no parameters
# Note that the expired version is not returned
params = {}
res = products.get(**params)
res_expected = {
"products": ["Firefox", "Thunderbird", "Fennec"],
"hits": {
"Firefox": [
{
"product": "Firefox",
"version": "8.0",
"start_date": now_str,
"end_date": now_str,
"throttle": 10.00,
"featured": False,
"release": "Release",
"has_builds": False,
}
],
"Thunderbird": [
{
"product": "Thunderbird",
"version": "10.0.2b",
"start_date": now_str,
"end_date": now_str,
"throttle": 10.00,
"featured": False,
"release": "Release",
"has_builds": False,
}
],
"Fennec": [
#.........這裏部分代碼省略.........