def test_platform_filter(self): platform, _ = Platform.objects.get_or_create(pk=amo.PLATFORM_WIN.id) file = self.addon1.current_version.files.all()[0] file.update(platform=platform) addons = addon_filter( **self._defaults(platform=amo.PLATFORM_LINUX.shortname)) eq_(addons, [self.addon2])
def get_addons(self): addons = self.collection.addons.filter(status=amo.STATUS_PUBLIC) kw = dict(addon_type='ALL', limit=self.limit, app=self.request.APP, platform=self.platform, version=self.version, compat_mode=self.compat_mode) f = lambda: addon_filter(addons, **kw) return caching.cached_with(addons, f, repr(kw))
def test_version_filter_normal_binary_components(self): # Ensure we filter out strict opt-in addons in normal mode. addon3 = addon_factory(version_kw=dict(max_app_version='7.0'), file_kw=dict(binary_components=True)) addons = self.addons + [addon3] addons = addon_filter(**self._defaults(addons=addons, version='11.0', compat_mode='normal')) eq_(addons, self.addons)
def test_version_version_less_than_min(self): # Ensure we filter out addons with a higher min than our app. addon3 = addon_factory(version_kw=dict(min_app_version='12.0', max_app_version='14.0')) addons = self.addons + [addon3] addons = addon_filter(**self._defaults(addons=addons, version='11.0', compat_mode='ignore')) eq_(addons, self.addons)
def get_addons(self): addons = self.collection.addons.all() kw = dict(addon_type='ALL', limit=self.limit, app=self.request.APP, platform=self.platform, version=self.version, shuffle=True) f = lambda: addon_filter(addons, **kw) return caching.cached_with(addons, f, repr(kw))
def test_locale_preferencing(self): # Add-ons matching the current locale get prioritized. addon3 = addon_factory() addon3.description = {'de': 'Unst Unst'} addon3.save() addons = self.addons + [addon3] translation.activate('de') addons = addon_filter(**self._defaults(addons=addons)) eq_(addons, [addon3] + self.addons) translation.deactivate()
def test_version_filter_normal_compat_override(self): # Ensure we filter out strict opt-in addons in normal mode. addon3 = addon_factory() addons = self.addons + [addon3] # Add override for this add-on. compat = CompatOverride.objects.create(guid='three', addon=addon3) CompatOverrideRange.objects.create( compat=compat, app=Application.objects.get(pk=1), min_version=addon3.current_version.version, max_version='*') addons = addon_filter(**self._defaults(addons=addons, version='11.0', compat_mode='normal')) eq_(addons, self.addons)
def test_version_filter_ignore(self): addons = addon_filter(**self._defaults(version="6.0", compat_mode="ignore")) eq_(addons, self.addons)
def test_basic(self): addons = addon_filter(**self._defaults()) eq_(addons, self.addons)
def get_addons(self): addons = self.collection.addons.all() kw = dict(addon_type='ALL', limit=6, app=self.request.APP, platform=self.platform, version=self.version, shuffle=True) return addon_filter(addons, **kw)
def f(): return addon_filter(addons, **kw)
def test_version_filter_normal_strict_opt_in(self): # Ensure we filter out strict opt-in addons in normal mode. addon3 = addon_factory(version_kw=dict(max_app_version="7.0"), file_kw=dict(strict_compatibility=True)) addons = self.addons + [addon3] addons = addon_filter(**self._defaults(addons=addons, version="11.0", compat_mode="normal")) eq_(addons, self.addons)
def test_version_filter_ignore(self): addons = addon_filter(**self._defaults(version='6.0', compat_mode='ignore')) eq_(addons, self.addons)
def test_version_filter_strict(self): addons = addon_filter(**self._defaults(version='6.0')) eq_(addons, [self.addon2])
def test_limit(self): addons = addon_filter(**self._defaults(limit=1)) eq_(addons, [self.addon1])
def test_app_filter(self): self.addon1.update(type=amo.ADDON_DICT) addons = addon_filter( **self._defaults(addon_type=str(amo.ADDON_EXTENSION))) eq_(addons, [self.addon2])