def test_sort(self): # Mocked version, to make sure we are calling ES with the parameters # we want. with patch('mkt.webapps.models.Webapp.from_search') as mocked_search: mocked_qs = MagicMock() mocked_search.return_value = mocked_qs for api_sort, es_sort in DEFAULT_SORTING.items(): res = self.client.get(self.url, [('sort', api_sort)]) eq_(res.status_code, 200, res.content) mocked_qs.order_by.assert_called_with(es_sort) # Unmocked version, to make sure elasticsearch is actually accepting # the params. for api_sort, es_sort in DEFAULT_SORTING.items(): res = self.client.get(self.url, [('sort', api_sort)]) eq_(res.status_code, 200)
def test_sort(self): for api_sort, es_sort in DEFAULT_SORTING.items(): qs = self._filter(self.req, {'sort': [api_sort]}) if es_sort.startswith('-'): ok_({es_sort[1:]: {'order': 'desc'}} in qs['sort'], qs) else: eq_([es_sort], qs['sort'], qs)
def test_sort(self): # Make sure elasticsearch is actually accepting the params. for api_sort, es_sort in DEFAULT_SORTING.items(): res = self.client.get(self.url, [('sort', api_sort)]) eq_(res.status_code, 200)
def test_sort(self): # Make sure elasticsearch is actually accepting the params. for api_sort, es_sort in DEFAULT_SORTING.items(): res = self.anon.get(self.url, [('sort', api_sort)]) eq_(res.status_code, 200)