diff --git a/apps/api/templates/api/includes/addon.xml b/apps/api/templates/api/includes/addon.xml index 8bd0d12aaf..66bdd735f8 100644 --- a/apps/api/templates/api/includes/addon.xml +++ b/apps/api/templates/api/includes/addon.xml @@ -115,6 +115,7 @@ {{ addon.homepage }} {{ addon.support_url }} + {{ addon.is_featured(request.APP, request.LANG)|int }} {%- endif -%} {% endcache %} diff --git a/apps/api/tests/test_legacy.py b/apps/api/tests/test_legacy.py index 4eb48e6efa..3d8f597508 100644 --- a/apps/api/tests/test_legacy.py +++ b/apps/api/tests/test_legacy.py @@ -1,4 +1,5 @@ # -*- coding: utf8 -*- +from datetime import datetime, timedelta import json import os @@ -14,7 +15,7 @@ from nose.tools import eq_ import amo import api import api.utils -from addons.models import Addon +from addons.models import Addon, Feature from amo import helpers from amo.urlresolvers import reverse from search.tests import SphinxTestCase @@ -117,6 +118,10 @@ class APITest(TestCase): fixtures = ['base/apps', 'base/addon_3615', 'base/addon_4664_twitterbar', 'base/addon_5299_gcal'] + def setUp(self): + if hasattr(Addon, '_feature'): + delattr(Addon, '_feature') + def test_api_caching(self): response = self.client.get('/en-US/firefox/api/1.5/addon/3615') eq_(response.status_code, 200) @@ -353,6 +358,23 @@ class APITest(TestCase): status_code=503) test_sphinx_off.sphinx = True + def test_is_featured(self): + self.assertContains(make_call('addon/5299', version=1.5), + '0') + 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') + for lang, app, result in [('ja', 'firefox', 1), + ('en-US', 'firefox', 0), + ('ja', 'seamonkey', 0)]: + # Clean out the special cache for feature. + delattr(Addon, '_feature') + self.assertContains(make_call('addon/5299', version=1.5, + lang=lang, app=app), + '%s' % result) + class ListTest(TestCase): """Tests the list view with various urls."""