Example #1
0
 def test_is_premium_webapp_foreign(self):
     self.make_premium(self.webapp, price='0.99')
     self.context['request'].REGION = regions.SPAIN
     # The region is set to Spain, so the currency is set EUR
     # and the display is set to French.
     with self.activate('fr'):
         # TODO bug: 878215, find what the answer here is.
         with self.assertRaises(KeyError):
             market_tile(self.context, self.webapp)
Example #2
0
 def test_developers(self):
     AddonPremium.objects.create(price_id=1, addon_id=self.webapp.pk)
     AddonUser.objects.create(user=self.user, addon=self.webapp)
     self.webapp.update(premium_type=amo.ADDON_PREMIUM)
     doc = pq(market_tile(self.context, self.webapp))
     data = json.loads(doc('.mkt-tile').attr('data-product'))
     eq_(data['isPurchased'], True)
Example #3
0
 def test_category(self):
     c = Category.objects.create(name='test-cat', type=amo.ADDON_WEBAPP)
     AddonCategory.objects.create(addon=self.webapp, category=c)
     doc = pq(market_tile(self.context, self.webapp))
     data = json.loads(doc('.mkt-tile').attr('data-product'))
     eq_(data['categories'],
         [str(cat.id) for cat in self.webapp.categories.all()])
Example #4
0
 def test_needs_firefox_for_android(self):
     self.context["request"].META["HTTP_USER_AGENT"] = "Mozilla/5.0 (Linux; U; Android 2.3.3; en-au; GT-I9100 Build)"
     doc = pq(market_tile(self.context, self.webapp))
     cls = doc("button").attr("class")
     assert "disabled" in cls, "Could not find %r class" % cls
     assert "incompatible" in cls, "Could not find %r class" % cls
     eq_(doc(".bad-app").length, 0)
Example #5
0
 def test_developers(self):
     AddonPremium.objects.create(price_id=1, addon_id=self.webapp.pk)
     AddonUser.objects.create(user=self.user, addon=self.webapp)
     self.webapp.update(premium_type=amo.ADDON_PREMIUM)
     doc = pq(market_tile(self.context, self.webapp))
     data = json.loads(doc('.mkt-tile').attr('data-product'))
     eq_(data['isPurchased'], True)
Example #6
0
 def test_is_premium_webapp_foreign(self):
     self.make_premium(self.webapp)
     with self.activate("fr"):
         doc = pq(market_tile(self.context, self.webapp))
         data = json.loads(doc(".mkt-tile").attr("data-product"))
         eq_(data["price"], 1.0)
         eq_(data["priceLocale"], u"1,00 €")
Example #7
0
 def test_is_premium_android_disabled(self):
     self.make_premium(self.webapp)
     doc = pq(market_tile(self.context, self.webapp))
     cls = doc('button').attr('class')
     assert 'disabled' in cls, 'Unexpected: %r' % cls
     eq_(doc('.bad-app').text(),
         'This app is available for purchase on only Firefox OS.')
Example #8
0
 def test_reviewers(self, action_allowed):
     action_allowed.return_value = True
     doc = pq(market_tile(self.context, self.webapp))
     data = json.loads(doc('.mkt-tile').attr('data-product'))
     issue = urlparams(reverse('detail.record',
                               args=[self.webapp.app_slug]), src='foo')
     eq_(data['recordUrl'], issue)
Example #9
0
 def test_is_premium_disabled(self):
     self.make_premium(self.webapp)
     self.create_switch(name="disabled-payments")
     doc = pq(market_tile(self.context, self.webapp))
     cls = doc("button").attr("class")
     assert "disabled" in cls, "Unexpected: %r" % cls
     eq_(doc(".bad-app").text(), "This app is temporarily unavailable for purchase.")
Example #10
0
 def test_is_premium_webapp_foreign(self):
     self.make_premium(self.webapp)
     with self.activate('fr'):
         doc = pq(market_tile(self.context, self.webapp))
         data = json.loads(doc('.mkt-tile').attr('data-product'))
         eq_(data['price'], 1.0)
         eq_(data['priceLocale'], u'1,00 €')
Example #11
0
 def test_is_premium_android_disabled(self):
     self.make_premium(self.webapp)
     doc = pq(market_tile(self.context, self.webapp))
     cls = doc('button').attr('class')
     assert 'disabled' in cls, 'Unexpected: %r' % cls
     eq_(doc('.bad-app').text(),
         'This app is available for purchase on only Firefox OS.')
Example #12
0
 def test_reviewers(self, action_allowed):
     action_allowed.return_value = True
     doc = pq(market_tile(self.context, self.webapp))
     data = json.loads(doc('.mkt-tile').attr('data-product'))
     issue = urlparams(reverse('detail.record',
                               args=[self.webapp.app_slug]), src='foo')
     eq_(data['recordUrl'], issue)
Example #13
0
 def test_is_premium_webapp_foreign(self):
     self.make_premium(self.webapp)
     with self.activate('fr'):
         doc = pq(market_tile(self.context, self.webapp))
         data = json.loads(doc('.mkt-tile').attr('data-product'))
         eq_(data['price'], 1.0)
         eq_(data['priceLocale'], u'1,00 €')
Example #14
0
 def test_reviewers(self, check_reviewer):
     check_reviewer.return_value = True
     doc = pq(market_tile(self.context, self.webapp))
     data = json.loads(doc('.mkt-tile').attr('data-product'))
     issue = urlparams(reverse('receipt.issue',
                               args=[self.webapp.app_slug]), src='foo')
     eq_(data['recordUrl'], issue)
Example #15
0
 def test_category(self):
     c = Category.objects.create(name='test-cat', type=amo.ADDON_WEBAPP)
     AddonCategory.objects.create(addon=self.webapp, category=c)
     doc = pq(market_tile(self.context, self.webapp))
     data = json.loads(doc('.mkt-tile').attr('data-product'))
     eq_(data['categories'],
         [str(cat.name) for cat in self.webapp.categories.all()])
Example #16
0
 def test_reviewers(self, check_reviewer):
     check_reviewer.return_value = True
     doc = pq(market_tile(self.context, self.webapp))
     data = json.loads(doc('.mkt-tile').attr('data-product'))
     issue = urlparams(reverse('receipt.issue',
                               args=[self.webapp.app_slug]), src='foo')
     eq_(data['recordUrl'], issue)
Example #17
0
 def test_needs_firefox_for_android_upgrade(self):
     # Only Firefox for Android 17.0+ has support for `navigator.mozApps`.
     self.context["request"].META["HTTP_USER_AGENT"] = "Mozilla/5.0 (Mobile; rv:16.0) Gecko/16.0 Firefox/16.0"
     doc = pq(market_tile(self.context, self.webapp))
     cls = doc("button").attr("class")
     assert "disabled" in cls, "Could not find %r class" % cls
     assert "incompatible" in cls, "Could not find %r class" % cls
     eq_(doc(".bad-app").length, 0)
Example #18
0
 def test_needs_firefox_for_android(self):
     self.context['request'].META['HTTP_USER_AGENT'] = (
         'Mozilla/5.0 (Linux; U; Android 2.3.3; en-au; GT-I9100 Build)')
     doc = pq(market_tile(self.context, self.webapp))
     cls = doc('button').attr('class')
     assert 'disabled' in cls, 'Could not find %r class' % cls
     assert 'incompatible' in cls, 'Could not find %r class' % cls
     eq_(doc('.bad-app').length, 0)
Example #19
0
 def test_can_install_mobile(self):
     self.webapp._device_types = [amo.DEVICE_MOBILE]
     self.context['request'].MOBILE = True
     self.context['request'].TABLET = False
     doc = pq(market_tile(self.context, self.webapp))
     cls = doc('button').attr('class')
     assert 'disabled' not in cls, 'Unexpected: %r' % cls
     eq_(doc('.bad-app').length, 0)
Example #20
0
 def test_cannot_install_tablet_only(self):
     self.webapp._device_types = [amo.DEVICE_TABLET]
     self.context['request'].MOBILE = False
     self.context['request'].TABLET = False
     doc = pq(market_tile(self.context, self.webapp))
     cls = doc('button').attr('class')
     assert 'disabled' in cls, 'Expected: %r' % cls
     eq_(doc('.bad-app').length, 1)
Example #21
0
 def test_needs_firefox_for_android_upgrade(self):
     # Only Firefox for Android 17.0+ has support for `navigator.mozApps`.
     self.context['request'].META['HTTP_USER_AGENT'] = (
         'Mozilla/5.0 (Mobile; rv:16.0) Gecko/16.0 Firefox/16.0')
     doc = pq(market_tile(self.context, self.webapp))
     cls = doc('button').attr('class')
     assert 'disabled' in cls, 'Unexpected: %r' % cls
     eq_(doc('.bad-app').text(), 'To use this app, upgrade Firefox.')
Example #22
0
 def test_can_install_mobile(self):
     self.webapp._device_types = [amo.DEVICE_MOBILE]
     self.context["request"].MOBILE = True
     self.context["request"].TABLET = False
     doc = pq(market_tile(self.context, self.webapp))
     cls = doc("button").attr("class")
     assert "disabled" not in cls, "Unexpected: %r" % cls
     eq_(doc(".bad-app").length, 0)
Example #23
0
 def test_is_premium_webapp_foreign(self):
     self.make_premium(self.webapp, price='0.99')
     self.context['request'].REGION = regions.SPAIN
     # The region is set to Spain, so the currency is set EUR
     # and the display is set to French.
     with self.activate('fr'):
         doc = pq(market_tile(self.context, self.webapp))
         eq_(doc('.price').text(), '')
Example #24
0
 def test_can_install_mobile(self):
     self.webapp._device_types = [amo.DEVICE_MOBILE]
     self.context['request'].MOBILE = True
     self.context['request'].TABLET = False
     doc = pq(market_tile(self.context, self.webapp))
     cls = doc('button').attr('class')
     assert 'disabled' not in cls, 'Unexpected: %r' % cls
     eq_(doc('.bad-app').length, 0)
Example #25
0
 def test_cannot_install_tablet_only(self):
     self.webapp._device_types = [amo.DEVICE_TABLET]
     self.context["request"].MOBILE = False
     self.context["request"].TABLET = False
     doc = pq(market_tile(self.context, self.webapp))
     cls = doc("button").attr("class")
     assert "disabled" in cls, "Expected: %r" % cls
     eq_(doc(".bad-app").length, 1)
Example #26
0
 def test_cannot_install_tablet_only(self):
     self.webapp._device_types = [amo.DEVICE_TABLET]
     self.context['request'].MOBILE = False
     self.context['request'].TABLET = False
     doc = pq(market_tile(self.context, self.webapp))
     cls = doc('button').attr('class')
     assert 'disabled' in cls, 'Expected: %r' % cls
     eq_(doc('.bad-app').length, 1)
Example #27
0
 def test_is_premium_disabled(self):
     self.make_premium(self.webapp)
     self.create_switch(name='disabled-payments')
     doc = pq(market_tile(self.context, self.webapp))
     cls = doc('button').attr('class')
     assert 'disabled' in cls, 'Unexpected: %r' % cls
     eq_(doc('.bad-app').text(),
         'This app is temporarily unavailable for purchase.')
Example #28
0
 def test_needs_firefox_for_android(self):
     self.context['request'].META['HTTP_USER_AGENT'] = (
         'Mozilla/5.0 (Linux; U; Android 2.3.3; en-au; GT-I9100 Build)')
     doc = pq(market_tile(self.context, self.webapp))
     cls = doc('button').attr('class')
     assert 'disabled' in cls, 'Unexpected: %r' % cls
     eq_(doc('.bad-app').text(),
         'To use this app, download and install Firefox for Android .')
Example #29
0
 def test_needs_firefox_for_android_upgrade(self):
     # Only Firefox for Android 17.0+ has support for `navigator.mozApps`.
     self.context['request'].META['HTTP_USER_AGENT'] = (
         'Mozilla/5.0 (Mobile; rv:16.0) Gecko/16.0 Firefox/16.0')
     doc = pq(market_tile(self.context, self.webapp))
     cls = doc('button').attr('class')
     assert 'disabled' in cls, 'Unexpected: %r' % cls
     eq_(doc('.bad-app').text(), 'To use this app, upgrade Firefox.')
Example #30
0
 def test_is_premium_disabled(self):
     self.make_premium(self.webapp)
     self.create_switch(name='disabled-payments')
     doc = pq(market_tile(self.context, self.webapp))
     cls = doc('button').attr('class')
     assert 'disabled' in cls, 'Unexpected: %r' % cls
     eq_(doc('.bad-app').text(),
         'This app is temporarily unavailable for purchase.')
Example #31
0
 def test_needs_firefox_for_android(self):
     self.context['request'].META['HTTP_USER_AGENT'] = (
         'Mozilla/5.0 (Linux; U; Android 2.3.3; en-au; GT-I9100 Build)')
     doc = pq(market_tile(self.context, self.webapp))
     cls = doc('button').attr('class')
     assert 'disabled' in cls, 'Could not find %r class' % cls
     assert 'incompatible' in cls, 'Could not find %r class' % cls
     eq_(doc('.bad-app').length, 0)
Example #32
0
    def test_is_not_packaged(self):
        manifest_url = self.webapp.manifest_url

        doc = pq(market_tile(self.context, self.webapp))
        assert 'data-manifest_url="%s"' % manifest_url in doc.html()

        data = json.loads(doc('a').attr('data-product'))
        eq_(data['is_packaged'], False)
        eq_(data['manifest_url'], manifest_url)
Example #33
0
 def test_some_supported_currencies(self, switch_is_active):
     switch_is_active.return_value = True
     self.make_premium(self.webapp, currencies=["CAD"])
     ad = AddonPremium.objects.get(addon=self.webapp)
     ad.update(currencies=["USD", "CAD"])
     doc = pq(market_tile(self.context, self.webapp))
     data = json.loads(doc(".mkt-tile").attr("data-product"))
     eq_(json.loads(data["currencies"])["USD"], "$1.00")
     eq_(json.loads(data["currencies"])["CAD"], "CA$1.00")
Example #34
0
    def test_is_not_packaged(self):
        manifest_url = self.webapp.manifest_url

        doc = pq(market_tile(self.context, self.webapp))
        assert 'data-manifest_url="%s"' % manifest_url in doc.html()

        data = json.loads(doc("a").attr("data-product"))
        eq_(data["is_packaged"], False)
        eq_(data["manifest_url"], manifest_url)
Example #35
0
    def test_is_premium_webapp_gaia(self):
        self.context["request"].GAIA = True
        self.make_premium(self.webapp)
        doc = pq(market_tile(self.context, self.webapp))
        eq_(doc(".price").text(), "$1.00")

        cls = doc("button").attr("class")
        assert "disabled" not in cls, "Unexpected: %r" % cls
        eq_(doc(".bad-app").length, 0)
Example #36
0
 def test_some_supported_currencies(self, switch_is_active):
     switch_is_active.return_value = True
     self.make_premium(self.webapp, currencies=['CAD'])
     ad = AddonPremium.objects.get(addon=self.webapp)
     ad.update(currencies=['USD', 'CAD'])
     doc = pq(market_tile(self.context, self.webapp))
     data = json.loads(doc('.mkt-tile').attr('data-product'))
     eq_(json.loads(data['currencies'])['USD'], '$1.00')
     eq_(json.loads(data['currencies'])['CAD'], 'CA$1.00')
Example #37
0
 def test_needs_firefox_for_android(self):
     self.context['request'].META['HTTP_USER_AGENT'] = (
         'Mozilla/5.0 (Linux; U; Android 2.3.3; en-au; GT-I9100 Build)')
     doc = pq(market_tile(self.context, self.webapp))
     cls = doc('button').attr('class')
     assert 'disabled' in cls, 'Unexpected: %r' % cls
     eq_(
         doc('.bad-app').text(),
         'To use this app, download and install Firefox for Android .')
Example #38
0
 def test_needs_firefox_for_android_upgrade(self):
     # Only Firefox for Android 17.0+ has support for `navigator.mozApps`.
     self.context['request'].META['HTTP_USER_AGENT'] = (
         'Mozilla/5.0 (Mobile; rv:16.0) Gecko/16.0 Firefox/16.0')
     doc = pq(market_tile(self.context, self.webapp))
     cls = doc('button').attr('class')
     assert 'disabled' in cls, 'Could not find %r class' % cls
     assert 'incompatible' in cls, 'Could not find %r class' % cls
     eq_(doc('.bad-app').length, 0)
Example #39
0
    def test_is_premium_webapp_gaia(self):
        self.context['request'].GAIA = True
        self.make_premium(self.webapp)
        doc = pq(market_tile(self.context, self.webapp))
        eq_(doc('.price').text(), '$1.00')

        cls = doc('button').attr('class')
        assert 'disabled' not in cls, 'Unexpected: %r' % cls
        eq_(doc('.bad-app').length, 0)
Example #40
0
 def test_some_supported_currencies(self, switch_is_active):
     switch_is_active.return_value = True
     self.make_premium(self.webapp, currencies=['CAD'])
     ad = AddonPremium.objects.get(addon=self.webapp)
     ad.update(currencies=['USD', 'CAD'])
     doc = pq(market_tile(self.context, self.webapp))
     data = json.loads(doc('.mkt-tile').attr('data-product'))
     eq_(json.loads(data['currencies'])['USD'], '$1.00')
     eq_(json.loads(data['currencies'])['CAD'], 'CA$1.00')
Example #41
0
 def test_needs_firefox_for_android_upgrade(self):
     # Only Firefox for Android 17.0+ has support for `navigator.mozApps`.
     self.context['request'].META['HTTP_USER_AGENT'] = (
         'Mozilla/5.0 (Mobile; rv:16.0) Gecko/16.0 Firefox/16.0')
     doc = pq(market_tile(self.context, self.webapp))
     cls = doc('button').attr('class')
     assert 'disabled' in cls, 'Could not find %r class' % cls
     assert 'incompatible' in cls, 'Could not find %r class' % cls
     eq_(doc('.bad-app').length, 0)
Example #42
0
    def test_is_not_packaged(self):
        manifest_url = self.webapp.manifest_url

        doc = pq(market_tile(self.context, self.webapp))
        assert 'data-manifest_url="%s"' % manifest_url in doc.html()

        data = json.loads(doc('a').attr('data-product'))
        eq_(data['is_packaged'], False)
        eq_(data['manifest_url'], manifest_url)
Example #43
0
    def test_is_premium_webapp_gaia(self):
        self.context['request'].GAIA = True
        self.make_premium(self.webapp)
        doc = pq(market_tile(self.context, self.webapp))
        eq_(doc('.price').text(), '$1.00')

        cls = doc('button').attr('class')
        assert 'disabled' not in cls, 'Unexpected: %r' % cls
        eq_(doc('.bad-app').length, 0)
Example #44
0
 def test_is_premium_webapp(self):
     self.make_premium(self.webapp)
     doc = pq(market_tile(self.context, self.webapp))
     data = json.loads(doc('.mkt-tile').attr('data-product'))
     eq_(data['manifestUrl'], self.webapp.manifest_url)
     eq_(data['price'], 1.0)
     eq_(data['priceLocale'], '$1.00')
     eq_(data['purchase'], self.webapp.get_purchase_url())
     eq_(data['isPurchased'], False)
Example #45
0
 def test_is_webapp(self):
     doc = pq(market_tile(self.context, self.webapp))
     data = json.loads(doc('.mkt-tile').attr('data-product'))
     eq_(data['manifestUrl'], self.webapp.manifest_url)
     eq_(data['recordUrl'], urlparams(self.webapp.get_detail_url('record'),
                                      src='foo'))
     eq_(data['preapprovalUrl'], reverse('detail.purchase.preapproval',
                                         args=[self.webapp.app_slug]))
     eq_(data['id'], str(self.webapp.pk))
     eq_(data['name'], self.webapp.name)
Example #46
0
 def test_is_premium_webapp_foreign(self):
     self.make_premium(self.webapp, price='0.99')
     self.context['request'].REGION = regions.SPAIN
     # The region is set to Spain, so the currency is set EUR
     # and the display is set to French.
     with self.activate('fr'):
         doc = pq(market_tile(self.context, self.webapp))
         data = json.loads(doc('.mkt-tile').attr('data-product'))
         eq_(data['price'], 5.01)
         eq_(data['priceLocale'], u'5,01\xa0\u20ac')
Example #47
0
 def test_is_premium_webapp_foreign(self):
     self.make_premium(self.webapp, price='0.99')
     self.context['request'].REGION = regions.SPAIN
     # The region is set to Spain, so the currency is set EUR
     # and the display is set to French.
     with self.activate('fr'):
         doc = pq(market_tile(self.context, self.webapp))
         data = json.loads(doc('.mkt-tile').attr('data-product'))
         eq_(data['price'], 5.01)
         eq_(data['priceLocale'], u'5,01\xa0\u20ac')
Example #48
0
    def test_is_premium_webapp(self):
        self.make_premium(self.webapp)
        doc = pq(market_tile(self.context, self.webapp))
        eq_(doc('.price').text(), '$1.00')

        data = json.loads(doc('.mkt-tile').attr('data-product'))
        eq_(data['manifest_url'], self.webapp.manifest_url)
        eq_(data['price'], 1.0)
        eq_(data['priceLocale'], '$1.00')
        eq_(data['purchase'], self.webapp.get_purchase_url())
        eq_(data['isPurchased'], False)
Example #49
0
 def test_is_desktop_enabled(self):
     self.webapp._device_types = [amo.DEVICE_DESKTOP]
     self.context['request'].MOBILE = False
     self.context['request'].META['HTTP_USER_AGENT'] = (
         'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:18.0) Gecko/18.0 '
         'Firefox/18.0')
     doc = pq(market_tile(self.context, self.webapp))
     cls = doc('button').attr('class')
     assert 'disabled' not in cls, 'Found %r class' % cls
     assert 'incompatible' not in cls, 'Found %r class' % cls
     eq_(doc('.bad-app').length, 0)
Example #50
0
    def test_is_webapp(self):
        doc = pq(market_tile(self.context, self.webapp))
        eq_(doc('.price').text(), 'Free')

        data = json.loads(doc('.mkt-tile').attr('data-product'))
        eq_(data['manifest_url'], self.webapp.manifest_url)
        eq_(data['recordUrl'], urlparams(self.webapp.get_detail_url('record'),
                                         src='foo'))
        eq_(data['id'], str(self.webapp.pk))
        eq_(data['name'], str(self.webapp.name))
        eq_(data['src'], 'foo')
Example #51
0
    def test_packaged_no_valid_status(self):
        self.webapp.update(is_packaged=True)
        version = self.webapp.versions.latest()
        version.all_files[0].update(status=amo.STATUS_REJECTED)
        self.webapp.update_version()  # Reset cached `_current_version`.

        doc = pq(market_tile(self.context, self.webapp))
        data = json.loads(doc('a').attr('data-product'))
        eq_(data['is_packaged'], True)
        eq_(data['manifest_url'], '')
        # The install button should not be shown if no current_version.
        eq_(doc('.product button').length, 0)
Example #52
0
 def test_is_desktop_disabled(self):
     raise SkipTest('we shall disable these later')
     self.context['request'].MOBILE = False
     self.context['request'].META['HTTP_USER_AGENT'] = (
         'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:18.0) Gecko/18.0 '
         'Firefox/18.0')
     doc = pq(market_tile(self.context, self.webapp))
     cls = doc('button').attr('class')
     assert 'disabled' in cls, 'Unexpected: %r' % cls
     eq_(
         doc('.bad-app').text(),
         'This app is available on only Firefox for Android and Firefox '
         'OS.')
Example #53
0
    def test_is_packaged(self):

        self.webapp.is_packaged = True

        manifest_url = self.webapp.get_manifest_url()
        doc = pq(market_tile(self.context, self.webapp))
        # NOTE: PyQuery won't parse attributes with underscores
        # or uppercase letters.
        assert 'data-manifest_url="%s"' % manifest_url in doc.html()

        data = json.loads(doc('a').attr('data-product'))
        eq_(data['is_packaged'], True)
        eq_(data['manifest_url'], manifest_url)
Example #54
0
    def test_is_webapp(self):
        doc = pq(market_tile(self.context, self.webapp))
        eq_(doc('.price').text(), 'Free')

        data = json.loads(doc('.mkt-tile').attr('data-product'))
        eq_(data['manifestUrl'], self.webapp.manifest_url)
        eq_(data['recordUrl'],
            urlparams(self.webapp.get_detail_url('record'), src='foo'))
        eq_(
            data['preapprovalUrl'],
            reverse('detail.purchase.preapproval',
                    args=[self.webapp.app_slug]))
        eq_(data['id'], str(self.webapp.pk))
        eq_(data['name'], self.webapp.name)
Example #55
0
    def test_is_premium_webapp(self):
        self.make_premium(self.webapp)
        doc = pq(market_tile(self.context, self.webapp))
        eq_(doc('.price').text(), '$1.00')

        data = json.loads(doc('.mkt-tile').attr('data-product'))
        eq_(data['manifest_url'], self.webapp.manifest_url)
        eq_(data['price'], 1.0)
        eq_(data['priceLocale'], '$1.00')
        eq_(data['isPurchased'], False)

        cls = doc('button').attr('class')
        assert 'disabled' in cls, 'Unexpected: %r' % cls
        eq_(doc('.bad-app').text(),
            'This app is available for purchase on only Firefox OS.')
Example #56
0
    def test_xss(self):
        nasty = '<script>'
        escaped = '&lt;script&gt;'
        author = self.webapp.authors.all()[0]
        author.display_name = nasty
        author.save()

        self.webapp.name = nasty
        self.webapp.save()
        Webapp.transformer([self.webapp])  # Transform `listed_authors`, etc.

        doc = pq(market_tile(self.context, self.webapp))
        data = json.loads(doc('.mkt-tile').attr('data-product'))
        eq_(data['name'], escaped)
        eq_(data['author'], escaped)
Example #57
0
 def test_is_premium_purchased(self):
     AddonPurchase.objects.create(user=self.user, addon=self.webapp)
     self.make_premium(self.webapp)
     doc = pq(market_tile(self.context, self.webapp))
     data = json.loads(doc('.mkt-tile').attr('data-product'))
     eq_(data['isPurchased'], True)
Example #58
0
 def test_is_premium_disabled(self):
     self.make_premium(self.webapp)
     self.create_switch(name='disabled-payments')
     doc = pq(market_tile(self.context, self.webapp))
     cls = doc('button').attr('class')
     assert 'disable' in cls, 'Unexpected: %r' % cls
Example #59
0
 def test_install_src(self):
     # request.GET['src'] is 'foo', and we're overriding it.
     doc = pq(market_tile(self.context, self.webapp, src='xxx'))
     data = json.loads(doc('.mkt-tile').attr('data-product'))
     eq_(data['src'], 'xxx')
Example #60
0
 def test_default_supported_currencies(self):
     self.make_premium(self.webapp)
     doc = pq(market_tile(self.context, self.webapp))
     data = json.loads(doc('.mkt-tile').attr('data-product'))
     assert 'currencies' not in data