本文整理汇总了Python中mkt.receipts.utils.create_receipt函数的典型用法代码示例。如果您正苦于以下问题:Python create_receipt函数的具体用法?Python create_receipt怎么用?Python create_receipt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_receipt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: for_user
def for_user(self, ins, flavour, encode):
encode.return_value = "tmp-to-keep-memoize-happy"
create_receipt(ins.pk, flavour=flavour)
receipt = encode.call_args[0][0]
eq_(receipt["product"]["type"], flavour)
eq_(receipt["verify"], absolutify(reverse("receipt.verify", args=[ins.addon.app_slug])))
return receipt
示例2: for_user
def for_user(self, ins, flavour, encode):
encode.return_value = 'tmp-to-keep-memoize-happy'
create_receipt(ins.pk, flavour=flavour)
receipt = encode.call_args[0][0]
eq_(receipt['product']['type'], flavour)
eq_(receipt['verify'],
absolutify(reverse('receipt.verify', args=[ins.addon.guid])))
return receipt
示例3: for_user
def for_user(self, app, user, flavour, encode):
encode.return_value = 'tmp-to-keep-memoize-happy'
create_receipt(app, user, 'some-uuid', flavour=flavour)
receipt = encode.call_args[0][0]
eq_(receipt['typ'], flavour + '-receipt')
eq_(receipt['verify'],
absolutify(reverse('receipt.verify', args=[app.guid])))
return receipt
示例4: for_user
def for_user(self, ins, flavour, encode):
encode.return_value = 'tmp-to-keep-memoize-happy'
create_receipt(ins.pk, flavour=flavour)
receipt = encode.call_args[0][0]
eq_(receipt['product']['type'], flavour)
eq_(receipt['verify'],
absolutify(reverse('receipt.verify', args=[self.webapp.app_slug])))
assert receipt['exp'] > (calendar.timegm(time.gmtime()) +
(60 * 60 * 24) - TEST_LEEWAY)
示例5: test_receipt_data
def test_receipt_data(self, encode):
encode.return_value = "tmp-to-keep-memoize-happy"
ins = self.create_install(self.user, self.webapp)
create_receipt(ins.pk)
receipt = encode.call_args[0][0]
eq_(receipt["product"]["url"], self.webapp.manifest_url[:-1])
eq_(receipt["product"]["storedata"], "id=%s" % int(ins.addon.pk))
assert receipt["exp"] > (calendar.timegm(time.gmtime()) + settings.WEBAPPS_RECEIPT_EXPIRY_SECONDS - TEST_LEEWAY)
eq_(receipt["reissue"], self.webapp.get_purchase_url("reissue"))
示例6: test_receipt_data
def test_receipt_data(self, encode):
encode.return_value = 'tmp-to-keep-memoize-happy'
create_receipt(self.app, self.user, 'some-uuid')
receipt = encode.call_args[0][0]
eq_(receipt['product']['url'], self.app.manifest_url[:-1])
eq_(receipt['product']['storedata'], 'id=%s' % int(self.app.pk))
assert receipt['exp'] > (calendar.timegm(time.gmtime()) +
settings.WEBAPPS_RECEIPT_EXPIRY_SECONDS -
TEST_LEEWAY)
eq_(receipt['reissue'], absolutify(reverse('receipt.reissue')))
示例7: test_receipt_data
def test_receipt_data(self, encode):
encode.return_value = 'tmp-to-keep-memoize-happy'
ins = self.create_install(self.user, self.webapp)
create_receipt(ins.pk)
receipt = encode.call_args[0][0]
eq_(receipt['product']['url'], self.webapp.manifest_url[:-1])
eq_(receipt['product']['storedata'], 'id=%s' % int(ins.addon.pk))
assert receipt['exp'] > (calendar.timegm(time.gmtime()) +
settings.WEBAPPS_RECEIPT_EXPIRY_SECONDS -
TEST_LEEWAY)
eq_(receipt['reissue'], self.webapp.get_purchase_url('reissue'))
示例8: test_crack_receipt
def test_crack_receipt(self):
# Check that we can decode our receipt and get a dictionary back.
self.addon.update(type=amo.ADDON_WEBAPP, manifest_url='http://a.com')
purchase = self.make_purchase()
receipt = create_receipt(purchase.addon, purchase.user, purchase.uuid)
result = verify.decode_receipt(receipt)
eq_(result['typ'], u'purchase-receipt')
示例9: test_crack_receipt_new_called
def test_crack_receipt_new_called(self, trunion_verify, settings):
# Check that we can decode our receipt and get a dictionary back.
self.app.update(type=amo.ADDON_WEBAPP, manifest_url='http://a.com')
verify.decode_receipt(
'jwt_public_key~' + create_receipt(
self.app, self.user, str(uuid.uuid4())))
assert trunion_verify.called
示例10: test_crack_receipt
def test_crack_receipt(self):
# Check that we can decode our receipt and get a dictionary back.
self.app.update(manifest_url="http://a.com")
purchase = self.make_purchase()
receipt = create_receipt(purchase.webapp, purchase.user, purchase.uuid)
result = verify.decode_receipt(receipt)
eq_(result["typ"], u"purchase-receipt")
示例11: test_expired
def test_expired(self):
receipt = create_receipt(self.addon, self.user, 'some-uuid')
self.verify.return_value = {'status': 'expired'}
res = self.client.post(self.url, data=receipt,
content_type='text/plain')
eq_(res.status_code, 200)
data = json.loads(res.content)
ok_(data['receipt'])
eq_(data['status'], 'expired')
示例12: _record
def _record(request, addon):
logged = request.user.is_authenticated()
premium = addon.is_premium()
# Require login for premium.
if not logged and premium:
return http.HttpResponseRedirect(reverse('users.login'))
ctx = {'addon': addon.pk}
# Don't generate receipts if we're allowing logged-out install.
if logged:
is_dev = request.check_ownership(addon, require_owner=False,
ignore_disabled=True, admin=False)
is_reviewer = acl.check_reviewer(request)
if (not addon.is_webapp() or not addon.is_public() and
not (is_reviewer or is_dev)):
raise http.Http404
if (premium and
not addon.has_purchased(request.amo_user) and
not is_reviewer and not is_dev):
raise PermissionDenied
# If you are reviewer, you get a user receipt. Use the reviewer tools
# to get a reviewer receipt. App developers still get their special
# receipt.
install_type = (apps.INSTALL_TYPE_DEVELOPER if is_dev
else apps.INSTALL_TYPE_USER)
# Log the install.
installed, c = Installed.objects.get_or_create(addon=addon,
user=request.amo_user, install_type=install_type)
# Get a suitable uuid for this receipt.
uuid = get_uuid(addon, request.amo_user)
error = ''
receipt_cef.log(request, addon, 'sign', 'Receipt requested')
try:
receipt = create_receipt(addon, request.amo_user, uuid)
except SigningError:
error = _('There was a problem installing the app.')
ctx.update(receipt=receipt, error=error)
else:
if not addon.is_public() or not addon.is_webapp():
raise http.Http404
amo.log(amo.LOG.INSTALL_ADDON, addon)
record_action('install', request, {
'app-domain': addon.domain_from_url(addon.origin, allow_none=True),
'app-id': addon.pk,
'anonymous': request.user.is_anonymous(),
})
return ctx
示例13: install_record
def install_record(obj, request, install_type):
# Generate or re-use an existing install record.
installed, created = Installed.objects.get_or_create(addon=obj, user=request.user, install_type=install_type)
log.info("Installed record %s: %s" % ("created" if created else "re-used", obj.pk))
log.info("Creating receipt: %s" % obj.pk)
receipt_cef.log(request._request, obj, "sign", "Receipt signing")
uuid = get_uuid(installed.addon, installed.user)
return create_receipt(installed.addon, installed.user, uuid)
示例14: record
def record(self, bundle, request, install_type):
# Generate or re-use an existing install record.
installed, created = Installed.objects.get_or_create(
addon=bundle.obj, user=request.user.get_profile(), install_type=install_type
)
log.info("Installed record %s: %s" % ("created" if created else "re-used", bundle.obj.pk))
log.info("Creating receipt: %s" % bundle.obj.pk)
receipt_cef.log(request, bundle.obj, "sign", "Receipt signing")
return create_receipt(installed)
示例15: record
def record(self, bundle, request, install_type):
# Generate or re-use an existing install record.
installed, created = Installed.objects.get_or_create(
addon=bundle.obj, user=request.user.get_profile(),
install_type=install_type)
log.info('Installed record %s: %s' % (
'created' if created else 're-used',
bundle.obj.pk))
log.info('Creating receipt: %s' % bundle.obj.pk)
receipt_cef.log(request, bundle.obj, 'sign', 'Receipt signing')
return create_receipt(installed)