Esempio n. 1
0
    def setUp(self):
        super(TestRecs, self).setUp()
        self.url = reverse('discovery.recs', args=['3.6', 'Darwin'])
        self.guids = ('*****@*****.**',
                      '*****@*****.**',
                      '*****@*****.**',
                      'not-a-real-guid',)
        self.ids = Recs.ids
        self.guids = [a.guid or 'bad-guid'
                      for a in Addon.objects.filter(id__in=self.ids)]
        self.json = json.dumps({'guids': self.guids})
        # The view is limited to returning 9 add-ons.
        self.expected_recs = Recs.expected_recs()[:9]

        versions = AppVersion.objects.filter(application=amo.FIREFOX.id)
        self.min_id = versions.order_by('version_int')[0].id
        self.max_id = versions.order_by('-version_int')[0].id
        for addon in Addon.objects.all():
            v = Version.objects.create(addon=addon)
            File.objects.create(version=v, status=amo.STATUS_PUBLIC)
            ApplicationsVersions.objects.create(
                version=v, application=amo.FIREFOX.id,
                min_id=self.min_id, max_id=self.max_id)
            addon.update(_current_version=v)
            addons.signals.version_changed.send(sender=addon)
        Addon.objects.update(status=amo.STATUS_PUBLIC, disabled_by_user=False)
Esempio n. 2
0
    def setUp(self):
        self.url = reverse('discovery.recs', args=['3.6', 'Darwin'])
        self.guids = (
            '*****@*****.**',
            '*****@*****.**',
            '*****@*****.**',
            'not-a-real-guid',
        )
        self.ids = Recs.ids
        self.guids = [
            a.guid or 'bad-guid' for a in Addon.objects.filter(id__in=self.ids)
        ]
        self.json = json.dumps({'guids': self.guids})
        # The view is limited to returning 9 add-ons.
        self.expected_recs = Recs.expected_recs()[:9]

        self.min_id, self.max_id = 1, 364  # see test_min_max_appversion
        for addon in Addon.objects.all():
            v = Version.objects.create(addon=addon)
            File.objects.create(version=v, status=amo.STATUS_PUBLIC)
            ApplicationsVersions.objects.create(version=v,
                                                application_id=amo.FIREFOX.id,
                                                min_id=self.min_id,
                                                max_id=self.max_id)
            addon.update(_current_version=v)
            addons.signals.version_changed.send(sender=addon)
        Addon.objects.update(status=amo.STATUS_PUBLIC, disabled_by_user=False)
Esempio n. 3
0
    def test_only_show_public(self):
        # Mark one add-on as non-public.
        unpublic = self.expected_recs[0]
        Addon.objects.filter(id=unpublic).update(status=amo.STATUS_LITE)
        response = self.client.post(self.url, self.json, content_type="application/json")
        eq_(response.status_code, 200)

        data = json.loads(response.content)
        eq_(len(data["addons"]), 9)
        ids = [a["id"] for a in data["addons"]]
        eq_(ids, Recs.expected_recs()[1:10])
        assert unpublic not in ids
Esempio n. 4
0
    def test_only_show_public(self):
        # Mark one add-on as non-public.
        unpublic = self.expected_recs[0]
        Addon.objects.filter(id=unpublic).update(status=amo.STATUS_LITE)
        response = self.client.post(self.url, self.json,
                                    content_type='application/json')
        eq_(response.status_code, 200)

        data = json.loads(response.content)
        eq_(len(data['addons']), 9)
        ids = [a['id'] for a in data['addons']]
        eq_(ids, Recs.expected_recs()[1:10])
        assert unpublic not in ids
Esempio n. 5
0
    def test_only_show_public(self, api_mock):
        raise SkipTest()  # bug 640694
        api_mock.addon_filter = lambda xs, _, limit, *args, **kw: xs[:limit]

        # Mark one add-on as non-public.
        unpublic = self.expected_recs[0]
        Addon.objects.filter(id=unpublic).update(status=amo.STATUS_LITE)
        response = self.client.post(self.url, self.json, content_type="application/json")
        eq_(response.status_code, 200)

        data = json.loads(response.content)
        eq_(len(data["addons"]), 9)
        ids = [a["id"] for a in data["addons"]]
        eq_(ids, Recs.expected_recs()[1:10])
        assert unpublic not in ids
Esempio n. 6
0
    def test_only_show_public(self, api_mock):
        raise SkipTest()  # bug 640694
        api_mock.addon_filter = lambda xs, _, limit, *args, **kw: xs[:limit]

        # Mark one add-on as non-public.
        unpublic = self.expected_recs[0]
        Addon.objects.filter(id=unpublic).update(status=amo.STATUS_LITE)
        response = self.client.post(self.url, self.json,
                                    content_type='application/json')
        eq_(response.status_code, 200)

        data = json.loads(response.content)
        eq_(len(data['addons']), 9)
        ids = [a['id'] for a in data['addons']]
        eq_(ids, Recs.expected_recs()[1:10])
        assert unpublic not in ids
Esempio n. 7
0
    def setUp(self):
        self.url = reverse("discovery.recs", args=["3.6", "Darwin"])
        self.guids = (
            "*****@*****.**",
            "*****@*****.**",
            "*****@*****.**",
            "not-a-real-guid",
        )
        self.ids = Recs.ids
        self.guids = [a.guid or "bad-guid" for a in Addon.objects.filter(id__in=self.ids)]
        self.json = json.dumps({"guids": self.guids})
        # The view is limited to returning 9 add-ons.
        self.expected_recs = Recs.expected_recs()[:9]

        self.min_id, self.max_id = 1, 364  # see test_min_max_appversion
        for addon in Addon.objects.all():
            v = Version.objects.create(addon=addon)
            File.objects.create(version=v, status=amo.STATUS_PUBLIC)
            ApplicationsVersions.objects.create(
                version=v, application_id=amo.FIREFOX.id, min_id=self.min_id, max_id=self.max_id
            )
            addon.update(_current_version=v)
            addons.signals.version_changed.send(sender=addon)
        Addon.objects.update(status=amo.STATUS_PUBLIC, disabled_by_user=False)