本文整理汇总了Python中bandwagon.tests.test_models.TestRecommendations.expected_recs方法的典型用法代码示例。如果您正苦于以下问题:Python TestRecommendations.expected_recs方法的具体用法?Python TestRecommendations.expected_recs怎么用?Python TestRecommendations.expected_recs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bandwagon.tests.test_models.TestRecommendations
的用法示例。
在下文中一共展示了TestRecommendations.expected_recs方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from bandwagon.tests.test_models import TestRecommendations [as 别名]
# 或者: from bandwagon.tests.test_models.TestRecommendations import expected_recs [as 别名]
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)
示例2: test_only_show_public
# 需要导入模块: from bandwagon.tests.test_models import TestRecommendations [as 别名]
# 或者: from bandwagon.tests.test_models.TestRecommendations import expected_recs [as 别名]
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
示例3: test_only_show_public
# 需要导入模块: from bandwagon.tests.test_models import TestRecommendations [as 别名]
# 或者: from bandwagon.tests.test_models.TestRecommendations import expected_recs [as 别名]
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
示例4: setUp
# 需要导入模块: from bandwagon.tests.test_models import TestRecommendations [as 别名]
# 或者: from bandwagon.tests.test_models.TestRecommendations import expected_recs [as 别名]
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)