Beispiel #1
0
 def setUp(self):
     self.login_as_editor()
     self.apps = [app_factory(name='XXX',
                              status=amo.WEBAPPS_UNREVIEWED_STATUS),
                  app_factory(name='YYY',
                              status=amo.WEBAPPS_UNREVIEWED_STATUS)]
     self.url = reverse('reviewers.apps.queue_pending')
Beispiel #2
0
 def test_own_apps(self):
     """Only user's transactions are shown."""
     app_factory()
     r = RequestFactory().get(self.url)
     r.user = self.user
     transactions = _get_transactions(r)[1]
     self.assertSetEqual([tx.addon for tx in transactions], self.apps)
Beispiel #3
0
    def test_installed_pagination(self):
        ins1 = Installed.objects.create(user=self.user, addon=app_factory())
        ins1.update(created=self.days_ago(1))
        ins2 = Installed.objects.create(user=self.user, addon=app_factory())
        ins2.update(created=self.days_ago(2))
        ins3 = Installed.objects.create(user=self.user, addon=app_factory())
        ins3.update(created=self.days_ago(3))
        res = self.client.get(self.list_url, {'limit': 2})
        eq_(res.status_code, 200)
        data = json.loads(res.content)

        eq_(len(data['objects']), 2)
        eq_(data['objects'][0]['id'], ins1.addon.id)
        eq_(data['objects'][1]['id'], ins2.addon.id)
        eq_(data['meta']['total_count'], 3)
        eq_(data['meta']['limit'], 2)
        eq_(data['meta']['previous'], None)
        eq_(data['meta']['offset'], 0)
        next = urlparse(data['meta']['next'])
        eq_(next.path, self.list_url)
        eq_(QueryDict(next.query).dict(), {u'limit': u'2', u'offset': u'2'})

        res = self.client.get(self.list_url, {'limit': 2, 'offset': 2})
        eq_(res.status_code, 200)
        data = json.loads(res.content)

        eq_(len(data['objects']), 1)
        eq_(data['objects'][0]['id'], ins3.addon.id)
        eq_(data['meta']['total_count'], 3)
        eq_(data['meta']['limit'], 2)
        prev = urlparse(data['meta']['previous'])
        eq_(next.path, self.list_url)
        eq_(QueryDict(prev.query).dict(), {u'limit': u'2', u'offset': u'0'})
        eq_(data['meta']['offset'], 2)
        eq_(data['meta']['next'], None)
Beispiel #4
0
    def test_installed_pagination(self):
        ins1 = Installed.objects.create(user=self.user, addon=app_factory())
        ins1.update(created=self.days_ago(1))
        ins2 = Installed.objects.create(user=self.user, addon=app_factory())
        ins2.update(created=self.days_ago(2))
        ins3 = Installed.objects.create(user=self.user, addon=app_factory())
        ins3.update(created=self.days_ago(3))
        res = self.client.get(self.list_url, {"limit": 2})
        eq_(res.status_code, 200)
        data = json.loads(res.content)

        eq_(len(data["objects"]), 2)
        eq_(data["objects"][0]["id"], ins1.addon.id)
        eq_(data["objects"][1]["id"], ins2.addon.id)
        eq_(data["meta"]["total_count"], 3)
        eq_(data["meta"]["limit"], 2)
        eq_(data["meta"]["previous"], None)
        eq_(data["meta"]["offset"], 0)
        next = urlparse(data["meta"]["next"])
        eq_(next.path, self.list_url)
        eq_(QueryDict(next.query).dict(), {u"limit": u"2", u"offset": u"2"})

        res = self.client.get(self.list_url, {"limit": 2, "offset": 2})
        eq_(res.status_code, 200)
        data = json.loads(res.content)

        eq_(len(data["objects"]), 1)
        eq_(data["objects"][0]["id"], ins3.addon.id)
        eq_(data["meta"]["total_count"], 3)
        eq_(data["meta"]["limit"], 2)
        prev = urlparse(data["meta"]["previous"])
        eq_(next.path, self.list_url)
        eq_(QueryDict(prev.query).dict(), {u"limit": u"2", u"offset": u"0"})
        eq_(data["meta"]["offset"], 2)
        eq_(data["meta"]["next"], None)
Beispiel #5
0
 def test_own_apps(self):
     """Only user's transactions are shown."""
     app_factory()
     r = RequestFactory().get(self.url)
     r.user = self.user
     transactions = _get_transactions(r)[1]
     self.assertSetEqual([tx.addon for tx in transactions], self.apps)
Beispiel #6
0
    def test_installed_pagination(self):
        ins1 = Installed.objects.create(user=self.user, addon=app_factory())
        ins1.update(created=self.days_ago(1))
        ins2 = Installed.objects.create(user=self.user, addon=app_factory())
        ins2.update(created=self.days_ago(2))
        ins3 = Installed.objects.create(user=self.user, addon=app_factory())
        ins3.update(created=self.days_ago(3))
        res = self.client.get(self.list_url, {'limit': 2})
        eq_(res.status_code, 200)
        data = json.loads(res.content)

        eq_(len(data['objects']), 2)
        eq_(data['objects'][0]['id'], ins1.addon.id)
        eq_(data['objects'][1]['id'], ins2.addon.id)
        eq_(data['meta']['total_count'], 3)
        eq_(data['meta']['limit'], 2)
        eq_(data['meta']['previous'], None)
        eq_(data['meta']['offset'], 0)
        next = urlparse(data['meta']['next'])
        eq_(next.path, self.list_url)
        eq_(QueryDict(next.query).dict(), {u'limit': u'2', u'offset': u'2'})

        res = self.client.get(self.list_url, {'limit': 2, 'offset': 2})
        eq_(res.status_code, 200)
        data = json.loads(res.content)

        eq_(len(data['objects']), 1)
        eq_(data['objects'][0]['id'], ins3.addon.id)
        eq_(data['meta']['total_count'], 3)
        eq_(data['meta']['limit'], 2)
        prev = urlparse(data['meta']['previous'])
        eq_(next.path, self.list_url)
        eq_(QueryDict(prev.query).dict(), {u'limit': u'2', u'offset': u'0'})
        eq_(data['meta']['offset'], 2)
        eq_(data['meta']['next'], None)
Beispiel #7
0
 def setUp(self):
     self.login_as_editor()
     self.apps = [
         app_factory(name="XXX", status=amo.WEBAPPS_UNREVIEWED_STATUS),
         app_factory(name="YYY", status=amo.WEBAPPS_UNREVIEWED_STATUS),
     ]
     self.url = reverse("reviewers.queue_apps")
Beispiel #8
0
 def test_package_helpers(self):
     app1 = app_factory()
     eq_(app1.is_packaged, False)
     eq_(app1.has_packaged_files, False)
     app2 = app_factory(file_kw=dict(is_packaged=True))
     eq_(app2.is_packaged, True)
     eq_(app2.has_packaged_files, True)
Beispiel #9
0
 def test_excluded_in(self):
     app1 = app_factory()
     app2 = app_factory()
     region = list(mkt.regions.ADULT_EXCLUDED)[0]
     AddonExcludedRegion.objects.create(addon=app1, region=region.id)
     Flag.objects.create(addon=app1, adult_content=True)
     Flag.objects.create(addon=app2, adult_content=True)
     eq_(Webapp.get_excluded_in(region), [app1.id, app2.id])
Beispiel #10
0
 def setUp(self):
     self.login_as_editor()
     super(TestReviewLog, self).setUp()
     self.apps = [
         app_factory(name='XXX', status=amo.WEBAPPS_UNREVIEWED_STATUS),
         app_factory(name='YYY', status=amo.WEBAPPS_UNREVIEWED_STATUS)
     ]
     self.url = reverse('reviewers.apps.logs')
Beispiel #11
0
 def setUp(self):
     self.login_as_editor()
     super(TestReviewLog, self).setUp()
     self.apps = [app_factory(name='XXX',
                              status=amo.WEBAPPS_UNREVIEWED_STATUS),
                  app_factory(name='YYY',
                              status=amo.WEBAPPS_UNREVIEWED_STATUS)]
     self.url = reverse('reviewers.apps.logs')
Beispiel #12
0
 def setUp(self):
     self.login_as_editor()
     super(TestReviewersHome, self).setUp()
     self.apps = [
         app_factory(name='Antelope', status=amo.WEBAPPS_UNREVIEWED_STATUS),
         app_factory(name='Bear', status=amo.WEBAPPS_UNREVIEWED_STATUS),
         app_factory(name='Cougar', status=amo.WEBAPPS_UNREVIEWED_STATUS)
     ]
     self.url = reverse('reviewers.home')
Beispiel #13
0
def test_ordering():
    """Given a specific set of primary keys, assure that we return addons
    in that order."""

    app1id = app_factory().id
    app2id = app_factory().id
    app3id = app_factory().id
    semi_arbitrary_order = [app2id, app3id, app1id]
    addons = manual_order(Webapp.objects.all(), semi_arbitrary_order)
    eq_(semi_arbitrary_order, [addon.id for addon in addons])
def test_ordering():
    """Given a specific set of primary keys, assure that we return addons
    in that order."""

    app1id = app_factory().id
    app2id = app_factory().id
    app3id = app_factory().id
    semi_arbitrary_order = [app2id, app3id, app1id]
    addons = manual_order(Webapp.objects.all(), semi_arbitrary_order)
    eq_(semi_arbitrary_order, [addon.id for addon in addons])
Beispiel #15
0
 def setUp(self):
     self.login_as_editor()
     super(TestReviewersHome, self).setUp()
     self.apps = [app_factory(name='Antelope',
                              status=amo.WEBAPPS_UNREVIEWED_STATUS),
                  app_factory(name='Bear',
                              status=amo.WEBAPPS_UNREVIEWED_STATUS),
                  app_factory(name='Cougar',
                              status=amo.WEBAPPS_UNREVIEWED_STATUS)]
     self.url = reverse('reviewers.home')
Beispiel #16
0
 def test_installed_order(self):
     # Should be reverse chronological order.
     ins1 = Installed.objects.create(user=self.user, addon=app_factory())
     ins1.update(created=self.days_ago(1))
     ins2 = Installed.objects.create(user=self.user, addon=app_factory())
     ins2.update(created=self.days_ago(2))
     res = self.client.get(self.list_url)
     eq_(res.status_code, 200)
     data = json.loads(res.content)
     eq_(len(data['objects']), 2)
     eq_(data['objects'][0]['id'], ins1.addon.id)
     eq_(data['objects'][1]['id'], ins2.addon.id)
    def test_all_results(self):
        for x in range(4):
            app_factory(name='chr' + str(x))
        self.refresh('webapp')

        # Test search limit.
        data = self.search(q='chr')
        eq_(len(data['results']), 2)

        # Test maximum search result.
        data = self.search(q='chr', all_results=True)
        eq_(len(data['results']), 3)
Beispiel #18
0
 def test_installed_order(self):
     # Should be reverse chronological order.
     ins1 = Installed.objects.create(user=self.user, addon=app_factory())
     ins1.update(created=self.days_ago(1))
     ins2 = Installed.objects.create(user=self.user, addon=app_factory())
     ins2.update(created=self.days_ago(2))
     res = self.client.get(self.list_url)
     eq_(res.status_code, 200)
     data = json.loads(res.content)
     eq_(len(data['objects']), 2)
     eq_(data['objects'][0]['id'], ins1.addon.id)
     eq_(data['objects'][1]['id'], ins2.addon.id)
Beispiel #19
0
    def test_all_results(self):
        for x in range(4):
            app_factory(name='chr' + str(x))
        self.refresh('webapp')

        # Test search limit.
        data = self.search(q='chr')
        eq_(len(data['results']), 2)

        # Test maximum search result.
        data = self.search(q='chr', all_results=True)
        eq_(len(data['results']), 3)
Beispiel #20
0
    def test_relevant_apps(self, purchase_ids):
        profile = UserProfile.objects.create(email='*****@*****.**')
        purchased_app = app_factory()
        purchase_ids.return_value = [purchased_app.pk]
        developed_app = app_factory()
        developed_app.addonuser_set.create(user=profile)
        installed_app = app_factory()
        installed_app.installed.create(user=profile)

        data = self._test_login()
        eq_(data['apps']['installed'], [installed_app.pk])
        eq_(data['apps']['purchased'], [purchased_app.pk])
        eq_(data['apps']['developed'], [developed_app.pk])
Beispiel #21
0
    def test_relevant_apps(self, purchase_ids):
        profile = UserProfile.objects.create(email='*****@*****.**')
        purchased_app = app_factory()
        purchase_ids.return_value = [purchased_app.pk]
        developed_app = app_factory()
        developed_app.addonuser_set.create(user=profile)
        installed_app = app_factory()
        installed_app.installed.create(user=profile)

        data = self._test_login()
        eq_(data['apps']['installed'], [installed_app.pk])
        eq_(data['apps']['purchased'], [purchased_app.pk])
        eq_(data['apps']['developed'], [developed_app.pk])
Beispiel #22
0
    def test_relevant_apps(self, purchase_ids):
        profile = UserProfile.objects.create(email="*****@*****.**")
        profile.create_django_user(backend="django_browserid.auth.BrowserIDBackend")
        purchased_app = app_factory()
        purchase_ids.return_value = [purchased_app.pk]
        developed_app = app_factory()
        developed_app.addonuser_set.create(user=profile)
        installed_app = app_factory()
        installed_app.installed.create(user=profile)

        data = self._test_login()
        eq_(data["apps"]["installed"], [installed_app.pk])
        eq_(data["apps"]["purchased"], [purchased_app.pk])
        eq_(data["apps"]["developed"], [developed_app.pk])
Beispiel #23
0
    def setup_paid(self, type_=None):
        type_ = amo.ADDON_PREMIUM if type_ is None else type_
        self.free = [Webapp.objects.get(id=337141), app_factory()]
        self.paid = []
        for x in xrange(1, 3):
            app = app_factory(weekly_downloads=x * 100)
            if type_ in amo.ADDON_PREMIUMS:
                price = Price.objects.create(price=x)
                AddonPremium.objects.create(price=price, addon=app)
                app.update(premium_type=type_)
                self.paid.append(app)
            elif type_ in amo.ADDON_FREES:
                self.free.append(app)

        # For measure add some disabled free apps ...
        app_factory(disabled_by_user=True)
        app_factory(status=amo.STATUS_NULL)

        # ... and some disabled paid apps.
        price = Price.objects.create(price='50.00')
        a = app_factory(disabled_by_user=True, premium_type=amo.ADDON_PREMIUM)
        AddonPremium.objects.create(price=price, addon=a)
        a = app_factory(status=amo.STATUS_NULL, premium_type=amo.ADDON_PREMIUM)
        AddonPremium.objects.create(price=price, addon=a)

        self.both = sorted(self.free + self.paid,
                           key=lambda x: x.weekly_downloads, reverse=True)
        self.free = sorted(self.free, key=lambda x: x.weekly_downloads,
                           reverse=True)
        self.paid = sorted(self.paid, key=lambda x: x.weekly_downloads,
                           reverse=True)
Beispiel #24
0
    def setUp(self):
        self.login_as_editor()
        super(TestReviewLog, self).setUp()
        self.apps = [app_factory(name='XXX',
                                 status=amo.WEBAPPS_UNREVIEWED_STATUS),
                     app_factory(name='YYY',
                                 status=amo.WEBAPPS_UNREVIEWED_STATUS)]
        self.url = reverse('reviewers.apps.logs')

        self.task_user = UserProfile.objects.get(email='*****@*****.**')
        patcher = mock.patch.object(settings, 'TASK_USER_ID',
                                    self.task_user.id)
        patcher.start()
        self.addCleanup(patcher.stop)
Beispiel #25
0
    def test_pagination(self):
        Webapp.objects.get(pk=337141).delete()
        app1 = app_factory(name='test app test1')
        app2 = app_factory(name='test app test2')
        app3 = app_factory(name='test app test3')
        # Setting 'created' app_factory is unreliable and we need a reliable
        # order.
        app1.update(created=self.days_ago(1))
        app2.update(created=self.days_ago(2))
        app3.update(created=self.days_ago(3))
        self.refresh('webapp')

        res = self.client.get(self.url, data={'limit': '2', 'sort': 'created'})
        eq_(res.status_code, 200)
        data = json.loads(res.content)
        eq_(len(data['objects']), 2)
        eq_(int(data['objects'][0]['id']), app1.id)
        eq_(int(data['objects'][1]['id']), app2.id)

        eq_(data['meta']['total_count'], 3)
        eq_(data['meta']['limit'], 2)
        eq_(data['meta']['previous'], None)
        eq_(data['meta']['offset'], 0)

        next = urlparse(data['meta']['next'])
        eq_(next.path, self.url)
        eq_(
            QueryDict(next.query).dict(), {
                'limit': '2',
                'offset': '2',
                'sort': 'created'
            })

        res = self.client.get(self.url, QueryDict(next.query).dict())
        eq_(res.status_code, 200)
        data = json.loads(res.content)
        eq_(len(data['objects']), 1)
        eq_(int(data['objects'][0]['id']), app3.id)
        eq_(data['meta']['total_count'], 3)
        eq_(data['meta']['limit'], 2)
        prev = urlparse(data['meta']['previous'])
        eq_(next.path, self.url)
        eq_(
            QueryDict(prev.query).dict(), {
                'limit': '2',
                'offset': '0',
                'sort': 'created'
            })
        eq_(data['meta']['offset'], 2)
        eq_(data['meta']['next'], None)
Beispiel #26
0
    def setup_paid(self, type_=None):
        type_ = amo.ADDON_PREMIUM if type_ is None else type_
        self.free = [Webapp.objects.get(id=337141), app_factory()]
        self.paid = []
        for x in xrange(1, 3):
            app = app_factory(weekly_downloads=x * 100)
            if type_ in amo.ADDON_PREMIUMS:
                price = Price.objects.create(price=x)
                AddonPremium.objects.create(price=price, addon=app)
                app.update(premium_type=type_)
                self.paid.append(app)
            elif type_ in amo.ADDON_FREES:
                self.free.append(app)

        # For measure add some disabled free apps ...
        app_factory(disabled_by_user=True)
        app_factory(status=amo.STATUS_NULL)

        # ... and some disabled paid apps.
        price = Price.objects.create(price='50.00')
        a = app_factory(disabled_by_user=True, premium_type=amo.ADDON_PREMIUM)
        AddonPremium.objects.create(price=price, addon=a)
        a = app_factory(status=amo.STATUS_NULL, premium_type=amo.ADDON_PREMIUM)
        AddonPremium.objects.create(price=price, addon=a)

        self.both = sorted(self.free + self.paid,
                           key=lambda x: x.weekly_downloads,
                           reverse=True)
        self.free = sorted(self.free,
                           key=lambda x: x.weekly_downloads,
                           reverse=True)
        self.paid = sorted(self.paid,
                           key=lambda x: x.weekly_downloads,
                           reverse=True)
Beispiel #27
0
 def setUp(self):
     (app_factory(), app_factory())
     # Need queryset to initialize form.
     self.apps = Webapp.objects.all()
     self.data = {
         'app': self.apps[0].id,
         'transaction_type': 1,
         'transaction_id': 1,
         'date_from_day': '1',
         'date_from_month': '1',
         'date_from_year': '2012',
         'date_to_day': '1',
         'date_to_month': '1',
         'date_to_year': '2013',
     }
Beispiel #28
0
 def setUp(self):
     (app_factory(), app_factory())
     # Need queryset to initialize form.
     self.apps = Webapp.objects.all()
     self.data = {
         'app': self.apps[0].id,
         'transaction_type': 1,
         'transaction_id': 1,
         'date_from_day': '1',
         'date_from_month': '1',
         'date_from_year': '2012',
         'date_to_day': '1',
         'date_to_month': '1',
         'date_to_year': '2013',
     }
Beispiel #29
0
 def setUp(self):
     (app_factory(), app_factory())
     # Need queryset to initialize form.
     self.apps = Webapp.objects.all()
     self.data = {
         "app": self.apps[0].id,
         "transaction_type": 1,
         "transaction_id": 1,
         "date_from_day": "1",
         "date_from_month": "1",
         "date_from_year": "2012",
         "date_to_day": "1",
         "date_to_month": "1",
         "date_to_year": "2013",
     }
Beispiel #30
0
 def setUp(self):
     self.request = mock.Mock()
     self.app = app_factory(
         make_public=amo.PUBLIC_IMMEDIATELY, version_kw={"version": "1.0", "created": self.days_ago(5)}
     )
     version_factory(addon=self.app, version="2.0", file_kw=dict(status=amo.STATUS_PENDING))
     self.app.reload()
Beispiel #31
0
 def test_product_create_exists(self):
     self.ref_patcher.products.get.return_value = [{'resource_uri': '/f'}]
     account = self.make_account()
     app = app_factory()
     self.ref.product_create(account, app)
     # Product should have been got from zippy, but not created by a post.
     assert self.ref_patcher.products.get.called
Beispiel #32
0
    def setUp(self):
        self.app = app_factory(name='XXX')
        eq_(EscalationQueue.objects.filter(addon=self.app).count(), 0)

        patcher = mock.patch.object(settings, 'TASK_USER_ID', 4043307)
        patcher.start()
        self.addCleanup(patcher.stop)
Beispiel #33
0
 def make_time_limited_feature(self):
     a = app_factory()
     fa = self.make_featured(app=a, category=None)
     fa.start_date = datetime.date(2012, 1, 1)
     fa.end_date = datetime.date(2012, 2, 1)
     fa.save()
     return a
Beispiel #34
0
 def test_only_put_by_owner(self, client):
     app2 = app_factory(premium_type=amo.ADDON_FREE_INAPP)
     AddonUser.objects.create(addon=app2, user=self.other)
     acct = setup_payment_account(app2, self.other).payment_account
     r = self.client.put(get_url('account', acct.pk),
                         data=json.dumps(package_data))
     eq_(r.status_code, 404)
Beispiel #35
0
 def setUp(self):
     super(TestAcctSummary, self).setUp()
     self.user = UserProfile.objects.get(pk=31337)  # steamcube
     self.steamcube = Addon.objects.get(pk=337141)
     self.otherapp = app_factory(app_slug='otherapp')
     self.reg_user = UserProfile.objects.get(email='*****@*****.**')
     self.summary_url = reverse('acct_lookup.summary', args=[self.user.pk])
Beispiel #36
0
    def test_create_blocklisted_version(self):
        app = app_factory(name='Mozillaball ょ', app_slug='test',
                          is_packaged=True, version_kw={'version': '1.0',
                                                        'created': None})
        app.create_blocklisted_version()
        app = app.reload()
        v = app.versions.latest()
        f = v.files.latest()

        eq_(app.status, amo.STATUS_BLOCKED)
        eq_(app.versions.count(), 2)
        eq_(v.version, 'blocklisted-1.0')

        eq_(app._current_version, v)
        assert 'blocklisted-1.0' in f.filename
        eq_(f.status, amo.STATUS_BLOCKED)

        # Check manifest.
        url = app.get_manifest_url()
        res = self.client.get(url)
        eq_(res['Content-type'], 'application/x-web-app-manifest+json')
        assert 'etag' in res._headers
        data = json.loads(res.content)
        eq_(data['name'], 'Blocked by Mozilla')
        eq_(data['version'], 'blocklisted-1.0')
        eq_(data['package_path'], 'http://hy.fr/downloads/file/%s/%s' % (
            f.id, f.filename))
Beispiel #37
0
 def make_time_limited_feature(self, start, end):
     a = app_factory()
     fa = self.make_featured(app=a, category=None)
     fa.start_date = start
     fa.end_date = end
     fa.save()
     return a
 def setUp(self):
     self.app = app_factory()
     self.app_url = get_url('app', self.app.pk)
     self.version = self.app.current_version
     self.file = self.version.all_files[0]
     self.request = RequestFactory()
     super(TestVersionStatusViewSet, self).setUp()
Beispiel #39
0
    def test_create_new_product(self):
        account = self.make_account()
        app = app_factory()

        generic_product_uri = '/generic/product/1/'
        boku_product_uri = '/boku/product/1/'
        self.generic_patcher.product.get_object_or_404.return_value = {
            'resource_pk': 1,
            'resource_uri': generic_product_uri,
        }

        self.boku_patcher.product.get.return_value = {
            'meta': {
                'total_count': 0
            },
            'objects': [],
        }
        self.boku_patcher.product.post.return_value = {
            'resource_uri': boku_product_uri,
            'seller_product': generic_product_uri,
            'seller_boku': account.uri,
        }

        product = self.boku.product_create(account, app)
        eq_(product, boku_product_uri)
        self.boku_patcher.product.post.assert_called_with(
            data={
                'seller_boku': account.uri,
                'seller_product': generic_product_uri,
            })
Beispiel #40
0
    def test_suggestions(self):
        app1 = Webapp.objects.get(pk=337141)
        app1.save()
        app2 = app_factory(name=u"Second âpp",
                           description=u"Second dèsc" * 25,
                           created=self.days_ago(3))
        self.refresh('webapp')

        response = self.client.get(self.url)
        parsed = json.loads(response.content)
        eq_(parsed[0], '')
        self.assertSetEqual(
            parsed[1],
            [unicode(app1.name), unicode(app2.name)])
        self.assertSetEqual(
            parsed[2],
            [unicode(app1.description),
             unicode(truncate(app2.description))])
        self.assertSetEqual(parsed[3], [
            absolutify(app1.get_detail_url()),
            absolutify(app2.get_detail_url())
        ])
        self.assertSetEqual(parsed[4],
                            [app1.get_icon_url(64),
                             app2.get_icon_url(64)])

        # Cleanup to remove these from the index.
        unindex_webapps([app1.id, app2.id])
        app1.delete()
        app2.delete()
Beispiel #41
0
    def setUp(self):
        self.app = app_factory(name='XXX')
        eq_(EscalationQueue.objects.filter(addon=self.app).count(), 0)

        patcher = mock.patch.object(settings, 'TASK_USER_ID', 4043307)
        patcher.start()
        self.addCleanup(patcher.stop)
Beispiel #42
0
 def make_time_limited_feature(self):
     a = app_factory()
     fa = self.make_featured(app=a, category=None)
     fa.start_date = datetime.date(2012, 1, 1)
     fa.end_date = datetime.date(2012, 2, 1)
     fa.save()
     return a
    def test_update_existing_product(self):
        account = self.make_account()
        app = app_factory()

        generic_product_uri = '/generic/product/1/'
        self.generic_patcher.product.get_object_or_404.return_value = {
            'resource_pk': 1,
            'resource_uri': generic_product_uri,
        }

        existing_boku_product_uri = '/boku/product/1/'
        self.boku_patcher.product.get.return_value = {
            'meta': {'total_count': 1},
            'objects': [{
                'resource_uri': existing_boku_product_uri,
            }],
        }
        patch_mock = Mock()
        patch_mock.patch.return_value = {
            'resource_uri': existing_boku_product_uri,
            'seller_product': generic_product_uri,
            'seller_boku': account.uri,
        }
        self.boku_patcher.by_url.return_value = patch_mock

        product = self.boku.product_create(account, app)
        eq_(product, existing_boku_product_uri)
        self.boku_patcher.by_url.assert_called_with(existing_boku_product_uri)
        patch_mock.patch.assert_called_with(data={
            'seller_boku': account.uri,
            'seller_product': generic_product_uri,
        })
Beispiel #44
0
 def make_time_limited_feature(self, start, end):
     a = app_factory()
     fa = self.make_featured(app=a, category=None)
     fa.start_date = start
     fa.end_date = end
     fa.save()
     return a
Beispiel #45
0
    def test_create_blocklisted_version(self):
        app = app_factory(
            name="Mozillaball ょ", app_slug="test", is_packaged=True, version_kw={"version": "1.0", "created": None}
        )
        app.create_blocklisted_version()
        app = app.reload()
        v = app.versions.latest()
        f = v.files.latest()

        eq_(app.status, amo.STATUS_BLOCKED)
        eq_(app.versions.count(), 2)
        eq_(v.version, "blocklisted-1.0")

        eq_(app._current_version, v)
        assert "blocklisted-1.0" in f.filename
        eq_(f.status, amo.STATUS_BLOCKED)

        # Check manifest.
        url = app.get_manifest_url()
        res = self.client.get(url)
        eq_(res["Content-type"], "application/x-web-app-manifest+json; charset=utf-8")
        assert "etag" in res._headers
        data = json.loads(res.content)
        eq_(data["name"], "Blocked by Mozilla")
        eq_(data["version"], "blocklisted-1.0")
        eq_(data["package_path"], "http://hy.fr/downloads/file/%s/%s" % (f.id, f.filename))
Beispiel #46
0
    def test_create_blocklisted_version(self):
        app = app_factory(name='Mozillaball ょ',
                          app_slug='test',
                          is_packaged=True,
                          version_kw={
                              'version': '1.0',
                              'created': None
                          })
        app.create_blocklisted_version()
        app = app.reload()
        v = app.versions.latest()
        f = v.files.latest()

        eq_(app.status, amo.STATUS_BLOCKED)
        eq_(app.versions.count(), 2)
        eq_(v.version, 'blocklisted-1.0')

        eq_(app._current_version, v)
        assert 'blocklisted-1.0' in f.filename
        eq_(f.status, amo.STATUS_BLOCKED)

        # Check manifest.
        url = app.get_manifest_url()
        res = self.client.get(url)
        eq_(res['Content-type'],
            'application/x-web-app-manifest+json; charset=utf-8')
        assert 'etag' in res._headers
        data = json.loads(res.content)
        eq_(data['name'], 'Blocked by Mozilla')
        eq_(data['version'], 'blocklisted-1.0')
        eq_(data['package_path'],
            'http://hy.fr/downloads/file/%s/%s' % (f.id, f.filename))
Beispiel #47
0
    def setUp(self):
        self.uuid = 'paymentuuid'
        self.refund_uuid = 'refunduuid'
        self.summary_url = reverse('lookup.transaction_summary',
                                   args=[self.uuid])
        self.url = reverse('lookup.transaction_refund', args=[self.uuid])
        self.app = app_factory()
        self.user = UserProfile.objects.get(username='******')
        AddonUser.objects.create(addon=self.app, user=self.user)

        self.contrib = Contribution.objects.create(addon=self.app,
                                                   user=self.user,
                                                   uuid=self.uuid,
                                                   type=amo.CONTRIB_PURCHASE,
                                                   amount=1)

        self.req = RequestFactory().post(self.url, {'refund_reason': 'text'})
        self.req.user = User.objects.get(username='******')
        self.req.amo_user = UserProfile.objects.get(username='******')
        self.req.groups = self.req.amo_user.groups.all()
        # Fix Django 1.4 RequestFactory bug with MessageMiddleware.
        setattr(self.req, 'session', 'session')
        messages = FallbackStorage(self.req)
        setattr(self.req, '_messages', messages)
        self.login(self.req.user)
Beispiel #48
0
 def test_product_create_exists(self):
     self.ref_patcher.products.get.return_value = [{'resource_uri': '/f'}]
     account = self.make_account()
     app = app_factory()
     self.ref.product_create(account, app)
     # Product should have been got from zippy, but not created by a post.
     assert self.ref_patcher.products.get.called
    def test_create_new_product(self):
        account = self.make_account()
        app = app_factory()

        generic_product_uri = '/generic/product/1/'
        boku_product_uri = '/boku/product/1/'
        self.generic_patcher.product.get_object_or_404.return_value = {
            'resource_pk': 1,
            'resource_uri': generic_product_uri,
        }

        self.boku_patcher.product.get.return_value = {
            'meta': {'total_count': 0},
            'objects': [],
        }
        self.boku_patcher.product.post.return_value = {
            'resource_uri': boku_product_uri,
            'seller_product': generic_product_uri,
            'seller_boku': account.uri,
        }

        product = self.boku.product_create(account, app)
        eq_(product, boku_product_uri)
        self.boku_patcher.product.post.assert_called_with(data={
            'seller_boku': account.uri,
            'seller_product': generic_product_uri,
        })
Beispiel #50
0
    def test_update_existing_product(self):
        account = self.make_account()
        app = app_factory()

        generic_product_uri = '/generic/product/1/'
        self.generic_patcher.product.get_object_or_404.return_value = {
            'resource_pk': 1,
            'resource_uri': generic_product_uri,
        }

        existing_boku_product_uri = '/boku/product/1/'
        self.boku_patcher.product.get.return_value = {
            'meta': {
                'total_count': 1
            },
            'objects': [{
                'resource_uri': existing_boku_product_uri,
            }],
        }
        patch_mock = Mock()
        patch_mock.patch.return_value = {
            'resource_uri': existing_boku_product_uri,
            'seller_product': generic_product_uri,
            'seller_boku': account.uri,
        }
        self.boku_patcher.by_url.return_value = patch_mock

        product = self.boku.product_create(account, app)
        eq_(product, existing_boku_product_uri)
        self.boku_patcher.by_url.assert_called_with(existing_boku_product_uri)
        patch_mock.patch.assert_called_with(
            data={
                'seller_boku': account.uri,
                'seller_product': generic_product_uri,
            })
Beispiel #51
0
 def test_product_create_exists(self):
     self.generic_patcher.product.get_object_or_404.return_value = {
         'resource_uri': '/f'
     }
     account = self.make_account()
     app = app_factory()
     eq_(self.boku.product_create(account, app), '/f')
Beispiel #52
0
 def setUp(self):
     self.app = app_factory()
     self.app_url = get_url('app', self.app.pk)
     self.version = self.app.current_version
     self.file = self.version.all_files[0]
     self.request = RequestFactory()
     super(TestVersionStatusViewSet, self).setUp()
Beispiel #53
0
 def setUp(self):
     self.saved_cb = mkt.site.models._on_change_callbacks.copy()
     mkt.site.models._on_change_callbacks.clear()
     self.cb = Mock()
     self.cb.__name__ = 'testing_mock_callback'
     Webapp.on_change(self.cb)
     self.testapp = app_factory(public_stats=True)
Beispiel #54
0
 def test_set_apps_with_permission_three_apps(self):
     self.feed_permission()
     self.apps = [app_factory() for i in xrange(3)]
     new_apps = [app.pk for app in self.apps]
     res, data = self.set_apps(self.client, apps=new_apps)
     eq_(res.status_code, 200)
     eq_(new_apps, [app['id'] for app in data['apps']])
Beispiel #55
0
 def test_only_put_by_owner(self, client):
     app2 = app_factory(premium_type=amo.ADDON_FREE_INAPP)
     AddonUser.objects.create(addon=app2, user=self.other)
     acct = setup_payment_account(app2, self.other).payment_account
     r = self.client.put(get_url('account', acct.pk),
                         data=json.dumps(package_data))
     eq_(r.status_code, 404)
Beispiel #56
0
 def setUp(self):
     super(TestAcctSummary, self).setUp()
     self.user = UserProfile.objects.get(username='******')  # steamcube
     self.steamcube = Addon.objects.get(pk=337141)
     self.otherapp = app_factory(app_slug='otherapp')
     self.reg_user = UserProfile.objects.get(email='*****@*****.**')
     self.summary_url = reverse('lookup.user_summary', args=[self.user.pk])
     self.login(UserProfile.objects.get(username='******'))
Beispiel #57
0
    def test_q_exact(self):
        app1 = app_factory(name='test app test11')
        app2 = app_factory(name='test app test21')
        app3 = app_factory(name='test app test31')
        self.refresh('webapp')

        res = self.client.get(self.url + ({'q': 'test app test21'}, ))
        eq_(res.status_code, 200)
        eq_(len(res.json['objects']), 3)
        # app2 should be first since it's an exact match and is boosted higher.
        obj = res.json['objects'][0]
        eq_(obj['slug'], app2.app_slug)

        unindex_webapps([app1.id, app2.id, app3.id])
        app1.delete()
        app2.delete()
        app3.delete()
Beispiel #58
0
 def test_patch(self):
     self.create_upsell()
     self.create_allowed()
     another = app_factory(premium_type=amo.ADDON_PREMIUM)
     AddonUser.objects.create(addon=another, user=self.profile)
     res = self.client.patch(self.upsell_url, data=json.dumps(
         {'free': self.free_url, 'premium': self.url(another)}))
     eq_(res.status_code, 200)
Beispiel #59
0
 def test_patch_new_not_allowed(self):
     # Trying to patch to a new object you do not have access to.
     self.create_upsell()
     self.create_allowed()
     another = app_factory(premium_type=amo.ADDON_PREMIUM)
     res = self.client.patch(self.upsell_url, data=json.dumps(
         {'free': self.free_url, 'premium': self.url(another)}))
     eq_(res.status_code, 403)