Beispiel #1
0
    def test_app_categories(self):
        addon = lambda: Addon.objects.get(pk=3615)

        c22 = Category.objects.get(id=22)
        c22.name = 'CCC'
        c22.save()
        c23 = Category.objects.get(id=23)
        c23.name = 'BBB'
        c23.save()
        c24 = Category.objects.get(id=24)
        c24.name = 'AAA'
        c24.save()

        cats = addon().all_categories
        eq_(cats, [c22, c23, c24])
        for cat in cats:
            eq_(cat.application.id, amo.FIREFOX.id)

        cats = [c24, c23, c22]
        app_cats = [(amo.FIREFOX, cats)]
        eq_(addon().app_categories, app_cats)

        tb = Application.objects.get(id=amo.THUNDERBIRD.id)
        c = Category(application=tb, name='XXX', type=addon().type, count=1,
                     weight=1)
        c.save()
        AddonCategory.objects.create(addon=addon(), category=c)
        c24.save()  # Clear the app_categories cache.
        app_cats += [(amo.THUNDERBIRD, [c])]
        eq_(addon().app_categories, app_cats)
Beispiel #2
0
    def test_personas_category_landing(self):
        """Ensure we hit a grid page if there's a category and no sorting."""
        grid = 'browse/personas/grid.html'
        landing = 'browse/personas/category_landing.html'

        category = Category(type=amo.ADDON_PERSONA, slug='abc',
            application=Application.objects.get(id=amo.FIREFOX.id))
        category.save()
        category_url = reverse('browse.personas', args=[category.slug])

        r = self.client.get(category_url + '?sort=created')
        self.assertTemplateUsed(r, grid)

        r = self.client.get(category_url)
        self.assertTemplateUsed(r, grid)

        # Category with 5 add-ons should bring us to a landing page.
        category.count = 5
        category.save()
        r = self.client.get(category_url)
        self.assertTemplateUsed(r, landing)
Beispiel #3
0
    def test_personas_grid(self):
        """Ensure we always hit a grid page if there's a category."""
        grid = 'browse/personas/mobile/grid.html'

        category = Category(type=amo.ADDON_PERSONA, slug='xxx',
                            application_id=amo.FIREFOX.id)
        category.save()
        category_url = reverse('browse.personas', args=[category.slug])

        # Show the grid page even with sorting.
        r = self.client.get('%s?sort=created' % category_url)
        self.assertTemplateUsed(r, grid)

        r = self.client.get(category_url)
        self.assertTemplateUsed(r, grid)

        # Even if the category has 5 add-ons.
        category.count = 5
        category.save()
        r = self.client.get(category_url)
        self.assertTemplateUsed(r, grid)
Beispiel #4
0
 def _create_persona_cat(self):
     category = Category(type=amo.ADDON_PERSONA, slug='xxx',
                         application_id=amo.FIREFOX.id)
     category.save()
     return category