add in is_featured based on lang and app (bug #433673)
This commit is contained in:
Родитель
3061506e52
Коммит
3b266501b4
|
@ -115,6 +115,7 @@
|
|||
</last_updated>
|
||||
<homepage>{{ addon.homepage }}</homepage>
|
||||
<support>{{ addon.support_url }}</support>
|
||||
<featured>{{ addon.is_featured(request.APP, request.LANG)|int }}</featured>
|
||||
{%- endif -%}
|
||||
</addon>
|
||||
{% endcache %}
|
||||
|
|
|
@ -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),
|
||||
'<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')
|
||||
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),
|
||||
'<featured>%s</featured>' % result)
|
||||
|
||||
|
||||
class ListTest(TestCase):
|
||||
"""Tests the list view with various urls."""
|
||||
|
|
Загрузка…
Ссылка в новой задаче