本文整理汇总了Python中mkt.webapps.utils.app_to_dict函数的典型用法代码示例。如果您正苦于以下问题:Python app_to_dict函数的具体用法?Python app_to_dict怎么用?Python app_to_dict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了app_to_dict函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_can_purchase
def test_can_purchase(self):
self.make_premium(self.app, price='0.99')
res = app_to_dict(self.app, region=regions.UK.id)
res = app_to_dict(self.app, region=regions.UK.id)
eq_(res['price'], None)
eq_(res['price_locale'], None)
eq_(res['payment_required'], True)
示例2: test_can_purchase
def test_can_purchase(self):
self.make_premium(self.app, price='0.99')
with self.settings(PURCHASE_ENABLED_REGIONS=[regions.UK.id]):
res = app_to_dict(self.app, region=regions.UK.id)
res = app_to_dict(self.app, region=regions.UK.id)
eq_(res['price'], None)
eq_(res['price_locale'], None)
eq_(res['payment_required'], True)
示例3: test_versions_multiple
def test_versions_multiple(self):
ver = Version.objects.create(addon=self.app, version='1.9')
self.app.update(_current_version=ver, _latest_version=ver)
res = app_to_dict(self.app)
eq_(res['current_version'], ver.version)
self.assertSetEqual([v.version for v in self.app.versions.all()],
res['versions'].keys())
示例4: test_categories
def test_categories(self):
cat1 = Category.objects.create(type=amo.ADDON_WEBAPP, slug='cat1')
cat2 = Category.objects.create(type=amo.ADDON_WEBAPP, slug='cat2')
AddonCategory.objects.create(addon=self.app, category=cat1)
AddonCategory.objects.create(addon=self.app, category=cat2)
res = app_to_dict(self.app)
self.assertSetEqual(res['categories'], ['cat1', 'cat2'])
示例5: test_cannot_purchase
def test_cannot_purchase(self):
self.make_premium(self.app, price="0.99")
with self.settings(PURCHASE_ENABLED_REGIONS=[]):
res = app_to_dict(self.app, region=regions.UK.id)
eq_(res["price"], None)
eq_(res["price_locale"], None)
eq_(res["payment_required"], True)
示例6: test_with_preview
def test_with_preview(self):
obj = Preview.objects.create(
**{"caption": "foo", "filetype": "image/png", "thumbtype": "image/png", "addon": self.app}
)
preview = app_to_dict(self.app)["previews"][0]
self.assertSetEqual(preview, ["caption", "filetype", "id", "image_url", "thumbnail_url", "resource_uri"])
eq_(preview["caption"], "foo")
eq_(int(preview["id"]), obj.pk)
示例7: test_missing_price
def test_missing_price(self):
premium = self.make_premium(self.app, price='0.99')
premium.price = None
premium.save()
res = app_to_dict(self.app)
eq_(res['price'], None)
eq_(res['price_locale'], None)
示例8: test_with_locale
def test_with_locale(self):
premium = self.make_premium(self.app, price="0.99")
PriceCurrency.objects.create(region=regions.PL.id, currency="PLN", price="5.01", tier=premium.price, provider=1)
with self.activate(locale="fr"):
res = app_to_dict(self.app, region=regions.PL.id)
eq_(res["price"], Decimal("5.01"))
eq_(res["price_locale"], u"5,01\xa0PLN")
示例9: dehydrate
def dehydrate(self, bundle):
obj = bundle.obj
amo_user = getattr(bundle.request, "amo_user", None)
bundle.data.update(app_to_dict(obj, region=bundle.request.REGION.id, profile=amo_user, request=bundle.request))
bundle.data["privacy_policy"] = PrivacyPolicyResource().get_resource_uri(bundle)
self.dehydrate_extra(bundle)
return bundle
示例10: test_with_preview
def test_with_preview(self):
obj = Preview.objects.create(**{
'filetype': 'image/png', 'thumbtype': 'image/png',
'addon': self.app})
preview = app_to_dict(self.app)['previews'][0]
self.assertSetEqual(preview,
['filetype', 'id', 'image_url', 'thumbnail_url', 'resource_uri'])
eq_(int(preview['id']), obj.pk)
示例11: dehydrate
def dehydrate(self, bundle):
obj = bundle.obj
amo_user = getattr(bundle.request, 'amo_user', None)
bundle.data.update(app_to_dict(obj,
currency=bundle.request.REGION.default_currency, profile=amo_user))
bundle.data['privacy_policy'] = (
PrivacyPolicyResource().get_resource_uri(bundle))
return bundle
示例12: test_with_locale
def test_with_locale(self):
premium = self.make_premium(self.app, price='0.99')
PriceCurrency.objects.create(region=regions.PL.id, currency='PLN',
price='5.01', tier=premium.price,
provider=1)
with self.activate(locale='fr'):
res = app_to_dict(self.app, region=regions.PL.id)
eq_(res['price'], Decimal('5.01'))
eq_(res['price_locale'], u'5,01\xa0PLN')
示例13: dehydrate
def dehydrate(self, bundle):
obj = bundle.obj
user = getattr(bundle.request, 'user', None)
bundle.data.update(app_to_dict(obj,
currency=bundle.request.REGION.default_currency, user=user))
bundle.data['upsell'] = False
if obj.upsell:
upsell_bundle = Bundle(obj=obj.upsell.premium,
request=bundle.request)
bundle.data['upsell'] = self.full_dehydrate(upsell_bundle).data
return bundle
示例14: dehydrate
def dehydrate(self, bundle):
obj = bundle.obj
amo_user = getattr(bundle.request, 'amo_user', None)
bundle.data.update(app_to_dict(obj,
region=bundle.request.REGION.id, profile=amo_user))
bundle.data['privacy_policy'] = (
PrivacyPolicyResource().get_resource_uri(bundle))
# Add extra data for reviewers. Used in reviewer tool search.
bundle = update_with_reviewer_data(bundle)
return bundle
示例15: dehydrate
def dehydrate(self, bundle):
obj = bundle.obj
amo_user = getattr(bundle.request, 'amo_user', None)
region = (bundle.request.REGION.id if hasattr(bundle.request, 'REGION')
else None)
bundle.data.update(app_to_dict(obj, region=region, profile=amo_user,
request=bundle.request))
bundle.data['privacy_policy'] = (
PrivacyPolicyResource().get_resource_uri(bundle))
self.dehydrate_extra(bundle)
return bundle