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

Python utils.app_factory函数代码示例

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

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



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

示例1: test_installed_pagination

    def test_installed_pagination(self):
        ins1 = Installed.objects.create(user=self.user, addon=app_factory())
        ins1.update(created=self.days_ago(1))
        ins2 = Installed.objects.create(user=self.user, addon=app_factory())
        ins2.update(created=self.days_ago(2))
        ins3 = Installed.objects.create(user=self.user, addon=app_factory())
        ins3.update(created=self.days_ago(3))
        res = self.client.get(self.list_url, {"limit": 2})
        eq_(res.status_code, 200)
        data = json.loads(res.content)

        eq_(len(data["objects"]), 2)
        eq_(data["objects"][0]["id"], ins1.addon.id)
        eq_(data["objects"][1]["id"], ins2.addon.id)
        eq_(data["meta"]["total_count"], 3)
        eq_(data["meta"]["limit"], 2)
        eq_(data["meta"]["previous"], None)
        eq_(data["meta"]["offset"], 0)
        next = urlparse(data["meta"]["next"])
        eq_(next.path, self.list_url)
        eq_(QueryDict(next.query).dict(), {u"limit": u"2", u"offset": u"2"})

        res = self.client.get(self.list_url, {"limit": 2, "offset": 2})
        eq_(res.status_code, 200)
        data = json.loads(res.content)

        eq_(len(data["objects"]), 1)
        eq_(data["objects"][0]["id"], ins3.addon.id)
        eq_(data["meta"]["total_count"], 3)
        eq_(data["meta"]["limit"], 2)
        prev = urlparse(data["meta"]["previous"])
        eq_(next.path, self.list_url)
        eq_(QueryDict(prev.query).dict(), {u"limit": u"2", u"offset": u"0"})
        eq_(data["meta"]["offset"], 2)
        eq_(data["meta"]["next"], None)
开发者ID:Jobava,项目名称:zamboni,代码行数:35,代码来源:test_views.py


示例2: setUp

    def setUp(self):
        # Add a public, reviewed app for measure. It took 4 days for this app
        # to get reviewed.
        self.public_app = app_factory(
            version_kw={'created': self.days_ago(7),
                        'nomination': self.days_ago(7),
                        'reviewed': self.days_ago(3)})

        # Took 8 days for another public app to get reviewed.
        app_factory(
            version_kw={'nomination': self.days_ago(10),
                        'reviewed': self.days_ago(2)})

        # Add to the queue 2 pending apps for good measure.
        app_factory(
            status=mkt.STATUS_PENDING,
            file_kw={'status': mkt.STATUS_PENDING},
            version_kw={'nomination': self.days_ago(3)})

        app_factory(
            status=mkt.STATUS_PENDING,
            file_kw={'status': mkt.STATUS_PENDING},
            version_kw={'nomination': self.days_ago(1)})

        # A deleted app that shouldn't change calculations.
        app_factory(
            status=mkt.STATUS_DELETED,
            file_kw={'status': mkt.STATUS_PENDING},
            version_kw={'nomination': self.days_ago(1)})
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:29,代码来源:test_helpers.py


示例3: test_removed

 def test_removed(self):
     # At least one public app must exist for dump_apps to run.
     app_factory(name='second app', status=mkt.STATUS_PUBLIC)
     app_path = os.path.join(self.export_directory, self.app_path)
     app = Webapp.objects.get(pk=337141)
     app.update(status=mkt.STATUS_PUBLIC)
     self.create_export('tarball-name')
     assert private_storage.exists(app_path)
     app.update(status=mkt.STATUS_PENDING)
     self.create_export('tarball-name')
     assert not private_storage.exists(app_path)
开发者ID:shahbaz17,项目名称:zamboni,代码行数:11,代码来源:test_tasks.py


示例4: test_installed_order

 def test_installed_order(self):
     # Should be reverse chronological order.
     ins1 = Installed.objects.create(user=self.user, addon=app_factory())
     ins1.update(created=self.days_ago(1))
     ins2 = Installed.objects.create(user=self.user, addon=app_factory())
     ins2.update(created=self.days_ago(2))
     res = self.client.get(self.list_url)
     eq_(res.status_code, 200)
     data = json.loads(res.content)
     eq_(len(data['objects']), 2)
     eq_(data['objects'][0]['id'], ins1.addon.id)
     eq_(data['objects'][1]['id'], ins2.addon.id)
开发者ID:demagu-sr,项目名称:zamboni,代码行数:12,代码来源:test_views.py


示例5: test_all_results

    def test_all_results(self):
        for x in range(4):
            app_factory(name='chr' + str(x))
        self.refresh('webapp')

        # Test search limit.
        data = self.search(q='chr')
        eq_(len(data['objects']), 2)

        # Test maximum search result.
        data = self.search(q='chr', limit='max')
        eq_(len(data['objects']), 3)
开发者ID:jamesthechamp,项目名称:zamboni,代码行数:12,代码来源:test_views.py


示例6: test_removed

    def test_removed(self):
        # At least one public app must exist for dump_apps to run.
        app_factory(name="second app", status=mkt.STATUS_PUBLIC)
        app_path = os.path.join(settings.DUMPED_APPS_PATH, "apps", "337", "337141.json")
        app = Webapp.objects.get(pk=337141)
        app.update(status=mkt.STATUS_PUBLIC)
        call_command("process_addons", task="dump_apps")
        assert os.path.exists(app_path)

        app.update(status=mkt.STATUS_PENDING)
        call_command("process_addons", task="dump_apps")
        assert not os.path.exists(app_path)
开发者ID:Jobava,项目名称:zamboni,代码行数:12,代码来源:test_tasks.py


示例7: test_relevant_apps

    def test_relevant_apps(self, purchase_ids):
        profile = UserProfile.objects.create(email='[email protected]')
        purchased_app = app_factory()
        purchase_ids.return_value = [purchased_app.pk]
        developed_app = app_factory()
        developed_app.addonuser_set.create(user=profile)
        installed_app = app_factory()
        installed_app.installed.create(user=profile)

        data = self._test_login()
        eq_(data['apps']['installed'], [installed_app.pk])
        eq_(data['apps']['purchased'], [purchased_app.pk])
        eq_(data['apps']['developed'], [developed_app.pk])
开发者ID:demagu-sr,项目名称:zamboni,代码行数:13,代码来源:test_views.py


示例8: test_relevant_apps

    def test_relevant_apps(self, purchase_ids):
        profile = UserProfile.objects.create(email="[email protected]", fxa_uid="fake-uid")
        purchased_app = app_factory()
        purchase_ids.return_value = [purchased_app.pk]
        developed_app = app_factory()
        developed_app.addonuser_set.create(user=profile)
        installed_app = app_factory()
        installed_app.installed.create(user=profile)

        data = self._test_login()
        eq_(data["apps"]["installed"], [installed_app.pk])
        eq_(data["apps"]["purchased"], [purchased_app.pk])
        eq_(data["apps"]["developed"], [developed_app.pk])
开发者ID:Jobava,项目名称:zamboni,代码行数:13,代码来源:test_views.py


示例9: setUp

 def setUp(self):
     (app_factory(), app_factory())
     # Need queryset to initialize form.
     self.apps = Webapp.objects.all()
     self.data = {
         'app': self.apps[0].id,
         'transaction_type': 1,
         'transaction_id': 1,
         'date_from_day': '1',
         'date_from_month': '1',
         'date_from_year': '2012',
         'date_to_day': '1',
         'date_to_month': '1',
         'date_to_year': '2013',
     }
开发者ID:ujdhesa,项目名称:zamboni,代码行数:15,代码来源:test_forms.py


示例10: test_filter_by_app_pk

 def test_filter_by_app_pk(self):
     self.app2 = app_factory()
     Review.objects.create(addon=self.app2, user=self.user, body="no")
     Review.objects.create(addon=self.app, user=self.user, body="yes")
     res, data = self._get_filter(app=self.app.pk)
     eq_(data["info"]["slug"], self.app.app_slug)
     eq_(data["info"]["current_version"], self.app.current_version.version)
开发者ID:clouserw,项目名称:zamboni,代码行数:7,代码来源:test_views.py


示例11: generate_hosted_app

def generate_hosted_app(name, categories, developer_name,
                        privacy_policy=None, device_types=(), status=4,
                        rated=True, uses_flash=False, default_locale='en-US',
                        **spec):
    generated_url = 'http://%s.testmanifest.com/fake-data/manifest.webapp' % (
        slugify(name),)
    a = app_factory(categories=categories, name=name, complete=False,
                    privacy_policy=spec.get('privacy_policy'),
                    file_kw={'status': status, 'uses_flash': uses_flash},
                    default_locale=default_locale, rated=rated,
                    manifest_url=spec.get('manifest_url', generated_url))
    if device_types:
        for dt in device_types:
            a.webappdevicetype_set.create(device_type=DEVICE_CHOICES_IDS[dt])
    else:
        a.webappdevicetype_set.create(device_type=1)
    a.versions.latest().update(reviewed=datetime.datetime.now(),
                               _developer_name=developer_name)
    if 'manifest_file' in spec:
        AppManifest.objects.create(
            version=a._latest_version,
            manifest=open(spec['manifest_file']).read())
    else:
        generate_hosted_manifest(a)
    return a
开发者ID:shahbaz17,项目名称:zamboni,代码行数:25,代码来源:fakedata.py


示例12: setUp

 def setUp(self):
     self.app = app_factory()
     self.app_url = get_url('app', self.app.pk)
     self.version = self.app.current_version
     self.file = self.version.all_files[0]
     self.request = RequestFactory()
     super(TestVersionStatusViewSet, self).setUp()
开发者ID:shahbaz17,项目名称:zamboni,代码行数:7,代码来源:test_views.py


示例13: test_update_existing_product

    def test_update_existing_product(self):
        account = self.make_account()
        app = app_factory()

        generic_product_uri = '/generic/product/1/'
        self.generic_patcher.product.get_object_or_404.return_value = {
            'resource_pk': 1,
            'resource_uri': generic_product_uri,
        }

        existing_boku_product_uri = '/boku/product/1/'
        self.boku_patcher.product.get_object_or_404.return_value = {
            'resource_uri': existing_boku_product_uri
        }
        patch_mock = Mock()
        patch_mock.patch.return_value = {
            'resource_uri': existing_boku_product_uri,
            'seller_product': generic_product_uri,
            'seller_boku': account.uri,
        }
        self.boku_patcher.by_url.return_value = patch_mock

        product = self.boku.product_create(account, app)
        eq_(product, existing_boku_product_uri)
        self.boku_patcher.by_url.assert_called_with(existing_boku_product_uri)
        patch_mock.patch.assert_called_with(data={
            'seller_boku': account.uri,
            'seller_product': generic_product_uri,
        })
开发者ID:clouserw,项目名称:zamboni,代码行数:29,代码来源:test_providers.py


示例14: test_create_new_product

    def test_create_new_product(self):
        account = self.make_account()
        app = app_factory()

        generic_product_uri = '/generic/product/1/'
        boku_product_uri = '/boku/product/1/'
        self.generic_patcher.product.get_object_or_404.return_value = {
            'resource_pk': 1,
            'resource_uri': generic_product_uri,
        }

        self.boku_patcher.product.get_object_or_404.side_effect = (
            ObjectDoesNotExist)

        self.boku_patcher.product.post.return_value = {
            'resource_uri': boku_product_uri,
            'seller_product': generic_product_uri,
            'seller_boku': account.uri,
        }

        product = self.boku.product_create(account, app)
        eq_(product, boku_product_uri)
        self.boku_patcher.product.post.assert_called_with(data={
            'seller_boku': account.uri,
            'seller_product': generic_product_uri,
        })
开发者ID:clouserw,项目名称:zamboni,代码行数:26,代码来源:test_providers.py


示例15: test_rereview_flag_adult

    def test_rereview_flag_adult(self):
        mkt.set_user(user_factory())
        app = app_factory()

        app.set_content_ratings({
            mkt.ratingsbodies.ESRB: mkt.ratingsbodies.ESRB_E,
            mkt.ratingsbodies.CLASSIND: mkt.ratingsbodies.CLASSIND_18,
        })
        _flag_rereview_adult(app, mkt.ratingsbodies.ESRB,
                             mkt.ratingsbodies.ESRB_T)
        assert not app.rereviewqueue_set.count()
        assert not ActivityLog.objects.filter(
            action=mkt.LOG.CONTENT_RATING_TO_ADULT.id).exists()

        # Adult should get flagged to rereview.
        _flag_rereview_adult(app, mkt.ratingsbodies.ESRB,
                             mkt.ratingsbodies.ESRB_A)
        eq_(app.rereviewqueue_set.count(), 1)
        eq_(ActivityLog.objects.filter(
            action=mkt.LOG.CONTENT_RATING_TO_ADULT.id).count(), 1)

        # Test things same same if rating stays the same as adult.
        app.set_content_ratings({
            mkt.ratingsbodies.ESRB: mkt.ratingsbodies.ESRB_A,
        })
        _flag_rereview_adult(app, mkt.ratingsbodies.ESRB,
                             mkt.ratingsbodies.ESRB_A)
        eq_(app.rereviewqueue_set.count(), 1)
        eq_(ActivityLog.objects.filter(
            action=mkt.LOG.CONTENT_RATING_TO_ADULT.id).count(), 1)
开发者ID:shahbaz17,项目名称:zamboni,代码行数:30,代码来源:test_cron.py


示例16: generate_hosted_app

def generate_hosted_app(
    name,
    categories,
    developer_name,
    privacy_policy=None,
    device_types=(),
    status=4,
    rated=True,
    default_locale="en-US",
    **spec
):
    generated_url = "http://%s.testmanifest.com/fake-data/manifest.webapp" % (slugify(name),)
    a = app_factory(
        categories=categories,
        name=name,
        complete=False,
        privacy_policy=spec.get("privacy_policy"),
        file_kw={"status": status},
        default_locale=default_locale,
        rated=rated,
        manifest_url=spec.get("manifest_url", generated_url),
    )
    if device_types:
        for dt in device_types:
            a.addondevicetype_set.create(device_type=DEVICE_CHOICES_IDS[dt])
    else:
        a.addondevicetype_set.create(device_type=1)
    a.versions.latest().update(reviewed=datetime.datetime.now(), _developer_name=developer_name)
    if "manifest_file" in spec:
        AppManifest.objects.create(version=a._latest_version, manifest=open(spec["manifest_file"]).read())
    else:
        generate_hosted_manifest(a)
    return a
开发者ID:jostw,项目名称:zamboni,代码行数:33,代码来源:fakedata.py


示例17: test_get

    def test_get(self, client=None):
        first_version = self.app.current_version
        rev = Review.objects.create(
            addon=self.app, user=self.user, version=first_version, body=u"I lôve this app", rating=5
        )
        rev.update(created=self.days_ago(2))
        rev2 = Review.objects.create(
            addon=self.app, user=self.user2, version=first_version, body=u"I also lôve this app", rating=4
        )
        # Extra review for another app, should be ignored.
        extra_app = app_factory()
        Review.objects.create(
            addon=extra_app, user=self.user, version=extra_app.current_version, body=u"I häte this extra app", rating=1
        )

        self.app.total_reviews = 2
        ver = version_factory(addon=self.app, version="2.0", file_kw=dict(status=mkt.STATUS_PUBLIC))
        self.app.update_version()

        reset_queries()
        res, data = self._get_url(self.list_url, app=self.app.pk, client=client)
        eq_(len(data["objects"]), 2)
        self._compare_review_data(client, data["objects"][0], rev2)
        self._compare_review_data(client, data["objects"][1], rev)
        eq_(data["info"]["average"], self.app.average_rating)
        eq_(data["info"]["slug"], self.app.app_slug)
        eq_(data["info"]["current_version"], ver.version)
        if client != self.anon:
            eq_(data["user"]["can_rate"], True)
            eq_(data["user"]["has_rated"], True)
        return res
开发者ID:clouserw,项目名称:zamboni,代码行数:31,代码来源:test_views.py


示例18: test_installed_remove_app_not_user_installed

 def test_installed_remove_app_not_user_installed(self):
     Installed.objects.create(user=self.user, addon_id=337141)
     app = app_factory()
     Installed.objects.create(user=self.user, addon=app, install_type=INSTALL_TYPE_REVIEWER)
     data = {"app": app.pk}
     res = self.client.post(self.remove_app_url, json.dumps(data))
     eq_(res.status_code, 400)
开发者ID:Jobava,项目名称:zamboni,代码行数:7,代码来源:test_views.py


示例19: test_min

 def test_min(self):
     pending_app = app_factory(
         status=mkt.STATUS_PENDING,
         file_kw={'status': mkt.STATUS_PENDING},
         version_kw={'nomination': self.days_ago(42)})
     pos = helpers.get_position(pending_app)
     eq_(pos['days'], 1)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:7,代码来源:test_helpers.py


示例20: setUp

 def setUp(self):
     self.app = app_factory(status=mkt.STATUS_PENDING)
     self.version = self.app.latest_version
     self.thread = CommunicationThread.objects.create(
         _addon=self.app, _version=self.version)
     self.user = user_factory()
     self.app.addonuser_set.create(user=self.user)
开发者ID:atiqueahmedziad,项目名称:zamboni,代码行数:7,代码来源:test_commands.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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