Example #1
0
    def test_search_query(self):
        self.create_custom_query_perm()

        def mocked_query_get(**params):
            assert "query" in params

            return {"hits": []}

        Query.implementation().get.side_effect = mocked_query_get

        url = reverse("supersearch:search_query")
        response = self.client.post(url, {"query": '{"query": {}}'})
        assert response.status_code == 200

        content = json.loads(response.content)
        assert "hits" in content
        assert content["hits"] == []

        # Test a failure.
        response = self.client.post(url)
        assert response.status_code == 400
        assert "query" in smart_text(response.content)
Example #2
0
    def test_search_query(self):
        self.create_custom_query_perm()

        def mocked_query_get(**params):
            ok_('query' in params)

            return {"hits": []}

        Query.implementation().get.side_effect = (mocked_query_get)

        url = reverse('supersearch.search_query')
        response = self.client.post(url, {'query': '{"query": {}}'})
        eq_(response.status_code, 200)

        content = json.loads(response.content)
        ok_('hits' in content)
        eq_(content['hits'], [])

        # Test a failure.
        response = self.client.post(url)
        eq_(response.status_code, 400)
        ok_('query' in response.content)
Example #3
0
    def test_search_query(self):
        self.create_custom_query_perm()

        def mocked_query_get(**params):
            assert 'query' in params

            return {"hits": []}

        Query.implementation().get.side_effect = mocked_query_get

        url = reverse('supersearch:search_query')
        response = self.client.post(url, {'query': '{"query": {}}'})
        assert response.status_code == 200

        content = json.loads(response.content)
        assert 'hits' in content
        assert content['hits'] == []

        # Test a failure.
        response = self.client.post(url)
        assert response.status_code == 400
        assert 'query' in smart_text(response.content)
Example #4
0
    def test_search_query(self):
        self.create_custom_query_perm()

        def mocked_query_get(**params):
            assert 'query' in params

            return {"hits": []}

        Query.implementation().get.side_effect = (
            mocked_query_get
        )

        url = reverse('supersearch.search_query')
        response = self.client.post(url, {'query': '{"query": {}}'})
        assert response.status_code == 200

        content = json.loads(response.content)
        assert 'hits' in content
        assert content['hits'] == []

        # Test a failure.
        response = self.client.post(url)
        assert response.status_code == 400
        assert 'query' in response.content
Example #5
0
    def test_search_query(self):
        self.create_custom_query_perm()

        def mocked_query_get(**params):
            ok_('query' in params)

            return {"hits": []}

        Query.implementation().get.side_effect = (
            mocked_query_get
        )

        url = reverse('supersearch.search_query')
        response = self.client.post(url, {'query': '{"query": {}}'})
        eq_(response.status_code, 200)

        content = json.loads(response.content)
        ok_('hits' in content)
        eq_(content['hits'], [])

        # Test a failure.
        response = self.client.post(url)
        eq_(response.status_code, 400)
        ok_('query' in response.content)