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', '*****@*****.**') 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
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', '*****@*****.**') 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
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", "*****@*****.**") 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
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)
def test_device_types(self): first_device_type = DEVICE_TYPES.keys()[0] webapp = Webapp.objects.get(id=337141) addondt = 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])
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])
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.')
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.')
def setUp(self): self.device = DEVICE_TYPES.keys()[0] self.cat = Category.objects.create(name='c', type=amo.ADDON_WEBAPP) self.webapp = Webapp.objects.create(type=amo.ADDON_WEBAPP, status=amo.STATUS_NULL)
def setUp(self): self.device = DEVICE_TYPES.keys()[0]
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])