本文整理汇总了Python中mkt.webapps.utils.es_app_to_dict函数的典型用法代码示例。如果您正苦于以下问题:Python es_app_to_dict函数的具体用法?Python es_app_to_dict怎么用?Python es_app_to_dict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了es_app_to_dict函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_devices
def test_devices(self):
AddonDeviceType.objects.create(addon=self.app, device_type=amo.DEVICE_GAIA.id)
self.app.save()
self.refresh("webapp")
res = es_app_to_dict(self.get_obj())
eq_(res["device_types"], ["firefoxos"])
开发者ID:pythonchelle,项目名称:zamboni,代码行数:7,代码来源:test_utils_.py
示例2: test_content_ratings
def test_content_ratings(self):
self.app.set_content_ratings({
ratingsbodies.CLASSIND: ratingsbodies.CLASSIND_18,
ratingsbodies.GENERIC: ratingsbodies.GENERIC_18,
})
self.app.set_descriptors(['has_esrb_blood', 'has_pegi_scary'])
self.app.set_interactives(['has_social_networking', 'has_shares_info'])
self.app.save()
self.refresh('webapp')
res = es_app_to_dict(self.get_obj())
eq_(res['content_ratings']['ratings']['br'],
{'body': 'CLASSIND',
'body_label': 'classind',
'rating': 'For ages 18+',
'rating_label': '18',
'description': unicode(ratingsbodies.CLASSIND_18.description)})
eq_(res['content_ratings']['ratings']['generic'],
{'body': 'Generic',
'body_label': 'generic',
'rating': 'For ages 18+',
'rating_label': '18',
'description': unicode(ratingsbodies.GENERIC_18.description)})
eq_(sorted(res['content_ratings']['descriptors'],
key=lambda x: x['name']),
[{'label': 'esrb-blood', 'name': 'Blood', 'ratings_body': 'esrb'},
{'label': 'pegi-scary', 'name': 'Fear', 'ratings_body': 'pegi'}])
eq_(sorted(res['content_ratings']['interactive_elements'],
key=lambda x: x['name']),
[{'label': 'shares-info', 'name': 'Shares Info'},
{'label': 'social-networking', 'name': 'Social Networking'}])
开发者ID:sylvesterwillis,项目名称:zamboni,代码行数:32,代码来源:test_utils_.py
示例3: test_icons
def test_icons(self):
"""
Tested separately b/c they have timestamps.
"""
res = es_app_to_dict(self.get_obj())
self.assertSetEqual(set([16, 48, 64, 128]), set(res["icons"].keys()))
ok_(res["icons"][128].startswith("http://testserver/img/uploads/addon_icons/337/337141-128.png"))
开发者ID:pythonchelle,项目名称:zamboni,代码行数:7,代码来源:test_utils_.py
示例4: test_basic
def test_basic(self):
res = es_app_to_dict(self.get_obj())
expected = {
"absolute_url": "http://testserver/app/something-something/",
"app_type": "hosted",
"author": "Mozilla Tester",
"created": self.app.created,
"current_version": "1.0",
"description": u"Something Something Steamcube description!",
"homepage": "",
"id": "337141",
"is_packaged": False,
"latest_version": {"status": 4, "is_privileged": False},
"manifest_url": "http://micropipes.com/temp/steamcube.webapp",
"name": "Something Something Steamcube!",
"premium_type": "free",
"public_stats": False,
"ratings": {"average": 0.0, "count": 0},
"slug": "something-something",
"status": 4,
"support_email": None,
"support_url": None,
"user": {"developed": False, "installed": False, "purchased": False},
"versions": {"1.0": "/api/v1/apps/versions/1268829/"},
"weekly_downloads": None,
}
for k, v in res.items():
if k in expected:
eq_(expected[k], v, u'Expected value "%s" for field "%s", got "%s"' % (expected[k], k, v))
开发者ID:pythonchelle,项目名称:zamboni,代码行数:30,代码来源:test_utils_.py
示例5: test_content_ratings
def test_content_ratings(self):
self.create_switch('iarc')
self.app.set_content_ratings({
ratingsbodies.CLASSIND: ratingsbodies.CLASSIND_18,
ratingsbodies.GENERIC: ratingsbodies.GENERIC_18,
})
self.app.set_descriptors(['has_esrb_blood', 'has_pegi_scary'])
self.app.set_interactives(['has_digital_purchases', 'has_shares_info'])
self.app.save()
self.refresh('webapp')
res = es_app_to_dict(self.get_obj())
eq_(res['content_ratings']['ratings']['classind'],
{'body': 'CLASSIND',
'body_label': 'classind',
'rating': 'For ages 18+',
'rating_label': '18',
'description': unicode(ratingsbodies.CLASSIND_18.description)})
eq_(res['content_ratings']['ratings']['generic'],
{'body': 'Generic',
'body_label': 'generic',
'rating': 'For ages 18+',
'rating_label': '18',
'description': unicode(ratingsbodies.GENERIC_18.description)})
eq_(dict(res['content_ratings']['descriptors']),
{'esrb': [{'label': 'blood', 'name': 'Blood'}],
'pegi': [{'label': 'scary', 'name': 'Fear'}]})
eq_(sorted(res['content_ratings']['interactive_elements'],
key=lambda x: x['name']),
[{'label': 'digital-purchases', 'name': 'Digital Purchases'},
{'label': 'shares-info', 'name': 'Shares Info'}])
开发者ID:aricha,项目名称:zamboni,代码行数:32,代码来源:test_utils_.py
示例6: serialize
def serialize(self, req, app):
amo_user = getattr(req, 'amo_user', None)
data = es_app_to_dict(app, region=req.REGION.id,
profile=amo_user,
request=req)
data['resource_uri'] = reverse('app-detail',
kwargs={'pk': data['id']})
return data
开发者ID:hardikj,项目名称:zamboni,代码行数:8,代码来源:api.py
示例7: test_has_price
def test_has_price(self):
self.make_premium(self.app)
self.app.save()
self.refresh('webapp')
res = es_app_to_dict(self.get_obj())
eq_(res['price'], Decimal('1.00'))
eq_(res['price_locale'], '$1.00')
开发者ID:hardikj,项目名称:zamboni,代码行数:8,代码来源:test_utils_.py
示例8: test_content_ratings_regions
def test_content_ratings_regions(self):
self.create_switch('iarc')
res = es_app_to_dict(self.get_obj())
region_rating_bodies = res['content_ratings']['regions']
eq_(region_rating_bodies['br'], 'classind')
eq_(region_rating_bodies['de'], 'usk')
eq_(region_rating_bodies['es'], 'pegi')
eq_(region_rating_bodies['us'], 'esrb')
开发者ID:aricha,项目名称:zamboni,代码行数:8,代码来源:test_utils_.py
示例9: test_user_not_mine
def test_user_not_mine(self):
self.app.addonuser_set.create(user_id=31337)
Installed.objects.create(addon=self.app, user_id=31337)
self.app.addonpurchase_set.create(user_id=31337)
self.app.save()
self.refresh("webapp")
res = es_app_to_dict(self.get_obj(), profile=self.profile)
eq_(res["user"], {"developed": False, "installed": False, "purchased": False})
开发者ID:pythonchelle,项目名称:zamboni,代码行数:9,代码来源:test_utils_.py
示例10: test_user
def test_user(self):
self.app.addonuser_set.create(user=self.profile)
self.profile.installed_set.create(addon=self.app)
self.app.addonpurchase_set.create(user=self.profile)
self.app.save()
self.refresh("webapp")
res = es_app_to_dict(self.get_obj(), profile=self.profile)
eq_(res["user"], {"developed": True, "installed": True, "purchased": True})
开发者ID:pythonchelle,项目名称:zamboni,代码行数:9,代码来源:test_utils_.py
示例11: test_no_currency
def test_no_currency(self):
self.make_premium(self.app)
PriceCurrency.objects.all().delete()
self.app.save()
self.refresh('webapp')
res = es_app_to_dict(self.get_obj())
eq_(res['price'], None)
eq_(res['price_locale'], None)
开发者ID:aricha,项目名称:zamboni,代码行数:9,代码来源:test_utils_.py
示例12: test_has_price
def test_has_price(self):
self.make_premium(self.app)
self.app.save()
self.refresh('webapp')
req = amo.tests.req_factory_factory('/', data={'region': 'us'})
res = es_app_to_dict(self.get_obj(), request=req)
eq_(res['price'], Decimal('1.00'))
eq_(res['price_locale'], '$1.00')
eq_(res['payment_required'], True)
# Test invalid region. This falls back to the region set by the region
# middleware.
req = amo.tests.req_factory_factory('/', data={'region': 'xx'})
res = es_app_to_dict(self.get_obj(), request=req)
eq_(res['price'], Decimal('1.00'))
eq_(res['price_locale'], '$1.00')
eq_(res['payment_required'], True)
开发者ID:aricha,项目名称:zamboni,代码行数:18,代码来源:test_utils_.py
示例13: dehydrate
def dehydrate(self, bundle):
obj = bundle.obj
amo_user = getattr(bundle.request, "amo_user", None)
bundle.data.update(
es_app_to_dict(obj, region=bundle.request.REGION.id, profile=amo_user, request=bundle.request)
)
return bundle
开发者ID:kmaglione,项目名称:zamboni,代码行数:9,代码来源:api.py
示例14: test_not_paid
def test_not_paid(self):
self.make_premium(self.app)
PriceCurrency.objects.update(paid=False)
self.app.save()
self.refresh('webapp')
res = es_app_to_dict(self.get_obj())
eq_(res['price'], None)
eq_(res['price_locale'], None)
开发者ID:aricha,项目名称:zamboni,代码行数:9,代码来源:test_utils_.py
示例15: test_user
def test_user(self):
self.app.addonuser_set.create(user=self.profile)
self.profile.installed_set.create(addon=self.app)
self.app.addonpurchase_set.create(user=self.profile)
self.app.save()
self.refresh('webapp')
res = es_app_to_dict(self.get_obj(), profile=self.profile)
eq_(res['user'],
{'developed': True, 'installed': True, 'purchased': True})
开发者ID:aricha,项目名称:zamboni,代码行数:10,代码来源:test_utils_.py
示例16: test_user_not_mine
def test_user_not_mine(self):
self.app.addonuser_set.create(user_id=31337)
Installed.objects.create(addon=self.app, user_id=31337)
self.app.addonpurchase_set.create(user_id=31337)
self.app.save()
self.refresh('webapp')
res = es_app_to_dict(self.get_obj(), profile=self.profile)
eq_(res['user'],
{'developed': False, 'installed': False, 'purchased': False})
开发者ID:aricha,项目名称:zamboni,代码行数:10,代码来源:test_utils_.py
示例17: test_user
def test_user(self):
AddonPurchase.objects.create(addon=self.app, user=self.profile)
Installed.objects.create(addon=self.app, user=self.profile)
AddonUser.objects.create(addon=self.app, user=self.profile)
self.app.save()
self.refresh('webapp')
res = es_app_to_dict(self.get_obj(), profile=self.profile)
eq_(res['user'],
{'developed': True, 'installed': True, 'purchased': True})
开发者ID:wraithan,项目名称:zamboni,代码行数:10,代码来源:test_utils_.py
示例18: test_content_ratings_regions_no_switch
def test_content_ratings_regions_no_switch(self):
self.app.set_content_ratings({
ratingsbodies.CLASSIND: ratingsbodies.CLASSIND_18,
ratingsbodies.GENERIC: ratingsbodies.GENERIC_18,
})
self.app.save()
self.refresh('webapp')
res = es_app_to_dict(self.get_obj())
assert 'us' not in res['content_ratings']['regions']
eq_(res['content_ratings']['regions']['br'], 'classind')
开发者ID:aricha,项目名称:zamboni,代码行数:11,代码来源:test_utils_.py
示例19: dehydrate
def dehydrate(self, bundle):
obj = bundle.obj
amo_user = getattr(bundle.request, 'amo_user', None)
bundle.data.update(es_app_to_dict(obj, region=bundle.request.REGION.id,
profile=amo_user,
request=bundle.request))
# Add extra data for reviewers. Used in reviewer tool search.
bundle = update_with_reviewer_data(bundle, using_es=True)
return bundle
开发者ID:smillaedler,项目名称:zamboni,代码行数:12,代码来源:api.py
示例20: test_content_ratings
def test_content_ratings(self):
rating = ratingsbodies.CLASSIND_18
self.app.content_ratings.create(
ratings_body=ratingsbodies.CLASSIND.id,
rating=rating.id)
self.app.save()
self.refresh('webapp')
res = es_app_to_dict(self.get_obj())
eq_(res['content_ratings'],
{'br': [{'body': 'CLASSIND',
'name': rating.name,
'description': unicode(rating.description)}]})
开发者ID:gonzalodelgado,项目名称:zamboni,代码行数:12,代码来源:test_utils_.py
注:本文中的mkt.webapps.utils.es_app_to_dict函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论