add download source for search suggestions
This commit is contained in:
Родитель
94a70b736c
Коммит
1fbc73803c
|
@ -293,7 +293,7 @@ class TestAjaxSearch(amo.tests.ESTestCase):
|
|||
cls.setUpIndex()
|
||||
|
||||
def search_addons(self, url, params, addons=[],
|
||||
types=amo.ADDON_SEARCH_TYPES):
|
||||
types=amo.ADDON_SEARCH_TYPES, src=None):
|
||||
r = self.client.get('?'.join([url, params]))
|
||||
eq_(r.status_code, 200)
|
||||
data = json.loads(r.content)
|
||||
|
@ -305,7 +305,10 @@ class TestAjaxSearch(amo.tests.ESTestCase):
|
|||
for got, expected in zip(data, addons):
|
||||
eq_(int(got['id']), expected.id)
|
||||
eq_(got['name'], unicode(expected.name))
|
||||
eq_(got['url'], expected.get_url_path())
|
||||
expected_url = expected.get_url_path()
|
||||
if src:
|
||||
expected_url += '?src=ss'
|
||||
eq_(got['url'], expected_url)
|
||||
eq_(got['icon'], expected.icon_url)
|
||||
|
||||
assert expected.status in amo.REVIEWED_STATUSES, (
|
||||
|
@ -382,7 +385,7 @@ class TestSearchSuggestions(TestAjaxSearch):
|
|||
def search_addons(self, params, addons=[],
|
||||
types=views.AddonSuggestionsAjax.types):
|
||||
super(TestSearchSuggestions, self).search_addons(
|
||||
self.url, params, addons, types)
|
||||
self.url, params, addons, types, src='ss')
|
||||
|
||||
def search_applications(self, params, apps=[]):
|
||||
r = self.client.get('?'.join([self.url, params]))
|
||||
|
|
|
@ -271,6 +271,7 @@ class BaseAjaxSearch(object):
|
|||
def __init__(self, request, excluded_ids=[]):
|
||||
self.request = request
|
||||
self.excluded_ids = excluded_ids
|
||||
self.src = getattr(self, 'src', None)
|
||||
self.types = getattr(self, 'types', amo.ADDON_SEARCH_TYPES)
|
||||
self.limit = 10
|
||||
self.key = 'q' # Name of search field.
|
||||
|
@ -314,21 +315,27 @@ class BaseAjaxSearch(object):
|
|||
if callable(val):
|
||||
val = val()
|
||||
d[key] = unicode(val)
|
||||
if self.src and 'url' in d:
|
||||
d['url'] = urlparams(d['url'], src=self.src)
|
||||
results.append(d)
|
||||
return results
|
||||
|
||||
|
||||
class AddonSuggestionsAjax(BaseAjaxSearch):
|
||||
class SearchSuggestionsAjax(BaseAjaxSearch):
|
||||
src = 'ss'
|
||||
|
||||
|
||||
class AddonSuggestionsAjax(SearchSuggestionsAjax):
|
||||
# No personas. No webapps.
|
||||
types = [amo.ADDON_ANY, amo.ADDON_EXTENSION, amo.ADDON_THEME,
|
||||
amo.ADDON_DICT, amo.ADDON_SEARCH, amo.ADDON_LPAPP]
|
||||
|
||||
|
||||
class PersonaSuggestionsAjax(BaseAjaxSearch):
|
||||
class PersonaSuggestionsAjax(SearchSuggestionsAjax):
|
||||
types = [amo.ADDON_PERSONA]
|
||||
|
||||
|
||||
class WebappSuggestionsAjax(BaseAjaxSearch):
|
||||
class WebappSuggestionsAjax(SearchSuggestionsAjax):
|
||||
types = [amo.ADDON_WEBAPP]
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
INSERT INTO download_sources (name, type, created) VALUES ('ss', 'full', NOW());
|
Загрузка…
Ссылка в новой задаче