Beispiel #1
0
    def test_repr(self):
        query = SuggestQuery(search_text="foo bar", suggester_name="sg")
        assert repr(query) == "<SuggestQuery [foo bar]>"

        query = SuggestQuery(search_text="aaaaabbbbb" * 200,
                             suggester_name="sg")
        assert len(repr(query)) == 1024
    def test_filter(self):
        query = SuggestQuery(search_text="text", suggester_name="sg")
        assert query.request.filter is None
        query.filter("expr0")
        assert query.request.filter == "expr0"

        query = SuggestQuery(search_text="text", suggester_name="sg", filter="expr1")
        assert query.request.filter == "expr1"
        query.filter("expr2")
        assert query.request.filter == "expr2"
Beispiel #3
0
 def test_kwargs_forwarded(self, mock_request):
     mock_request.return_value = None
     SuggestQuery(foo=10, bar=20)
     assert mock_request.called
     assert mock_request.call_args[0] == ()
     assert mock_request.call_args[1] == {"foo": 10, "bar": 20}
Beispiel #4
0
 def test_init(self):
     query = SuggestQuery(search_text="text", suggester_name="sg")
     assert type(query.request) is SuggestRequest
     assert query.request.filter is None