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

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

        query = AutocompleteQuery(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
     AutocompleteQuery(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 = AutocompleteQuery(search_text="text", suggester_name="sg")
     assert type(query.request) is AutocompleteRequest
     assert query.request.filter is None