Remove NEW_FEATURES
This commit is contained in:
Родитель
f430555f9c
Коммит
657e0d7c5d
|
@ -230,6 +230,7 @@ class CategoryForm(forms.Form):
|
|||
categories = self.cleaned_data['categories']
|
||||
total = categories.count()
|
||||
max_cat = amo.MAX_CATEGORIES
|
||||
|
||||
if getattr(self, 'disabled', False) and total:
|
||||
if categories[0].type == amo.ADDON_WEBAPP:
|
||||
raise forms.ValidationError(loc('Categories cannot be changed '
|
||||
|
@ -296,8 +297,7 @@ class BaseCategoryFormSet(BaseFormSet):
|
|||
# If this add-on is featured for this application, category
|
||||
# changes are forbidden.
|
||||
if not acl.action_allowed(self.request, 'Admin', 'EditAnyAddon'):
|
||||
form.disabled = (settings.NEW_FEATURES and app and
|
||||
self.addon.is_featured(app))
|
||||
form.disabled = (app and self.addon.is_featured(app))
|
||||
|
||||
def save(self):
|
||||
for f in self.forms:
|
||||
|
|
|
@ -50,18 +50,7 @@ class TestAddonManager(amo.tests.TestCase):
|
|||
def setUp(self):
|
||||
set_user(None)
|
||||
|
||||
@patch.object(settings, 'NEW_FEATURES', False)
|
||||
def test_featured(self):
|
||||
eq_(Addon.objects.featured(amo.FIREFOX).count(),
|
||||
Addon.objects.listed(amo.FIREFOX)
|
||||
.filter(feature__application=amo.FIREFOX.id).count())
|
||||
|
||||
@patch.object(settings, 'NEW_FEATURES', True)
|
||||
def test_new_featured(self):
|
||||
# TODO: remove this when NEW_FEATURES goes away. It's here because
|
||||
# build() was already called in setUp().
|
||||
from addons.cron import reset_featured_addons
|
||||
reset_featured_addons()
|
||||
eq_(Addon.objects.featured(amo.FIREFOX).count(), 3)
|
||||
|
||||
def test_listed(self):
|
||||
|
@ -169,13 +158,6 @@ class TestAddonManager(amo.tests.TestCase):
|
|||
sorted(addons, key=lambda x: x.weekly_downloads, reverse=True))
|
||||
eq_(list(Addon.objects.top_paid(amo.THUNDERBIRD, listed=False)), [])
|
||||
|
||||
|
||||
class TestAddonManagerFeatured(amo.tests.TestCase):
|
||||
# TODO(cvan): Merge with above once new featured add-ons are enabled.
|
||||
fixtures = ['addons/featured', 'bandwagon/featured_collections',
|
||||
'base/collections', 'base/featured']
|
||||
|
||||
@patch.object(settings, 'NEW_FEATURES', True)
|
||||
def test_new_featured(self):
|
||||
f = Addon.objects.featured(amo.FIREFOX)
|
||||
eq_(f.count(), 3)
|
||||
|
@ -277,25 +259,6 @@ class TestAddonModels(amo.tests.TestCase):
|
|||
a = Addon.objects.get(pk=5299)
|
||||
eq_(a.current_beta_version.id, 50000)
|
||||
|
||||
@patch.object(settings, 'NEW_FEATURES', False)
|
||||
def test_current_version_mixed_statuses(self):
|
||||
"""Mixed file statuses are evil (bug 558237)."""
|
||||
a = Addon.objects.get(pk=3895)
|
||||
# Last version has pending files, so second to last version is
|
||||
# considered "current".
|
||||
eq_(a.current_version.id, 78829)
|
||||
|
||||
# Fix file statuses on last version.
|
||||
v = Version.objects.get(pk=98217)
|
||||
v.files.update(status=amo.STATUS_PUBLIC)
|
||||
|
||||
# Wipe caches.
|
||||
cache.clear()
|
||||
a.update_version()
|
||||
|
||||
# Make sure the updated version is now considered current.
|
||||
eq_(a.current_version.id, v.id)
|
||||
|
||||
def test_delete(self):
|
||||
"""Test deleting add-ons."""
|
||||
a = Addon.objects.get(pk=3615)
|
||||
|
@ -1210,14 +1173,9 @@ class TestAddonModelsFeatured(amo.tests.TestCase):
|
|||
f = Addon.featured_random(amo.SUNBIRD, 'en-US')
|
||||
eq_(f, [])
|
||||
|
||||
@patch.object(settings, 'NEW_FEATURES', False)
|
||||
def test_featured_random(self):
|
||||
self._test_featured_random()
|
||||
|
||||
@patch.object(settings, 'NEW_FEATURES', True)
|
||||
def test_new_featured_random(self):
|
||||
self._test_featured_random()
|
||||
|
||||
|
||||
class TestBackupVersion(amo.tests.TestCase):
|
||||
fixtures = ['addons/update']
|
||||
|
|
|
@ -1841,14 +1841,9 @@ class TestMobileHome(TestMobile):
|
|||
[a.id for a in sorted(popular, key=lambda x: x.average_daily_users,
|
||||
reverse=True)])
|
||||
|
||||
@patch.object(settings, 'NEW_FEATURES', False)
|
||||
def test_addons(self):
|
||||
self._test_addons()
|
||||
|
||||
@patch.object(settings, 'NEW_FEATURES', True)
|
||||
def test_new_addons(self):
|
||||
self._test_addons()
|
||||
|
||||
|
||||
class TestMobileDetails(TestMobile):
|
||||
fixtures = TestMobile.fixtures + ['base/featured']
|
||||
|
|
|
@ -118,18 +118,12 @@ class FeaturedManager(object):
|
|||
@classmethod
|
||||
def _get_objects(cls):
|
||||
fields = ['addon', 'type', 'locale', 'application']
|
||||
if settings.NEW_FEATURES:
|
||||
from bandwagon.models import FeaturedCollection
|
||||
vals = (FeaturedCollection.objects
|
||||
.filter(collection__addons__isnull=False)
|
||||
.values_list('collection__addons',
|
||||
'collection__addons__type', 'locale',
|
||||
'application'))
|
||||
else:
|
||||
from addons.models import Addon
|
||||
vals = (Addon.objects.valid().filter(feature__isnull=False)
|
||||
.values_list('id', 'type', 'feature__locale',
|
||||
'feature__application'))
|
||||
from bandwagon.models import FeaturedCollection
|
||||
vals = (FeaturedCollection.objects
|
||||
.filter(collection__addons__isnull=False)
|
||||
.values_list('collection__addons',
|
||||
'collection__addons__type', 'locale',
|
||||
'application'))
|
||||
return [dict(zip(fields, val)) for val in vals]
|
||||
|
||||
@classmethod
|
||||
|
@ -207,18 +201,12 @@ class CreaturedManager(object):
|
|||
@classmethod
|
||||
def _get_objects(cls):
|
||||
fields = ['category', 'addon', 'locales', 'app']
|
||||
if settings.NEW_FEATURES:
|
||||
from bandwagon.models import FeaturedCollection
|
||||
vals = (FeaturedCollection.objects
|
||||
.filter(collection__addons__isnull=False)
|
||||
.values_list('collection__addons__category',
|
||||
'collection__addons', 'locale',
|
||||
'application'))
|
||||
else:
|
||||
from addons.models import AddonCategory
|
||||
vals = (AddonCategory.objects.filter(feature=True)
|
||||
.values_list('category', 'addon', 'feature_locales',
|
||||
'category__application'))
|
||||
from bandwagon.models import FeaturedCollection
|
||||
vals = (FeaturedCollection.objects
|
||||
.filter(collection__addons__isnull=False)
|
||||
.values_list('collection__addons__category',
|
||||
'collection__addons', 'locale',
|
||||
'application'))
|
||||
return [dict(zip(fields, val)) for val in vals]
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -149,11 +149,6 @@ class APITest(TestCase):
|
|||
fixtures = ['base/apps', 'base/addon_3615', 'base/addon_4664_twitterbar',
|
||||
'base/addon_5299_gcal', 'perf/index']
|
||||
|
||||
def setUp(self):
|
||||
patcher = patch.object(settings, 'NEW_FEATURES', False)
|
||||
patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
|
||||
def test_api_caching(self):
|
||||
response = self.client.get('/en-US/firefox/api/1.5/addon/3615')
|
||||
eq_(response.status_code, 200)
|
||||
|
@ -470,25 +465,7 @@ class APITest(TestCase):
|
|||
'<slug>%s</slug>' %
|
||||
Addon.objects.get(pk=5299).slug)
|
||||
|
||||
@patch.object(settings, 'NEW_FEATURES', False)
|
||||
def test_is_featured(self):
|
||||
self.assertContains(make_call('addon/5299', version=1.5),
|
||||
'<featured>0</featured>')
|
||||
Feature.objects.create(addon_id=5299,
|
||||
start=datetime.now() - timedelta(days=10),
|
||||
end=datetime.now() + timedelta(days=10),
|
||||
application_id=amo.FIREFOX.id,
|
||||
locale='ja')
|
||||
reset_featured_addons()
|
||||
for lang, app, result in [('ja', 'firefox', 1),
|
||||
('en-US', 'firefox', 0),
|
||||
('ja', 'seamonkey', 0)]:
|
||||
self.assertContains(make_call('addon/5299', version=1.5,
|
||||
lang=lang, app=app),
|
||||
'<featured>%s</featured>' % result)
|
||||
|
||||
@patch.object(settings, 'NEW_FEATURES', True)
|
||||
def test_new_is_featured(self):
|
||||
self.assertContains(make_call('addon/5299', version=1.5),
|
||||
'<featured>0</featured>')
|
||||
c = CollectionAddon.objects.create(
|
||||
|
@ -555,13 +532,9 @@ class APITest(TestCase):
|
|||
|
||||
class ListTest(TestCase):
|
||||
"""Tests the list view with various urls."""
|
||||
fixtures = ['base/apps', 'base/addon_3615', 'base/featured']
|
||||
|
||||
def setUp(self):
|
||||
# TODO(cvan): Remove this once featured collections are enabled.
|
||||
patcher = patch.object(settings, 'NEW_FEATURES', False)
|
||||
patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
fixtures = ['base/apps', 'base/addon_3615', 'base/featured',
|
||||
'addons/featured', 'bandwagon/featured_collections',
|
||||
'base/collections']
|
||||
|
||||
def test_defaults(self):
|
||||
"""
|
||||
|
@ -610,6 +583,7 @@ class ListTest(TestCase):
|
|||
self.assertContains(response, "<addon id", 3)
|
||||
|
||||
response = make_call('list', lang='he')
|
||||
|
||||
self.assertContains(response, "<addon id", 3)
|
||||
|
||||
def test_browser_featured_list(self):
|
||||
|
@ -649,19 +623,6 @@ class ListTest(TestCase):
|
|||
make_call(u'list/featured/all/10/Linux/3.7a2prexec\xb6\u0153\xec\xb2')
|
||||
|
||||
|
||||
class NewListTest(ListTest):
|
||||
"""Tests the list view with various urls."""
|
||||
fixtures = ListTest.fixtures + ['addons/featured',
|
||||
'bandwagon/featured_collections',
|
||||
'base/collections']
|
||||
|
||||
def setUp(self):
|
||||
# TODO(cvan): Remove this once featured collections are enabled.
|
||||
patcher = patch.object(settings, 'NEW_FEATURES', True)
|
||||
patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
|
||||
|
||||
class SeamonkeyFeaturedTest(TestCase):
|
||||
fixtures = ['base/seamonkey']
|
||||
|
||||
|
|
|
@ -381,94 +381,6 @@ class TestThemes(amo.tests.TestCase):
|
|||
eq_(doc('#side-categories #c-%s' % id).length, 1)
|
||||
|
||||
|
||||
class TestCategoryPages(amo.tests.TestCase):
|
||||
fixtures = ['base/apps', 'base/category', 'base/addon_3615',
|
||||
'base/featured', 'addons/featured', 'browse/nameless-addon']
|
||||
|
||||
def setUp(self):
|
||||
patcher = mock.patch.object(settings, 'NEW_FEATURES', False)
|
||||
patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
|
||||
def test_browsing_urls(self):
|
||||
"""Every browse page URL exists."""
|
||||
for _, slug in amo.ADDON_SLUGS.items():
|
||||
view = 'apps.list' if slug == 'apps' else 'browse.%s' % slug
|
||||
assert reverse(view)
|
||||
|
||||
def test_matching_opts(self):
|
||||
"""Every filter on landing pages is available on listing pages."""
|
||||
for key, _ in views.CategoryLandingFilter.opts:
|
||||
if key != 'featured':
|
||||
assert key in dict(views.AddonFilter.opts)
|
||||
|
||||
@mock.patch('browse.views.category_landing')
|
||||
def test_goto_category_landing(self, landing_mock):
|
||||
"""We hit a landing page if there's a category and no sorting."""
|
||||
landing_mock.return_value = http.HttpResponse()
|
||||
|
||||
self.client.get(reverse('browse.extensions'))
|
||||
assert not landing_mock.called
|
||||
|
||||
category = Category.objects.all()[0]
|
||||
category_url = reverse('browse.extensions', args=[category.slug])
|
||||
|
||||
self.client.get('%s?sort=created' % category_url)
|
||||
assert not landing_mock.called
|
||||
|
||||
self.client.get(category_url)
|
||||
assert landing_mock.called
|
||||
|
||||
# Category with fewer than 5 add-ons bypasses landing page.
|
||||
category.count = 4
|
||||
category.save()
|
||||
self.client.get(category_url)
|
||||
eq_(landing_mock.call_count, 1)
|
||||
|
||||
def test_creatured_addons(self):
|
||||
"""Make sure the creatured add-ons are for the right category."""
|
||||
# Featured in bookmarks.
|
||||
url = reverse('browse.extensions', args=['bookmarks'])
|
||||
response = self.client.get(url, follow=True)
|
||||
creatured = response.context['filter'].all()['featured']
|
||||
eq_(len(creatured), 1)
|
||||
eq_(creatured[0].id, 3615)
|
||||
|
||||
# Not featured in search-tools.
|
||||
url = reverse('browse.extensions', args=['search-tools'])
|
||||
response = self.client.get(url, follow=True)
|
||||
creatured = response.context['filter'].all()['featured']
|
||||
eq_(len(creatured), 0)
|
||||
|
||||
def test_creatured_only_public(self):
|
||||
"""Make sure the creatured add-ons are all public."""
|
||||
url = reverse('browse.creatured', args=['bookmarks'])
|
||||
r = self.client.get(url, follow=True)
|
||||
addons = r.context['addons']
|
||||
|
||||
for a in addons:
|
||||
assert a.status == amo.STATUS_PUBLIC, "%s is not public" % a.name
|
||||
|
||||
old_count = len(addons)
|
||||
addons[0].status = amo.STATUS_UNREVIEWED
|
||||
addons[0].save()
|
||||
r = self.client.get(url, follow=True)
|
||||
addons = r.context['addons']
|
||||
|
||||
for a in addons:
|
||||
assert a.status == amo.STATUS_PUBLIC, ("Altered %s is featured"
|
||||
% a.name)
|
||||
|
||||
eq_(len(addons), old_count - 1, "The number of addons is the same.")
|
||||
|
||||
def test_sorting_nameless(self):
|
||||
"""Nameless add-ons are dropped from the sort."""
|
||||
qs = Addon.objects.all()
|
||||
ids = order_by_translation(qs, 'name')
|
||||
assert 57132 in [a.id for a in qs]
|
||||
assert 57132 not in [a.id for a in ids]
|
||||
|
||||
|
||||
class TestFeeds(amo.tests.TestCase):
|
||||
fixtures = ['base/apps', 'base/category', 'base/featured',
|
||||
'addons/featured', 'addons/listed', 'base/collections',
|
||||
|
@ -536,33 +448,21 @@ class TestFeeds(amo.tests.TestCase):
|
|||
|
||||
class TestFeaturedLocale(amo.tests.TestCase):
|
||||
fixtures = ['base/apps', 'base/category', 'base/addon_3615',
|
||||
'base/featured', 'addons/featured', 'browse/nameless-addon']
|
||||
'base/featured', 'addons/featured', 'browse/nameless-addon',
|
||||
'base/collections', 'bandwagon/featured_collections',
|
||||
'base/addon_3615_featuredcollection']
|
||||
|
||||
def setUp(self):
|
||||
patcher = mock.patch.object(settings, 'NEW_FEATURES', False)
|
||||
patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
|
||||
self.addon = Addon.objects.get(pk=3615)
|
||||
self.persona = Addon.objects.get(pk=15679)
|
||||
self.extension = Addon.objects.get(pk=2464)
|
||||
self.category = Category.objects.get(slug='bookmarks')
|
||||
|
||||
self.reset_featured_addons()
|
||||
|
||||
self.url = reverse('browse.creatured', args=['bookmarks'])
|
||||
cache.clear()
|
||||
|
||||
def change_addoncategory(self, addon, locale='es-ES'):
|
||||
ac = addon.addoncategory_set.all()[0]
|
||||
ac.feature_locales = locale
|
||||
ac.save()
|
||||
self.reset()
|
||||
|
||||
def change_addon(self, addon, locale='es-ES'):
|
||||
feature = addon.feature_set.all()[0]
|
||||
feature.locale = locale
|
||||
feature.save()
|
||||
self.reset()
|
||||
|
||||
def reset(self):
|
||||
cache.clear()
|
||||
FeaturedManager.redis().flushall()
|
||||
|
@ -581,24 +481,15 @@ class TestFeaturedLocale(amo.tests.TestCase):
|
|||
if mtch:
|
||||
print mtch.group(2)
|
||||
|
||||
def test_creatured_random_caching(self):
|
||||
rnd = AddonCategory.creatured_random
|
||||
cat = Category.objects.get(pk=22)
|
||||
self.assertNumQueries(0, rnd, cat, 'en-US')
|
||||
self.assertNumQueries(0, rnd, cat, 'en-US')
|
||||
self.assertNumQueries(0, rnd, cat, 'es-ES')
|
||||
|
||||
def test_featured_random_caching(self):
|
||||
rnd = Addon.featured_random
|
||||
self.assertNumQueries(0, rnd, amo.FIREFOX, 'en-US')
|
||||
self.assertNumQueries(0, rnd, amo.FIREFOX, 'es-ES')
|
||||
self.assertNumQueries(0, rnd, amo.THUNDERBIRD, 'es-ES')
|
||||
self.assertNumQueries(0, rnd, amo.THUNDERBIRD, 'en-US')
|
||||
|
||||
def test_creatured_locale_en_US(self):
|
||||
res = self.client.get(self.url)
|
||||
assert self.addon in res.context['addons']
|
||||
|
||||
def test_creatured_locale_es_ES(self):
|
||||
"""Ensure 'en-US'-creatured add-ons do not exist for other locales."""
|
||||
res = self.client.get(self.url.replace('en-US', 'es-ES'))
|
||||
assert self.addon not in res.context['addons']
|
||||
|
||||
def test_creatured_locale_nones(self):
|
||||
self.change_addoncategory(self.addon, '')
|
||||
res = self.client.get(self.url)
|
||||
|
@ -621,10 +512,6 @@ class TestFeaturedLocale(amo.tests.TestCase):
|
|||
res = self.client.get(self.url)
|
||||
assert self.addon not in res.context['addons']
|
||||
|
||||
def test_creatured_locale_es_ES(self):
|
||||
res = self.client.get(self.url.replace('en-US', 'es-ES'))
|
||||
assert self.addon in res.context['addons']
|
||||
|
||||
def test_featured_locale_en_US(self):
|
||||
res = self.client.get(reverse('browse.extensions') + '?sort=featured')
|
||||
assert self.extension in res.context['addons']
|
||||
|
@ -725,6 +612,8 @@ class TestFeaturedLocale(amo.tests.TestCase):
|
|||
eq_(listed.count(7661), 1)
|
||||
|
||||
def test_homepage_order(self):
|
||||
FeaturedCollection.objects.filter(collection__addons=3615)[0].delete()
|
||||
|
||||
# Make these apps listed.
|
||||
for pk in [1003, 3481]:
|
||||
addon = Addon.objects.get(pk=pk)
|
||||
|
@ -757,6 +646,8 @@ class TestFeaturedLocale(amo.tests.TestCase):
|
|||
eq_([1003, 2464, 7661], sorted([i.pk for i in items]))
|
||||
|
||||
def test_featured_ids(self):
|
||||
FeaturedCollection.objects.filter(collection__addons=3615)[0].delete()
|
||||
|
||||
another = Addon.objects.get(id=1003)
|
||||
self.change_addon(another, 'en-US')
|
||||
items = Addon.featured_random(amo.FIREFOX, 'en-US')
|
||||
|
@ -774,27 +665,6 @@ class TestFeaturedLocale(amo.tests.TestCase):
|
|||
end=datetime.today())
|
||||
eq_(Addon.featured_random(amo.FIREFOX, 'en-US').count(1003), 1)
|
||||
|
||||
|
||||
class TestNewFeaturedLocale(TestFeaturedLocale):
|
||||
fixtures = (TestFeaturedLocale.fixtures +
|
||||
['base/collections', 'addons/featured', 'base/featured',
|
||||
'bandwagon/featured_collections',
|
||||
'base/addon_3615_featuredcollection'])
|
||||
|
||||
# TODO(cvan): Merge with above once new featured add-ons are enabled.
|
||||
def setUp(self):
|
||||
super(TestNewFeaturedLocale, self).setUp()
|
||||
patcher = mock.patch.object(settings, 'NEW_FEATURES', True)
|
||||
patcher.start()
|
||||
self.reset_featured_addons()
|
||||
self.addCleanup(patcher.stop)
|
||||
|
||||
def test_featured_random_caching(self):
|
||||
raise SkipTest() # We're no longer caching `featured_random`.
|
||||
|
||||
def test_creatured_random_caching(self):
|
||||
raise SkipTest() # We're no longer caching `creatured_random`.
|
||||
|
||||
def change_addon(self, addon, locale='es-ES'):
|
||||
fc = FeaturedCollection.objects.filter(collection__addons=addon.id)[0]
|
||||
feature = FeaturedCollection.objects.create(locale=locale,
|
||||
|
@ -817,23 +687,6 @@ class TestNewFeaturedLocale(TestFeaturedLocale):
|
|||
collection=c.collection)
|
||||
self.reset()
|
||||
|
||||
def test_featured_ids(self):
|
||||
# TODO(cvan): Change the TestFeaturedLocale test
|
||||
# accordingly after we switch over to the new features.
|
||||
FeaturedCollection.objects.filter(collection__addons=3615)[0].delete()
|
||||
super(TestNewFeaturedLocale, self).test_featured_ids()
|
||||
|
||||
def test_homepage_order(self):
|
||||
# TODO(cvan): Change the TestFeaturedLocale test
|
||||
# accordingly after we switch over to the new features.
|
||||
FeaturedCollection.objects.filter(collection__addons=3615)[0].delete()
|
||||
super(TestNewFeaturedLocale, self).test_homepage_order()
|
||||
|
||||
def test_creatured_locale_es_ES(self):
|
||||
"""Ensure 'en-US'-creatured add-ons do not exist for other locales."""
|
||||
res = self.client.get(self.url.replace('en-US', 'es-ES'))
|
||||
assert self.addon not in res.context['addons']
|
||||
|
||||
|
||||
class TestListingByStatus(amo.tests.TestCase):
|
||||
fixtures = ['base/apps', 'base/addon_3615']
|
||||
|
@ -1188,22 +1041,6 @@ class TestLegacyRedirects(amo.tests.TestCase):
|
|||
redirects('/recommended/format:rss', '/featured/format:rss')
|
||||
|
||||
|
||||
class TestFeaturedPage(amo.tests.TestCase):
|
||||
fixtures = ['base/apps', 'base/featured', 'addons/featured']
|
||||
|
||||
@mock.patch.object(settings, 'NEW_FEATURES', False)
|
||||
def test_featured_addons(self):
|
||||
"""Make sure that only featured extensions are shown."""
|
||||
url = reverse('browse.extensions') + '?sort=featured'
|
||||
response = self.client.get(url)
|
||||
# But not in the content.
|
||||
featured = (Addon.objects.listed(amo.FIREFOX)
|
||||
.filter(type=amo.ADDON_EXTENSION)
|
||||
.values_list('id', flat=True))
|
||||
eq_(sorted(featured),
|
||||
sorted(a.id for a in response.context['addons']))
|
||||
|
||||
|
||||
class TestCategoriesFeed(amo.tests.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
@ -1236,12 +1073,8 @@ class TestCategoriesFeed(amo.tests.TestCase):
|
|||
|
||||
class TestFeaturedFeed(amo.tests.TestCase):
|
||||
fixtures = ['addons/featured', 'base/addon_3615', 'base/apps',
|
||||
'base/collections', 'base/featured', 'base/users']
|
||||
|
||||
def setUp(self):
|
||||
patcher = mock.patch.object(settings, 'NEW_FEATURES', False)
|
||||
patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
'base/collections', 'base/featured', 'base/users',
|
||||
'bandwagon/featured_collections']
|
||||
|
||||
def test_feed_elements_present(self):
|
||||
url = reverse('browse.featured.rss')
|
||||
|
@ -1257,15 +1090,6 @@ class TestFeaturedFeed(amo.tests.TestCase):
|
|||
Addon.objects.featured(amo.FIREFOX).count())
|
||||
|
||||
|
||||
class TestNewFeaturedFeed(TestFeaturedFeed):
|
||||
fixtures = TestFeaturedFeed.fixtures + ['bandwagon/featured_collections']
|
||||
|
||||
def setUp(self):
|
||||
patcher = mock.patch.object(settings, 'NEW_FEATURES', True)
|
||||
patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
|
||||
|
||||
class TestPersonas(amo.tests.TestCase):
|
||||
fixtures = ('base/apps', 'base/featured', 'addons/featured',
|
||||
'addons/persona')
|
||||
|
|
|
@ -428,35 +428,20 @@ class TestEditBasic(TestEdit):
|
|||
FeaturedCollection.objects.create(collection=c.collection,
|
||||
application_id=amo.FIREFOX.id)
|
||||
|
||||
@mock.patch.object(settings, 'NEW_FEATURES', False)
|
||||
def test_edit_categories_add_old_creatured(self):
|
||||
"""Using the old features, categories should be able to be changed."""
|
||||
self._feature_addon()
|
||||
self.cat_initial['categories'] = [22, 23]
|
||||
self.client.post(self.basic_edit_url, self.get_dict())
|
||||
addon_cats = self.get_addon().categories.values_list('id', flat=True)
|
||||
|
||||
# This add-on's categories should change.
|
||||
eq_(sorted(addon_cats), [22, 23])
|
||||
|
||||
@mock.patch.object(settings, 'NEW_FEATURES', True)
|
||||
def test_edit_categories_add_new_creatured(self):
|
||||
def test_edit_categories_add_creatured(self):
|
||||
"""Ensure that categories cannot be changed for creatured add-ons."""
|
||||
self._feature_addon()
|
||||
# TODO: remove this when NEW_FEATURES goes away. It's here because
|
||||
# build() was already called in setUp().
|
||||
from addons.cron import reset_featured_addons
|
||||
reset_featured_addons()
|
||||
|
||||
self.cat_initial['categories'] = [22, 23]
|
||||
r = self.client.post(self.basic_edit_url, self.get_dict())
|
||||
addon_cats = self.get_addon().categories.values_list('id', flat=True)
|
||||
|
||||
eq_(r.context['cat_form'].errors[0]['categories'],
|
||||
['Categories cannot be changed while your add-on is featured for '
|
||||
'this application.'])
|
||||
# This add-on's categories should not change.
|
||||
eq_(sorted(addon_cats), [22])
|
||||
|
||||
@mock.patch.object(settings, 'NEW_FEATURES', True)
|
||||
def test_edit_categories_add_new_creatured_admin(self):
|
||||
"""Ensure that admins can change categories for creatured add-ons."""
|
||||
assert self.client.login(username='admin@mozilla.com',
|
||||
|
@ -475,8 +460,7 @@ class TestEditBasic(TestEdit):
|
|||
# This add-on's categories should change.
|
||||
eq_(sorted(addon_cats), [22, 23])
|
||||
|
||||
@mock.patch.object(settings, 'NEW_FEATURES', True)
|
||||
def test_edit_categories_disable_new_creatured(self):
|
||||
def test_edit_categories_disable_creatured(self):
|
||||
"""Ensure that other forms are okay when disabling category changes."""
|
||||
self._feature_addon()
|
||||
self.cat_initial['categories'] = [22, 23]
|
||||
|
@ -484,38 +468,13 @@ class TestEditBasic(TestEdit):
|
|||
self.client.post(self.basic_edit_url, data)
|
||||
eq_(unicode(self.get_addon().name), data['name'])
|
||||
|
||||
@mock.patch.object(settings, 'NEW_FEATURES', False)
|
||||
def test_edit_categories_no_disclaimer_old(self):
|
||||
"""With old features enabled, there should never be a disclaimer."""
|
||||
self._feature_addon()
|
||||
r = self.client.get(self.basic_edit_url)
|
||||
doc = pq(r.content)
|
||||
eq_(doc('#addon-categories-edit div.addon-app-cats').length, 1)
|
||||
eq_(doc('#addon-categories-edit > p').length, 0)
|
||||
|
||||
@mock.patch.object(settings, 'NEW_FEATURES', True)
|
||||
def test_edit_categories_no_disclaimer_new(self):
|
||||
def test_edit_categories_no_disclaimer(self):
|
||||
"""Ensure that there is a not disclaimer for non-creatured add-ons."""
|
||||
r = self.client.get(self.basic_edit_url)
|
||||
doc = pq(r.content)
|
||||
eq_(doc('#addon-categories-edit div.addon-app-cats').length, 1)
|
||||
eq_(doc('#addon-categories-edit > p').length, 0)
|
||||
|
||||
@mock.patch.object(settings, 'NEW_FEATURES', True)
|
||||
def test_edit_categories_disclaimer(self):
|
||||
"""Ensure that there is a disclaimer for creatured add-ons."""
|
||||
self._feature_addon()
|
||||
# TODO: remove this when NEW_FEATURES goes away. It's here because
|
||||
# build() was already called in setUp().
|
||||
from addons.cron import reset_featured_addons
|
||||
reset_featured_addons()
|
||||
r = self.client.get(self.basic_edit_url)
|
||||
doc = pq(r.content)
|
||||
eq_(doc('#addon-categories-edit div.addon-app-cats').length, 0)
|
||||
eq_(doc('#addon-categories-edit > p').length, 2)
|
||||
eq_(doc('#addon-categories-edit p.addon-app-cats').text(),
|
||||
'Firefox: %s' % unicode(Category.objects.get(id=22).name))
|
||||
|
||||
def test_edit_categories_addandremove(self):
|
||||
AddonCategory(addon=self.addon, category_id=23).save()
|
||||
eq_([c.id for c in self.get_addon().all_categories], [22, 23])
|
||||
|
|
|
@ -289,7 +289,7 @@ class TestPane(amo.tests.TestCase):
|
|||
r = self.client.get(self.url)
|
||||
eq_(pq(r.content)('#featured-addons h2').text(), 'Featured Add-ons')
|
||||
|
||||
def _test_featured_addons(self):
|
||||
def test_featured_addons(self):
|
||||
r = self.client.get(self.url)
|
||||
p = pq(r.content)('#featured-addons')
|
||||
|
||||
|
@ -312,21 +312,13 @@ class TestPane(amo.tests.TestCase):
|
|||
eq_(li.find('h3').text(), unicode(addon.name))
|
||||
eq_(li.find('img').attr('src'), addon.icon_url)
|
||||
|
||||
@mock.patch.object(settings, 'NEW_FEATURES', False)
|
||||
def test_featured_addons(self):
|
||||
self._test_featured_addons()
|
||||
|
||||
@mock.patch.object(settings, 'NEW_FEATURES', True)
|
||||
def test_new_featured_addons(self):
|
||||
self._test_featured_addons()
|
||||
|
||||
def test_featured_personas_section(self):
|
||||
r = self.client.get(self.url)
|
||||
h2 = pq(r.content)('#featured-personas h2')
|
||||
eq_(h2.text(), 'See all Featured Personas')
|
||||
eq_(h2.find('a.all').attr('href'), reverse('browse.personas'))
|
||||
|
||||
def _test_featured_personas(self):
|
||||
def test_featured_personas(self):
|
||||
addon = Addon.objects.get(id=15679)
|
||||
r = self.client.get(self.url)
|
||||
p = pq(r.content)('#featured-personas')
|
||||
|
@ -337,14 +329,6 @@ class TestPane(amo.tests.TestCase):
|
|||
eq_(a.attr('target'), '_self')
|
||||
eq_(p.find('.addon-title').text(), unicode(addon.name))
|
||||
|
||||
@mock.patch.object(settings, 'NEW_FEATURES', False)
|
||||
def test_featured_personas(self):
|
||||
self._test_featured_personas()
|
||||
|
||||
@mock.patch.object(settings, 'NEW_FEATURES', True)
|
||||
def test_new_featured_personas(self):
|
||||
self._test_featured_personas()
|
||||
|
||||
|
||||
class TestDetails(amo.tests.TestCase):
|
||||
fixtures = ['base/apps', 'base/addon_3615', 'base/addon_592']
|
||||
|
|
|
@ -41,11 +41,6 @@ data-featured-collection-url="{{ url('zadmin.featured_collection') }}"
|
|||
|
||||
{% block content %}
|
||||
<h2>{{ title }}</h2>
|
||||
{% if not settings.NEW_FEATURES %}
|
||||
<div class="notification-box warning">
|
||||
<p>Featured collections are disabled. Enable the <code>NEW_FEATURES</code> setting to use the new features.</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
<form action="" method="post">
|
||||
{{ csrf() }}
|
||||
{{ form.non_form_errors() }}
|
||||
|
|
|
@ -1171,9 +1171,6 @@ EXPOSE_VALIDATOR_TRACEBACKS = False
|
|||
SEARCH_EXCLUDE_PERSONAS = True
|
||||
UNLINK_SITE_STATS = True
|
||||
|
||||
# Use the new featured add-ons system which makes use of featured collections.
|
||||
NEW_FEATURES = False
|
||||
|
||||
# Impala flags.
|
||||
|
||||
# Set to True if we're allowed to use X-SENDFILE.
|
||||
|
@ -1370,3 +1367,4 @@ DEFAULT_TO_COMPATIBLE = True
|
|||
|
||||
# How long to delay sending traceback emails for, see django-delayed-mailer.
|
||||
DELAYED_MAILER_WAIT = 60
|
||||
|
||||
|
|
|
@ -55,6 +55,3 @@ SITE_URL = ''
|
|||
MOBILE_SITE_URL = ''
|
||||
|
||||
CACHE_BACKEND = 'caching.backends.locmem://'
|
||||
|
||||
# These are not on by default yet or are toggled on directly in tests.
|
||||
NEW_FEATURES = False
|
||||
|
|
Загрузка…
Ссылка в новой задаче