当前位置: 首页>>代码示例>>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;未经允许,请勿转载。