本文整理汇总了Python中constants.applications.DEVICE_TYPES类的典型用法代码示例。如果您正苦于以下问题:Python DEVICE_TYPES类的具体用法?Python DEVICE_TYPES怎么用?Python DEVICE_TYPES使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DEVICE_TYPES类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: app_factory
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
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: device_list
def device_list(product):
device_types = product.device_types
if device_types:
t = env.get_template('detail/helpers/device_list.html')
return jinja2.Markup(t.render({
'device_types': device_types,
'all_device_types': DEVICE_TYPES.values()}))
示例4: app_factory
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
示例5: setUp
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)
示例6: test_device_types
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])
示例7: test_device_types_default
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.')
示例8: _step
def _step(self):
self.user.update(read_dev_agreement=datetime.datetime.now())
self.cl = AppSubmissionChecklist.objects.create(addon=self.webapp, terms=True, manifest=True)
# Associate app with user.
AddonUser.objects.create(addon=self.webapp, user=self.user)
# Associate device type with app.
self.dtype = DEVICE_TYPES.values()[0]
AddonDeviceType.objects.create(addon=self.webapp, device_type=self.dtype.id)
self.device_types = [self.dtype]
# Associate category with app.
self.cat1 = Category.objects.create(type=amo.ADDON_WEBAPP, name="Fun")
AddonCategory.objects.create(addon=self.webapp, category=self.cat1)
示例9: devices
def devices(self, data):
with no_translation():
names = dict([(n.api_name, n.id)
for n in DEVICE_TYPES.values()])
filtered = [names.get(n, n) for n in data.get('device_types', [])]
return {'device_types': filtered}
示例10: test_extract_device
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])