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

Python tests.app_factory函数代码示例

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

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



在下文中一共展示了app_factory函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_ordering

def test_ordering():
    """Given a specific set of primary keys, assure that we return addons
    in that order."""

    app1id = app_factory().id
    app2id = app_factory().id
    app3id = app_factory().id
    semi_arbitrary_order = [app2id, app3id, app1id]
    addons = manual_order(Webapp.objects.all(), semi_arbitrary_order)
    eq_(semi_arbitrary_order, [addon.id for addon in addons])
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:10,代码来源:test_models.py


示例2: test_with_existing_cert_valid

    def test_with_existing_cert_valid(self):
        # Set up. app1 has no rating descriptors, app2 has one.
        data = setup_mock_response('GetRatingChanges')
        cert_id_1 = data['CertList'][0]['CertID']
        cert_id_2 = data['CertList'][1]['CertID']
        app1 = app_factory()
        app2 = app_factory()
        IARCCert.objects.create(app=app1, cert_id=UUID(cert_id_1))
        IARCCert.objects.create(app=app2, cert_id=UUID(cert_id_2))
        eq_(RatingDescriptors.objects.filter(addon=app1).count(), 0)
        RatingDescriptors.objects.create(addon=app2, has_esrb_lang=True)
        eq_(app2.rating_descriptors.to_keys(), ['has_esrb_lang'])
        expected_end_date = datetime.datetime.utcnow()
        expected_start_date = expected_end_date - datetime.timedelta(days=1)

        # GetRatingChanges Call.
        res = get_rating_changes()

        # Check that we called IARC as expected.
        eq_(len(responses.calls), 1)
        eq_(responses.calls[0].request.headers.get('StorePassword'),
            settings.IARC_V2_STORE_PASSWORD)
        eq_(responses.calls[0].request.headers.get('StoreID'),
            settings.IARC_V2_STORE_ID)
        eq_(json.loads(responses.calls[0].request.body), {
            'StartDate': expected_start_date.strftime('%Y-%m-%d'),
            'EndDate': expected_end_date.strftime('%Y-%m-%d'),
            'MaxRows': 500,
            'StartRowIndex': 0
        })
        eq_(res['Result']['ResponseCode'], 'Success')

        # Check that Cert IDs are still correct.
        eq_(UUID(app1.iarc_cert.cert_id), UUID(cert_id_1))
        eq_(UUID(app2.iarc_cert.cert_id), UUID(cert_id_2))

        # Compare with mock data. Force reload using .objects.get in order to
        # properly reset the related objects caching. App1 should have gained
        # a descriptor, and app2 should have lost its original descriptor and
        # gained a few.
        app1 = Webapp.objects.get(pk=app1.pk)
        app2 = Webapp.objects.get(pk=app2.pk)
        eq_(app1.rating_descriptors.to_keys(), ['has_esrb_violence_ref'])
        self.assertSetEqual(
            app2.rating_descriptors.to_keys(),
            ['has_classind_violence', 'has_generic_moderate_violence',
             'has_pegi_moderate_violence', 'has_esrb_violence',
             'has_usk_violence'])
        eq_(app1.content_ratings.all()[0].get_rating_class(), ESRB_10)
        eq_(app2.content_ratings.all()[0].get_rating_class(), CLASSIND_12)
开发者ID:digideskio,项目名称:zamboni,代码行数:50,代码来源:test_client.py


示例3: setUp

    def setUp(self):
        self.app = app_factory(name='XXX')
        eq_(EscalationQueue.objects.filter(webapp=self.app).count(), 0)

        patcher = mock.patch.object(settings, 'TASK_USER_ID', 4043307)
        patcher.start()
        self.addCleanup(patcher.stop)
开发者ID:shahbaz17,项目名称:zamboni,代码行数:7,代码来源:test_tasks.py


示例4: test_events_webapps

    def test_events_webapps(self):
        self.app = app_factory()
        self.check_event(mkt.STATUS_PENDING,
                         mkt.REVIEWED_WEBAPP_HOSTED)

        RereviewQueue.objects.create(addon=self.app)
        self.check_event(mkt.STATUS_PUBLIC,
                         mkt.REVIEWED_WEBAPP_REREVIEW, in_rereview=True)
        self.check_event(mkt.STATUS_UNLISTED,
                         mkt.REVIEWED_WEBAPP_REREVIEW, in_rereview=True)
        self.check_event(mkt.STATUS_APPROVED,
                         mkt.REVIEWED_WEBAPP_REREVIEW, in_rereview=True)
        RereviewQueue.objects.all().delete()

        self.app.is_packaged = True
        self.check_event(mkt.STATUS_PENDING,
                         mkt.REVIEWED_WEBAPP_PACKAGED)
        self.check_event(mkt.STATUS_PUBLIC,
                         mkt.REVIEWED_WEBAPP_UPDATE)
        self.check_event(mkt.STATUS_UNLISTED,
                         mkt.REVIEWED_WEBAPP_UPDATE)
        self.check_event(mkt.STATUS_APPROVED,
                         mkt.REVIEWED_WEBAPP_UPDATE)

        self.app.latest_version.is_privileged = True
        self.check_event(mkt.STATUS_PENDING,
                         mkt.REVIEWED_WEBAPP_PRIVILEGED)
        self.check_event(mkt.STATUS_PUBLIC,
                         mkt.REVIEWED_WEBAPP_PRIVILEGED_UPDATE)
        self.check_event(mkt.STATUS_UNLISTED,
                         mkt.REVIEWED_WEBAPP_PRIVILEGED_UPDATE)
        self.check_event(mkt.STATUS_APPROVED,
                         mkt.REVIEWED_WEBAPP_PRIVILEGED_UPDATE)
开发者ID:Jobava,项目名称:zamboni,代码行数:33,代码来源:test_models.py


示例5: _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


示例6: test_refresh

    def test_refresh(self):
        setup_mock_response('SearchCerts')
        cert = UUID('adb3261b-c657-4fd2-a057-bc9f85310b80')
        app = app_factory()
        IARCCert.objects.create(app=app, cert_id=cert.get_hex())
        refresh(app)
        eq_(len(responses.calls), 1)
        eq_(responses.calls[0].request.headers.get('StorePassword'),
            settings.IARC_V2_STORE_PASSWORD)
        eq_(responses.calls[0].request.headers.get('StoreID'),
            settings.IARC_V2_STORE_ID)
        eq_(json.loads(responses.calls[0].request.body), {
            'CertID': unicode(cert)
        })

        # Compare with mock data. Force reload using .objects.get in order to
        # properly reset the related objects caching.
        app = Webapp.objects.get(pk=app.pk)
        self.assertSetEqual(
            app.rating_descriptors.to_keys(),
            ['has_classind_lang', 'has_generic_parental_guidance_recommended',
             'has_pegi_parental_guidance_recommended'])
        self.assertSetEqual(
            app.rating_interactives.to_keys(),
            ['has_shares_location', 'has_digital_purchases',
             'has_users_interact'])
        eq_(app.content_ratings.all()[0].get_rating_class(), CLASSIND_12)
开发者ID:digideskio,项目名称:zamboni,代码行数:27,代码来源:test_client.py


示例7: setUp

 def setUp(self):
     self.saved_cb = models._on_change_callbacks.copy()
     models._on_change_callbacks.clear()
     self.cb = Mock()
     self.cb.__name__ = 'testing_mock_callback'
     Webapp.on_change(self.cb)
     self.testapp = app_factory(public_stats=True)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:7,代码来源:test_models.py


示例8: setUp

 def setUp(self):
     super(TestUserHasPermNoteApps, self).setUp()
     self.app = app_factory()
     self.developer = user_factory()
     self.developer.addonuser_set.create(addon=self.app)
     self.reviewer = user_factory()
     self.grant_permission(self.reviewer, "Apps", "Review")
     self.thread = CommunicationThread.objects.create(_addon=self.app, _version=self.app.latest_version)
开发者ID:ujdhesa,项目名称:zamboni,代码行数:8,代码来源:test_models.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: make_packaged_app

def make_packaged_app():
    ap = app_factory()
    ap.update(is_packaged=True)
    f = ap.latest_version.all_files[0]
    fp = os.path.join(ap.latest_version.path_prefix, f.filename)
    with private_storage.open(fp, 'w') as out:
        out.write('.')
    return ap
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:8,代码来源:test_views.py


示例11: 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


示例12: homescreen_factory

def homescreen_factory(self):
    # Homescreens may not be added to feed collections.
    homescreen = app_factory(name=u'Elegant Waffle',
                                  description=u'homescreen runner',
                                  created=self.days_ago(5),
                                  manifest_url='http://h.testmanifest.com')
    Tag(tag_text='homescreen').save_tag(homescreen)
    return homescreen
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:8,代码来源:test_models.py


示例13: test_indexable

 def test_indexable(self):
     homescreen = app_factory(name=u'Elegant Waffle',
                              description=u'homescreen runner',
                              created=self.days_ago(5),
                              manifest_url='http://h.testmanifest.com')
     Tag(tag_text='homescreen').save_tag(homescreen)
     homescreen.save()
     q = WebappIndexer.get_indexable()
     eq_(list(q), [self.app])
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:9,代码来源:test_indexers.py


示例14: test_lang

    def test_lang(self):
        app = app_factory(description={'fr': 'Le blah', 'en-US': 'Blah'})
        url = reverse('app-detail', args=[app.pk])

        res = self.client.get(url + '?lang=en')
        eq_(json.loads(res.content)['description'], 'Blah')

        res = self.client.get(url + '?lang=fr')
        eq_(json.loads(res.content)['description'], 'Le blah')
开发者ID:ujdhesa,项目名称:zamboni,代码行数:9,代码来源:test_handlers.py


示例15: test_with_user_installed

 def test_with_user_installed(self, region_from_request):
     region_from_request.return_value = mkt.regions.BRA
     installed_app = app_factory()
     Installed.objects.create(user=self.user, webapp=installed_app)
     res = self.client.get(self.url)
     data = json.loads(res.content)
     eq_(data['region'], 'br')
     eq_(data['apps']['installed'], [installed_app.pk])
     eq_(data['apps']['developed'], [])
     eq_(data['apps']['purchased'], [])
开发者ID:shahbaz17,项目名称:zamboni,代码行数:10,代码来源:test_views.py


示例16: test_with_user_purchased

 def test_with_user_purchased(self, region_from_request, purchase_ids):
     region_from_request.return_value = mkt.regions.BRA
     purchased_app = app_factory()
     purchase_ids.return_value = [purchased_app.pk]
     res = self.client.get(self.url)
     data = json.loads(res.content)
     eq_(data['region'], 'br')
     eq_(data['apps']['installed'], [])
     eq_(data['apps']['developed'], [])
     eq_(data['apps']['purchased'], [purchased_app.pk])
开发者ID:shahbaz17,项目名称:zamboni,代码行数:10,代码来源:test_views.py


示例17: test_with_user_installed

 def test_with_user_installed(self, region_from_request):
     region_from_request.return_value = mkt.regions.BRA
     installed_app = app_factory()
     Installed.objects.create(user=self.user, addon=installed_app)
     res = self.client.get(self.url)
     data = json.loads(res.content)
     eq_(data["region"], "br")
     eq_(data["apps"]["installed"], [installed_app.pk])
     eq_(data["apps"]["developed"], [])
     eq_(data["apps"]["purchased"], [])
开发者ID:Jobava,项目名称:zamboni,代码行数:10,代码来源:test_views.py


示例18: test_attach_to_cert_uuid_hex_string

 def test_attach_to_cert_uuid_hex_string(self):
     setup_mock_response('AttachToCert')
     fake_app = app_factory()
     fake_cert = uuid4()
     data = _attach_to_cert(fake_app, fake_cert.get_hex())
     eq_(data,
         {'ResultCode': 'Success', 'ErrorMessage': None, 'ErrorID': None})
     expected_json = app_data(fake_app)
     expected_json['CertID'] = unicode(fake_cert)
     eq_(len(responses.calls), 1)
     eq_(responses.calls[0].request.url,
         urljoin(settings.IARC_V2_SERVICE_ENDPOINT, 'AttachToCert'))
     eq_(json.loads(responses.calls[0].request.body), expected_json)
开发者ID:mathjazz,项目名称:zamboni,代码行数:13,代码来源:test_client.py


示例19: test_app_data

 def test_app_data(self):
     self.app = app_factory()
     self.profile = user_factory()
     self.app.addonuser_set.create(user=self.profile)
     eq_(app_data(self.app),
         {'StoreProductID': self.app.guid,
          'StoreProductURL': absolutify(self.app.get_url_path()),
          'EmailAddress': self.profile.email,
          'CompanyName': u'',
          'StoreDeveloperID': self.app.pk,
          'DeveloperEmail': self.profile.email,
          'Publish': True,
          'ProductName': unicode(self.app.name)})
开发者ID:mathjazz,项目名称:zamboni,代码行数:13,代码来源:test_client.py


示例20: test_with_existing_cert_valid

    def test_with_existing_cert_valid(self):
        data = setup_mock_response('GetRatingChanges')
        cert_id_1 = data['CertList'][0]['CertID']
        cert_id_2 = data['CertList'][1]['CertID']
        app1 = app_factory()
        app2 = app_factory()
        IARCCert.objects.create(app=app1, cert_id=UUID(cert_id_1))
        IARCCert.objects.create(app=app2, cert_id=UUID(cert_id_2))
        eq_(RatingDescriptors.objects.filter(addon=app1).count(), 0)
        RatingDescriptors.objects.create(addon=app2, has_esrb_lang=True)
        eq_(app2.rating_descriptors.to_keys(), ['has_esrb_lang'])
        expected_start_date = datetime.datetime.utcnow()
        expected_end_date = expected_start_date - datetime.timedelta(days=1)

        res = get_rating_changes()

        eq_(len(responses.calls), 1)
        eq_(responses.calls[0].request.url,
            urljoin(settings.IARC_V2_SERVICE_ENDPOINT, 'GetRatingChanges'))
        eq_(json.loads(responses.calls[0].request.body), {
            'StartDate': expected_start_date.strftime('%Y-%m-%d'),
            'EndDate': expected_end_date.strftime('%Y-%m-%d'),
            'MaxRows': 500,
            'StartRowIndex': 0
        })

        eq_(UUID(app1.iarc_cert.cert_id), UUID(cert_id_1))
        eq_(UUID(app2.iarc_cert.cert_id), UUID(cert_id_2))

        # Compare with mock data. Force reload using .objects.get in order to
        # properly reset the related objects caching.
        app1 = Webapp.objects.get(pk=app1.pk)
        app2 = Webapp.objects.get(pk=app2.pk)
        eq_(app1.rating_descriptors.to_keys(), ['has_esrb_violence_ref'])
        eq_(app2.rating_descriptors.to_keys(),
            ['has_classind_violence', 'has_esrb_violence', 'has_usk_violence'])
        eq_(res['Result']['ResponseCode'], 'Success')
        eq_(app1.content_ratings.all()[0].get_rating_class(), ESRB_10)
        eq_(app2.content_ratings.all()[0].get_rating_class(), CLASSIND_12)
开发者ID:mathjazz,项目名称:zamboni,代码行数:39,代码来源:test_client.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python tests.user_factory函数代码示例发布时间:2022-05-27
下一篇:
Python public_storage.open函数代码示例发布时间: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