Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
 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)
Exemplo n.º 6
0
 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)