当前位置: 首页>>代码示例>>Python>>正文


Python DEVICE_TYPES.keys方法代码示例

本文整理汇总了Python中mkt.constants.applications.DEVICE_TYPES.keys方法的典型用法代码示例。如果您正苦于以下问题:Python DEVICE_TYPES.keys方法的具体用法?Python DEVICE_TYPES.keys怎么用?Python DEVICE_TYPES.keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mkt.constants.applications.DEVICE_TYPES的用法示例。


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

示例1: app_factory

# 需要导入模块: from mkt.constants.applications import DEVICE_TYPES [as 别名]
# 或者: from mkt.constants.applications.DEVICE_TYPES import keys [as 别名]
def app_factory(**kw):
    """
    Create an app. Keyword arguments are passed to addon_factory.

    complete -- fills out app details + creates content ratings.
    rated -- creates content ratings
    """
    complete = kw.pop('complete', False)
    rated = kw.pop('rated', False)
    if complete:
        kw.setdefault('support_email', '[email protected]')

    kw.update(type=amo.ADDON_WEBAPP)
    app = amo.tests.addon_factory(**kw)

    if rated or complete:
        make_rated(app)

    if complete:
        if not app.categories:
            app.update(categories=['utilities'])
        app.addondevicetype_set.create(device_type=DEVICE_TYPES.keys()[0])
        app.previews.create()

    return app
开发者ID:MorrisJobke,项目名称:zamboni,代码行数:27,代码来源:__init__.py

示例2: setUp

# 需要导入模块: from mkt.constants.applications import DEVICE_TYPES [as 别名]
# 或者: from mkt.constants.applications.DEVICE_TYPES import keys [as 别名]
    def setUp(self):
        super(TestVersionPackaged, self).setUp()
        self.login('[email protected]')
        self.app.update(is_packaged=True)
        self.app = self.get_app()
        # Needed for various status checking routines on fully complete apps.
        make_rated(self.app)
        if not self.app.categories:
            self.app.update(categories=['utilities'])
        self.app.addondevicetype_set.create(device_type=DEVICE_TYPES.keys()[0])
        self.app.previews.create()

        self.url = self.app.get_dev_url('versions')
        self.delete_url = self.app.get_dev_url('versions.delete')
开发者ID:pkdevboxy,项目名称:zamboni,代码行数:16,代码来源:test_views_versions.py

示例3: website_factory

# 需要导入模块: from mkt.constants.applications import DEVICE_TYPES [as 别名]
# 或者: from mkt.constants.applications.DEVICE_TYPES import keys [as 别名]
def website_factory(**kwargs):
    text = rand_text()
    data = {
        'description': 'Description for %s' % text.capitalize(),
        'name': text.capitalize(),
        'short_name': text[:10].capitalize(),
        'status': STATUS_PUBLIC,
        'title': 'Title for %s' % text.capitalize(),
        'url': 'http://%s.example.com' % text,
        'mobile_url': 'http://mobile.%s.example.com' % text,
        'devices': DEVICE_TYPES.keys(),
    }
    data.update(kwargs)
    return Website.objects.create(**data)
开发者ID:Jobava,项目名称:zamboni,代码行数:16,代码来源:utils.py

示例4: test_additional_info

# 需要导入模块: from mkt.constants.applications import DEVICE_TYPES [as 别名]
# 或者: from mkt.constants.applications.DEVICE_TYPES import keys [as 别名]
    def test_additional_info(self):
        """
        One of the ways `additional_info` is used it to pass the device type of
        the request and filter apps by device.
        """
        # By default app_factory creates apps with device being
        # DEVICE_TYPES.keys()[0]. Let's change a couple and query by that
        # device.
        device = DEVICE_TYPES.keys()[1]
        self.apps[0].addondevicetype_set.create(device_type=device)
        self.apps[1].addondevicetype_set.create(device_type=device)
        # Reindex b/c we changed an off-model attribute.
        self.reindex(Webapp, 'webapp')

        sq = WebappIndexer.get_app_filter(self.request, {'device': device},
                                          app_ids=self.app_ids)
        results = sq.execute().hits
        eq_(len(results), 2)
开发者ID:j-barron,项目名称:zamboni,代码行数:20,代码来源:test_indexers.py

示例5: test_extract_device

# 需要导入模块: from mkt.constants.applications import DEVICE_TYPES [as 别名]
# 或者: from mkt.constants.applications.DEVICE_TYPES import keys [as 别名]
    def test_extract_device(self):
        device = DEVICE_TYPES.keys()[0]
        AddonDeviceType.objects.create(addon=self.app, device_type=device)

        obj, doc = self._get_doc()
        eq_(doc['device'], [device])
开发者ID:MaxMillion,项目名称:zamboni,代码行数:8,代码来源:test_indexers.py

示例6: app_factory

# 需要导入模块: from mkt.constants.applications import DEVICE_TYPES [as 别名]
# 或者: from mkt.constants.applications.DEVICE_TYPES import keys [as 别名]
def app_factory(status=mkt.STATUS_PUBLIC, version_kw={}, file_kw={}, **kw):
    """
    Create an app.

    complete -- fills out app details + creates content ratings.
    rated -- creates content ratings

    """
    from mkt.webapps.models import update_search_index, Webapp
    # Disconnect signals until the last save.
    post_save.disconnect(update_search_index, sender=Webapp,
                         dispatch_uid='webapp.search.index')

    complete = kw.pop('complete', False)
    rated = kw.pop('rated', False)
    if complete:
        kw.setdefault('support_email', '[email protected]')
    when = _get_created(kw.pop('created', None))

    # Keep as much unique data as possible in the uuid: '-' aren't important.
    name = kw.pop('name',
                  u'Webapp %s' % unicode(uuid.uuid4()).replace('-', ''))

    kwargs = {
        # Set artificially the status to STATUS_PUBLIC for now, the real
        # status will be set a few lines below, after the update_version()
        # call. This prevents issues when calling app_factory with
        # STATUS_DELETED.
        'status': mkt.STATUS_PUBLIC,
        'name': name,
        'app_slug': name.replace(' ', '-').lower()[:30],
        'bayesian_rating': random.uniform(1, 5),
        'created': when,
        'last_updated': when,
    }
    kwargs.update(kw)

    # Save 1.
    app = Webapp.objects.create(**kwargs)
    version = version_factory(file_kw, addon=app, **version_kw)  # Save 2.
    app.status = status
    app.update_version()

    # Put signals back.
    post_save.connect(update_search_index, sender=Webapp,
                      dispatch_uid='webapp.search.index')

    app.save()  # Save 4.

    if 'nomination' in version_kw:
        # If a nomination date was set on the version, then it might have been
        # erased at post_save by addons.models.watch_status() or
        # mkt.webapps.models.watch_status().
        version.save()

    if rated or complete:
        make_rated(app)

    if complete:
        if not app.categories:
            app.update(categories=['utilities'])
        app.addondevicetype_set.create(device_type=DEVICE_TYPES.keys()[0])
        app.previews.create()

    return app
开发者ID:clouserw,项目名称:zamboni,代码行数:67,代码来源:utils.py


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