當前位置: 首頁>>代碼示例>>Python>>正文


Python test_models.TestRecommendations類代碼示例

本文整理匯總了Python中bandwagon.tests.test_models.TestRecommendations的典型用法代碼示例。如果您正苦於以下問題:Python TestRecommendations類的具體用法?Python TestRecommendations怎麽用?Python TestRecommendations使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了TestRecommendations類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setUp

    def setUp(self):
        super(TestRecs, self).setUp()
        self.url = reverse('discovery.recs', args=['3.6', 'Darwin'])
        self.guids = ('[email protected]',
                      '[email protected]',
                      '[email protected]',
                      '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)
開發者ID:abdellah-bn,項目名稱:olympia,代碼行數:26,代碼來源:test_views.py

示例2: test_only_show_public

    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
開發者ID:beenishkhan,項目名稱:zamboni,代碼行數:12,代碼來源:test_views.py

示例3: test_only_show_public

    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
開發者ID:ricardodani,項目名稱:zamboni,代碼行數:15,代碼來源:test_views.py

示例4: setUp

    def setUp(self):
        self.url = reverse("discovery.recs", args=["3.6", "Darwin"])
        self.guids = (
            "[email protected]",
            "[email protected]",
            "[email protected]",
            "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)
開發者ID:beenishkhan,項目名稱:zamboni,代碼行數:24,代碼來源:test_views.py


注:本文中的bandwagon.tests.test_models.TestRecommendations類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。