Пример #1
0
    def test_queryset_visible_banners(self):
        parent = CategoryFactory.create()
        categories = CategoryFactory.create_batch(5, parent=parent)
        category1, category2, category3, category4, category5 = categories

        # category1 has a visible ImageBanner
        ImageBannerFactory.create(category=category1, visible=True)
        TextBannerFactory.create(category=category1, visible=False)
        FirefoxUpgradeBannerFactory.create(category=category1, visible=False)

        # category2 has a visible TextBanner
        ImageBannerFactory.create(category=category2, visible=False)
        TextBannerFactory.create(category=category2, visible=True)
        FirefoxUpgradeBannerFactory.create(category=category2, visible=False)

        # category3 has a visible FirefoxUpgradeBanner
        ImageBannerFactory.create(category=category3, visible=False)
        TextBannerFactory.create(category=category3, visible=False)
        FirefoxUpgradeBannerFactory.create(category=category3, visible=True)

        # category4 has no visible banners
        ImageBannerFactory.create(category=category4, visible=False)
        TextBannerFactory.create(category=category4, visible=False)
        FirefoxUpgradeBannerFactory.create(category=category4, visible=False)

        # category5 has no banners.
        eq_(set(Category.objects.with_visible_banners()), set([category1, category2, category3]))
Пример #2
0
    def test_get_queryset_visible_banners(self):
        """
        get_queryset should return a queryset with only categories that
        have visible banners.
        """
        parent = CategoryFactory.create()
        category1, category2, category3, category4 = CategoryFactory.create_batch(
            4, parent=parent)

        # category1 has a visible ImageBanner
        ImageBannerFactory.create(category=category1, visible=True)
        TextBannerFactory.create(category=category1, visible=False)
        FirefoxUpgradeBannerFactory.create(category=category1, visible=False)

        # category2 has a visible TextBanner
        ImageBannerFactory.create(category=category2, visible=False)
        TextBannerFactory.create(category=category2, visible=True)
        FirefoxUpgradeBannerFactory.create(category=category2, visible=False)

        # category3 has a visible FirefoxUpgradeBanner
        ImageBannerFactory.create(category=category3, visible=False)
        TextBannerFactory.create(category=category3, visible=False)
        FirefoxUpgradeBannerFactory.create(category=category3, visible=True)

        # category4 has no visible banners
        ImageBannerFactory.create(category=category4, visible=False)
        TextBannerFactory.create(category=category4, visible=False)
        FirefoxUpgradeBannerFactory.create(category=category4, visible=False)

        eq_(set(self.view.get_queryset()),
            set([category1, category2, category3]))
Пример #3
0
    def test_get_queryset_visible_banners(self):
        """
        get_queryset should return a queryset with only categories that
        have visible banners.
        """
        parent = CategoryFactory.create()
        category1, category2, category3, category4 = CategoryFactory.create_batch(4, parent=parent)

        # category1 has a visible ImageBanner
        ImageBannerFactory.create(category=category1, visible=True)
        TextBannerFactory.create(category=category1, visible=False)
        FirefoxUpgradeBannerFactory.create(category=category1, visible=False)

        # category2 has a visible TextBanner
        ImageBannerFactory.create(category=category2, visible=False)
        TextBannerFactory.create(category=category2, visible=True)
        FirefoxUpgradeBannerFactory.create(category=category2, visible=False)

        # category3 has a visible FirefoxUpgradeBanner
        ImageBannerFactory.create(category=category3, visible=False)
        TextBannerFactory.create(category=category3, visible=False)
        FirefoxUpgradeBannerFactory.create(category=category3, visible=True)

        # category4 has no visible banners
        ImageBannerFactory.create(category=category4, visible=False)
        TextBannerFactory.create(category=category4, visible=False)
        FirefoxUpgradeBannerFactory.create(category=category4, visible=False)

        eq_(set(self.view.get_queryset()), set([category1, category2, category3]))