本文整理汇总了Python中constants.applications.DEVICE_TYPES.keys方法的典型用法代码示例。如果您正苦于以下问题:Python DEVICE_TYPES.keys方法的具体用法?Python DEVICE_TYPES.keys怎么用?Python DEVICE_TYPES.keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类constants.applications.DEVICE_TYPES
的用法示例。
在下文中一共展示了DEVICE_TYPES.keys方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: app_factory
# 需要导入模块: from constants.applications import DEVICE_TYPES [as 别名]
# 或者: from 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:
app.set_content_ratings(
dict((body, body.ratings[0]) for body in
mkt.ratingsbodies.ALL_RATINGS_BODIES))
app.set_iarc_info(123, 'abc')
app.set_descriptors([])
app.set_interactives([])
if complete:
cat, _ = Category.objects.get_or_create(slug='utilities',
type=amo.ADDON_WEBAPP)
app.addoncategory_set.create(category=cat)
app.addondevicetype_set.create(device_type=DEVICE_TYPES.keys()[0])
app.previews.create()
return app
示例2: app_factory
# 需要导入模块: from constants.applications import DEVICE_TYPES [as 别名]
# 或者: from 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:
cat, _ = Category.objects.get_or_create(slug="utilities", type=amo.ADDON_WEBAPP)
app.addoncategory_set.create(category=cat)
app.addondevicetype_set.create(device_type=DEVICE_TYPES.keys()[0])
app.previews.create()
return app
示例3: app_factory
# 需要导入模块: from constants.applications import DEVICE_TYPES [as 别名]
# 或者: from constants.applications.DEVICE_TYPES import keys [as 别名]
def app_factory(**kw):
"""Create an app. Any keyword argument is passed to addon_factory, except
for the booleans 'rated' and 'complete'. Those allow you to create an app
that automatically have content ratings and automatically have everything
needed to be considered 'complete', respectively."""
kw.update(type=amo.ADDON_WEBAPP)
complete = kw.pop('complete', False)
rated = kw.pop('rated', False)
if complete:
kw.setdefault('support_email', '[email protected]')
app = amo.tests.addon_factory(**kw)
if rated or complete:
app.set_content_ratings(
dict((body, body.ratings[0]) for body in
mkt.ratingsbodies.ALL_RATINGS_BODIES))
app.set_iarc_info(123, 'abc')
app.set_descriptors([])
app.set_interactives([])
if complete:
cat, _ = Category.objects.get_or_create(slug='utilities',
type=amo.ADDON_WEBAPP)
app.addoncategory_set.create(category=cat)
app.addondevicetype_set.create(device_type=DEVICE_TYPES.keys()[0])
app.previews.create()
return app
示例4: setUp
# 需要导入模块: from constants.applications import DEVICE_TYPES [as 别名]
# 或者: from constants.applications.DEVICE_TYPES import keys [as 别名]
def setUp(self):
super(TestEditBasic, self).setUp()
self.cat = Category.objects.create(name="Games", type=amo.ADDON_WEBAPP)
self.dtype = DEVICE_TYPES.keys()[0]
AddonCategory.objects.create(addon=self.webapp, category=self.cat)
AddonDeviceType.objects.create(addon=self.webapp, device_type=self.dtype)
self.url = self.get_url("basic")
self.edit_url = self.get_url("basic", edit=True)
示例5: test_device_types
# 需要导入模块: from constants.applications import DEVICE_TYPES [as 别名]
# 或者: from constants.applications.DEVICE_TYPES import keys [as 别名]
def test_device_types(self):
first_device_type = DEVICE_TYPES.keys()[0]
webapp = Webapp.objects.get(id=337141)
AddonDeviceType.objects.create(addon=webapp,
device_type=first_device_type)
types = [DEVICE_TYPES[first_device_type]]
eq_(webapp.device_types, types)
form = forms.DeviceTypeForm(addon=webapp)
eq_(list(form.initial['device_types']),
[t.id for t in types])
示例6: test_device_types_default
# 需要导入模块: from constants.applications import DEVICE_TYPES [as 别名]
# 或者: from constants.applications.DEVICE_TYPES import keys [as 别名]
def test_device_types_default(self):
self._step()
# Add the rest of the device types. We already add [0] in _step().
for d_id in DEVICE_TYPES.keys()[1:]:
AddonDeviceType.objects.create(addon=self.webapp,
device_type=d_id)
r = self.client.get(self.url)
eq_(r.status_code, 200)
checkboxes = pq(r.content)('input[name=device_types]')
eq_(checkboxes.filter(':checked').length, checkboxes.length,
'All device types should be checked by default.')
示例7: test_extract_device
# 需要导入模块: from constants.applications import DEVICE_TYPES [as 别名]
# 或者: from 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])