本文整理汇总了Python中mkt.websites.utils.website_factory函数的典型用法代码示例。如果您正苦于以下问题:Python website_factory函数的具体用法?Python website_factory怎么用?Python website_factory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了website_factory函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_keywords
def test_keywords(self):
website_factory()
self.website.keywords.add(Tag.objects.create(tag_text='hodor'))
self.website.keywords.add(Tag.objects.create(tag_text='radar'))
self.website.save()
self.refresh('website')
res = self.anon.get(self.url, data={'q': 'hodor'})
eq_(res.status_code, 200)
objs = res.json['objects']
eq_(len(objs), 1)
eq_(sorted(objs[0]['keywords']), sorted(['hodor', 'radar']))
示例2: test_q_relevency
def test_q_relevency(self):
# Add 2 websites - the last one has 'something' appearing in both its
# title and its description, so it should be booster and appear higher
# in the results.
website_factory(title='something')
boosted_website = website_factory(title='something',
description='something')
self._reindex()
res = self.anon.get(self.url, data={'q': 'something'})
eq_(res.status_code, 200)
eq_(len(res.json['objects']), 3)
obj = res.json['objects'][0]
eq_(obj['id'], boosted_website.pk)
示例3: test_search_ordering_relevancy
def test_search_ordering_relevancy(self):
website1 = website_factory(
name='Blah', description='Blah', devices=[mkt.DEVICE_TV.id])
website2 = website_factory(name='Blah', devices=[mkt.DEVICE_TV.id],
tv_featured=1)
website3 = website_factory(name='Blah', devices=[mkt.DEVICE_TV.id])
self.reindex(Website)
self.reindex(Webapp)
url = reverse('tv-multi-search-api')
res = self.client.get(url, {'q': 'blah'})
objects = res.json['objects']
eq_(len(objects), 3)
eq_(objects[0]['id'], website2.pk)
eq_(objects[1]['id'], website1.pk)
eq_(objects[2]['id'], website3.pk)
示例4: setUp
def setUp(self):
super(TestWebsiteReviewerActions, self).setUp()
self.website = website_factory(
title='something',
categories=json.dumps(['books', 'sports']))
self.user = UserProfile.objects.get(pk=2519)
self.grant_permission(self.user, 'Websites:Review')
示例5: test_extract_with_translations
def test_extract_with_translations(self):
self.obj = website_factory()
title = {
'en-US': u'Site Tîtle',
'fr': u'Titrè du sïte',
}
self.obj.title = title
name = {
'en-US': u'Namé Site',
'fr': u'Nom du sïte',
}
self.obj.name = name
self.obj.save()
doc = self._get_doc()
eq_(sorted(doc['title']), [title['en-US'], title['fr']])
eq_(sorted(doc['title_translations']),
[{'lang': 'en-US', 'string': title['en-US']},
{'lang': 'fr', 'string': title['fr']}])
eq_(sorted(doc['name']), [name['en-US'], name['fr']])
eq_(sorted(doc['name_translations']),
[{'lang': 'en-US', 'string': name['en-US']},
{'lang': 'fr', 'string': name['fr']}])
eq_(doc['name_l10n_french'], [name['fr']])
eq_(doc['name_l10n_english'], [name['en-US']])
eq_(doc['name_sort'], name['en-US'].lower())
示例6: test_list
def test_list(self):
self.website2 = website_factory(url='http://www.lol.com/')
self._reindex()
with self.assertNumQueries(0):
response = self.anon.get(self.url)
eq_(response.status_code, 200)
eq_(len(response.json['objects']), 2)
示例7: _create_group_of_games
def _create_group_of_games(self):
content = [app_factory(), website_factory(), app_factory(),
website_factory()]
# Add tags.
for i, cat in enumerate(GAME_CATEGORIES):
tag = Tag.objects.get_or_create(tag_text=GAME_CATEGORIES[i])[0]
if hasattr(content[i], 'tags'):
content[i].tags.add(tag)
else:
content[i].keywords.add(tag)
self.reindex(Webapp)
self.reindex(Website)
self.refresh(('webapp', 'website'))
return content
示例8: test_empty
def test_empty(self):
self.webapp = app_factory()
self.website = website_factory()
self.refresh(('webapp', 'website'))
res = self.anon.get(self.url)
eq_(res.status_code, 200)
eq_(len(res.json['objects']), 0)
示例9: setUp
def setUp(self):
self.app = app_factory(status=mkt.STATUS_PENDING)
self.website = website_factory()
self.user = user_factory(email='editor')
self.grant_permission(self.user, 'Apps:Review')
self.admin_user = user_factory(email='admin')
self.grant_permission(self.admin_user, '*:*', name='Admins')
user_factory(email='regular')
示例10: setUp
def setUp(self):
super(TestWebsiteAbuseResource, self).setUp()
self.website = website_factory()
self.default_data = {
'text': 'This website is weird.',
'sprout': 'potato',
'website': self.website.pk
}
示例11: setUp
def setUp(self):
super(TestMultiSearchView, self).setUp()
self.url = reverse('fireplace-multi-search-api')
self.website = website_factory()
self.website.popularity.add(WebsitePopularity(region=0, value=666))
self.webapp = Webapp.objects.get(pk=337141)
self.reindex(Webapp)
self.reindex(Website)
示例12: setUp
def setUp(self):
self.website = website_factory(**{
'categories': json.dumps(['books', 'sports']),
# This assumes devices and region_exclusions are stored as a json
# array of ids, not slugs.
'devices': json.dumps([DEVICE_GAIA.id, DEVICE_DESKTOP.id]),
'region_exclusions': json.dumps([BRA.id, GTM.id, URY.id]),
})
示例13: test_search_ordering
def test_search_ordering(self):
website1 = website_factory(name='A', devices=[mkt.DEVICE_TV.id])
website2 = website_factory(name='B', devices=[mkt.DEVICE_TV.id],
tv_featured=1)
website3 = website_factory(name='C', devices=[mkt.DEVICE_TV.id],
tv_featured=2)
website4 = website_factory(name='D', devices=[mkt.DEVICE_TV.id])
self.reindex(Website)
self.reindex(Webapp)
self.refresh()
url = reverse('tv-multi-search-api')
res = self.client.get(url)
objects = res.json['objects']
eq_(len(objects), 4)
eq_(objects[0]['id'], website3.pk)
eq_(objects[1]['id'], website2.pk)
eq_(objects[2]['id'], website1.pk)
eq_(objects[3]['id'], website4.pk)
示例14: setUp
def setUp(self):
super(TestWebsiteView, self).setUp()
self.website = website_factory(**{
'categories': json.dumps(['books-comics', 'sports']),
# Preferred_regions are stored as a json array of ids.
'preferred_regions': json.dumps([URY.id, USA.id]),
'icon_type': 'image/png',
'icon_hash': 'fakehash',
})
self.url = reverse('api-v2:website-detail',
kwargs={'pk': self.website.pk})
示例15: setUp
def setUp(self):
self.website = website_factory(**{
'title': 'something',
'categories': json.dumps(['books', 'sports']),
'status': STATUS_PENDING,
})
self.url = reverse('api-v2:reviewers-website-search-api')
self.user = UserProfile.objects.get(pk=2519)
self.grant_permission(self.user, 'Apps:Review')
super(TestReviewerSearch, self).setUp()
self.refresh('website')