fix tests, don't need receipts in a.m.o
This commit is contained in:
Родитель
dc041c8d32
Коммит
deb4e17798
|
@ -344,14 +344,3 @@ def theme_grid(context, themes, src=None, dl_src=None):
|
|||
@jinja2.contextfunction
|
||||
def addon_report_abuse(context, hide, addon):
|
||||
return new_context(**locals())
|
||||
|
||||
|
||||
@register.function
|
||||
def addon_receipt(request, addon):
|
||||
amo_user, user = request.amo_user, request.user
|
||||
if user.is_authenticated():
|
||||
if addon.has_installed(amo_user):
|
||||
if ((addon.is_premium() and addon.has_purchased(amo_user))
|
||||
or not addon.is_premium()):
|
||||
return addon.installed.get(user=amo_user).receipt
|
||||
return ''
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
{% endif %}
|
||||
{% trans manifest_url=addon.manifest_url if addon.is_webapp() else '',
|
||||
class='trigger_app_install' if addon.is_webapp() else 'trigger_download',
|
||||
receipt=addon_receipt(request, addon),
|
||||
receipt='receipt',
|
||||
href='#' if addon.is_webapp() else download %}
|
||||
<p>If installation does not automatically begin, please <a class="{{ class }}" data-manifest-url="{{ manifest_url }}" href="{{ href }}"
|
||||
data-receipt="{{ receipt }}">click here</a>.</p>
|
||||
|
|
|
@ -5,8 +5,7 @@ from pyquery import PyQuery
|
|||
import amo
|
||||
import amo.tests
|
||||
from addons.helpers import (statusflags, flag, contribution, performance_note,
|
||||
mobile_persona_preview, mobile_persona_confirm,
|
||||
addon_receipt)
|
||||
mobile_persona_preview, mobile_persona_confirm)
|
||||
from addons.models import Addon
|
||||
|
||||
|
||||
|
@ -142,32 +141,3 @@ class TestPerformanceNote(amo.tests.TestCase):
|
|||
self.ctx['request'].APP = amo.THUNDERBIRD
|
||||
r = performance_note(self.ctx, 30)
|
||||
eq_(r.strip(), '')
|
||||
|
||||
|
||||
class TestAddonReceipt(amo.tests.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.request = Mock()
|
||||
self.addon = Mock()
|
||||
self.request.user.is_authenticated.return_value = True
|
||||
|
||||
def test_not_auth(self):
|
||||
self.request.user.is_authenticated.return_value = False
|
||||
eq_(addon_receipt(self.request, self.addon), '')
|
||||
|
||||
def test_auth_premium_not_purchased(self):
|
||||
self.addon.is_premium.return_value = True
|
||||
self.addon.has_installed.return_value = True
|
||||
self.addon.has_purchased.return_value = False
|
||||
eq_(addon_receipt(self.request, self.addon), '')
|
||||
|
||||
def test_auth_not_premium(self):
|
||||
self.addon.is_premium.return_value = False
|
||||
self.addon.has_installed.return_value = True
|
||||
assert addon_receipt(self.request, self.addon)
|
||||
|
||||
def test_auth_premium_purchased(self):
|
||||
self.addon.is_premium.return_value = True
|
||||
self.addon.has_installed.return_value = True
|
||||
self.addon.has_purchased.return_value = True
|
||||
assert addon_receipt(self.request, self.addon)
|
||||
|
|
Загрузка…
Ссылка в новой задаче