示例#1
0
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
示例#2
0
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
示例#3
0
文件: helpers.py 项目: AALEKH/zamboni
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
0
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
示例#5
0
 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
0
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()
            }))
示例#7
0
    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])
示例#8
0
    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])
示例#9
0
    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.')
示例#10
0
    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.')
示例#11
0
    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)
示例#12
0
    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)

        # Associate category with app.
        self.cat1 = Category.objects.create(type=amo.ADDON_WEBAPP, name='Fun')
        AddonCategory.objects.create(addon=self.webapp, category=self.cat1)
示例#13
0
    def _step(self):
        #self.user.update(read_dev_agreement=datetime.datetime.now())
        self.user.update(read_dev_agreement=True)
        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)

        # Associate category with app.
        self.cat1 = Category.objects.create(type=amo.ADDON_WEBAPP, name='Fun')
        AddonCategory.objects.create(addon=self.webapp, category=self.cat1)

        # Create initial formset for categories.
        ctx = self.client.get(self.url).context['form_cats']
        self.cat_initial = amo.tests.initial(ctx.initial_forms[0])
示例#14
0
 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)
示例#15
0
 def setUp(self):
     self.device = DEVICE_TYPES.keys()[0]
示例#16
0
 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)
示例#17
0
 def setUp(self):
     self.device = DEVICE_TYPES.keys()[0]
示例#18
0
 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}
示例#19
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])
示例#20
0
 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}
示例#21
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])