def test_by_category_app(self): # Add an addon to the same category, but in a featured collection # for a different app: it should not be returned. extra_addon = addon_factory(category=Category.objects.get( pk=self.category_id)) collection = collection_factory() collection.add_addon(extra_addon) FeaturedCollection.objects.create(application=amo.ANDROID.id, collection=collection) assert set(get_creatured_ids(self.category_id, None)) == (set(self.no_locale))
def test_by_category_app(self): # Add an addon to the same category, but in a featured collection # for a different app: it should not be returned. extra_addon = addon_factory() extra_addon.addoncategory_set.create(category_id=self.category) collection = collection_factory() collection.add_addon(extra_addon) FeaturedCollection.objects.create( application=amo.THUNDERBIRD.id, collection=collection) assert set(get_creatured_ids(self.category, None)) == ( set(self.no_locale))
def test_by_category_app_and_locale(self): # Add an addon to the same category and locale, but in a featured # collection for a different app: it should not be returned. extra_addon = addon_factory() extra_addon.addoncategory_set.create(category_id=self.category) collection = collection_factory() collection.add_addon(extra_addon) FeaturedCollection.objects.create( application=amo.THUNDERBIRD.id, collection=collection, locale='en-US') assert set(get_creatured_ids(self.category, 'en-US')) == ( set(self.no_locale + self.en_us_locale))
def test_by_category_app_and_locale(self): # Add an addon to the same category and locale, but in a featured # collection for a different app: it should not be returned. extra_addon = addon_factory( category=Category.objects.get(pk=self.category_id)) collection = collection_factory() collection.add_addon(extra_addon) FeaturedCollection.objects.create( application=amo.ANDROID.id, collection=collection, locale='en-US') assert set(get_creatured_ids(self.category_id, 'en-US')) == ( set(self.no_locale + self.en_us_locale))
def filter_featured(self): # Featured search add-ons in all locales: APP, LANG = self.request.APP, self.request.LANG ids = get_featured_ids(APP, LANG, amo.ADDON_SEARCH) try: search_cat = Category.objects.get(slug='search-tools', application=APP.id) others = get_creatured_ids(search_cat, LANG) ids.extend(o for o in others if o not in ids) except Category.DoesNotExist: pass return manual_order(Addon.objects.valid(), ids, 'addons.id')
def test_by_locale(self): assert set(get_creatured_ids(self.category_id, 'en-US')) == (set(self.no_locale + self.en_us_locale))
def test_shuffle(self): ids = get_creatured_ids(self.category, 'en-US') eq_((ids[0], ), self.en_us_locale)
def test_by_category_id(self): assert set(get_creatured_ids(self.category_id, None)) == (set(self.no_locale))
def test_by_category_dynamic(self): category = Category.objects.get(pk=self.category_id) assert set(get_creatured_ids(category, None)) == (set(self.no_locale))
def test_by_category_static(self): category = CATEGORIES_BY_ID[self.category_id] assert set(get_creatured_ids(category, None)) == (set(self.no_locale))
def test_by_locale(self): assert set(get_creatured_ids(self.category, 'en-US')) == ( set(self.no_locale + self.en_us_locale))
def test_by_locale(self): eq_(set(get_creatured_ids(self.category, 'en-US')), set(self.no_locale + self.en_us_locale))
def test_by_category_id(self): assert set(get_creatured_ids(self.category, None)) == ( set(self.no_locale))
def test_by_category_dynamic(self): category = Category.objects.get(pk=self.category) assert set(get_creatured_ids(category, None)) == ( set(self.no_locale))
def test_by_category_static(self): category = CATEGORIES_BY_ID[self.category] assert set(get_creatured_ids(category, None)) == ( set(self.no_locale))
def test_shuffle(self): ids = get_creatured_ids(self.category, 'en-US') assert (ids[0],) == self.en_us_locale
def test_shuffle(self): ids = get_creatured_ids(self.category_id, 'en-US') assert (ids[0], ) == self.en_us_locale
def test_by_category(self): eq_(set(get_creatured_ids(self.category, None)), set(self.no_locale))
def test_shuffle(self): ids = get_creatured_ids(self.category, 'en-US') eq_((ids[0],), self.en_us_locale)