• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.website_factory函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mkt.websites.utils.website_factory函数的典型用法代码示例。如果您正苦于以下问题:Python website_factory函数的具体用法?Python website_factory怎么用?Python website_factory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了website_factory函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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']))
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:11,代码来源:test_views.py


示例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)
开发者ID:clouserw,项目名称:zamboni,代码行数:14,代码来源:test_views.py


示例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)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:15,代码来源:test_views.py


示例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')
开发者ID:Witia1,项目名称:zamboni,代码行数:7,代码来源:test_views_api.py


示例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())
开发者ID:Jobava,项目名称:zamboni,代码行数:27,代码来源:test_indexers.py


示例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)
开发者ID:clouserw,项目名称:zamboni,代码行数:7,代码来源:test_views.py


示例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
开发者ID:Hitechverma,项目名称:zamboni,代码行数:16,代码来源:test_views.py


示例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)
开发者ID:Jobava,项目名称:zamboni,代码行数:8,代码来源:test_views.py


示例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')
开发者ID:Jobava,项目名称:zamboni,代码行数:8,代码来源:test_models.py


示例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
     }
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:8,代码来源:test_views.py


示例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)
开发者ID:shahbaz17,项目名称:zamboni,代码行数:8,代码来源:test_views.py


示例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]),
     })
开发者ID:clouserw,项目名称:zamboni,代码行数:8,代码来源:test_views.py


示例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)
开发者ID:carriercomm,项目名称:zamboni,代码行数:18,代码来源:test_views.py


示例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})
开发者ID:atiqueahmedziad,项目名称:zamboni,代码行数:11,代码来源:test_views.py


示例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')
开发者ID:psvramaraju,项目名称:zamboni,代码行数:11,代码来源:test_views.py


示例16: test_get_multi

    def test_get_multi(self):
        website = website_factory()
        app = app_factory()
        website_factory(devices=[mkt.DEVICE_DESKTOP.id,
                                 mkt.DEVICE_GAIA.id])
        app.addondevicetype_set.create(device_type=mkt.DEVICE_TV.id)
        self.reindex(Webapp)
        self.reindex(Website)
        self.refresh()
        url = reverse('tv-multi-search-api')
        res = self.client.get(url)
        objects = res.json['objects']
        eq_(len(objects), 2)
        eq_(objects[0]['doc_type'], 'webapp')
        assert_tvplace_app(objects[0])
        eq_(objects[0]['id'], app.pk)

        eq_(objects[1]['doc_type'], 'website')
        assert_tvplace_website(objects[1])
        eq_(objects[1]['id'], website.pk)
开发者ID:carriercomm,项目名称:zamboni,代码行数:20,代码来源:test_views.py


示例17: test_attach_tags_websites

    def test_attach_tags_websites(self):
        tag1 = Tag.objects.create(tag_text="abc", blocked=False)
        tag2 = Tag.objects.create(tag_text="xyz", blocked=False)
        tag3 = Tag.objects.create(tag_text="swearword", blocked=True)

        website1 = website_factory()
        website1.keywords.add(tag1)
        website1.keywords.add(tag2)
        website1.keywords.add(tag3)

        website2 = website_factory()
        website2.keywords.add(tag2)
        website2.keywords.add(tag3)

        website3 = website_factory()

        ok_(not hasattr(website1, "keywords_list"))
        attach_tags([website3, website2, website1])
        eq_(website1.keywords_list, ["abc", "xyz"])
        eq_(website2.keywords_list, ["xyz"])
        ok_(not hasattr(website3, "keywords_list"))
开发者ID:ujdhesa,项目名称:zamboni,代码行数:21,代码来源:test_models.py


示例18: 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.extension = Extension.objects.create(name='test-ext-lol')
     self.extension.versions.create(status=STATUS_PUBLIC)
     self.extension.popularity.add(ExtensionPopularity(region=0, value=999))
     self.reindex(Extension)
     self.reindex(Webapp)
     self.reindex(Website)
开发者ID:Witia1,项目名称:zamboni,代码行数:12,代码来源:test_views.py


示例19: test_url

 def test_url(self):
     self.obj = website_factory()
     expected = {
         'http://domain.com': 'domain',
         'https://www.domain.com': 'domain',
         'http://m.domain.com': 'domain',
         'http://mobile.domain.com': 'domain',
         'http://domain.uk': 'domain',
         'http://www.domain.com/path/': 'domain/path/',
         'http://www.domain.com/path/?query#fragment': 'domain/path/',
     }
     for k, v in expected.items():
         eq_(self.indexer.strip_url(k), v)
开发者ID:Jobava,项目名称:zamboni,代码行数:13,代码来源:test_indexers.py


示例20: test_trending

    def test_trending(self):
        self.obj = website_factory()
        self.obj.trending.create(region=0, value=10.0)
        # Test an adolescent region.
        self.obj.trending.create(region=2, value=50.0)
        # Test a mature region.
        self.obj.trending.create(region=7, value=50.0)

        doc = self._get_doc()
        eq_(doc['trending'], 10.0)
        # An adolescent region uses the global trending value.
        eq_(doc['trending_2'], 10.0)
        eq_(doc['trending_7'], 50.0)
开发者ID:graingert,项目名称:zamboni,代码行数:13,代码来源:test_indexers.py



注:本文中的mkt.websites.utils.website_factory函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.unmemoized_get_config函数代码示例发布时间:2022-05-27
下一篇:
Python models.Website类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap