def test_newbie_mode_complete_without_meta_dict(): fake_document = MagicMock() fake_document.text_before_cursor = "GEOR" completer = GrammarCompleter(command_grammar, get_completer_mapping()) completions = list(completer.get_completions(fake_document, None)) assert [word.text for word in completions] == ["GEORADIUS", "GEORADIUSBYMEMBER"]
def test_running_with_pipeline(clean_redis, iredis_client, capfd): grammar = get_command_grammar("get") completer = GrammarCompleter(grammar, get_completer_mapping()) clean_redis.set("foo", "hello \n world") with pytest.raises(StopIteration): next(iredis_client.send_command("get foo | grep w", completer)) out, err = capfd.readouterr() assert out == " world\n"
def test_newbie_mode_complete_with_meta_dict(): fake_document = MagicMock() fake_document.text_before_cursor = "GEOR" completer = GrammarCompleter(command_grammar, get_completer_mapping()) completions = list(completer.get_completions(fake_document, None)) assert sorted([completion.display_meta for completion in completions]) == [ FormattedText([( "", "Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a member", # noqa )]), FormattedText([( "", "Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a point", # noqa )]), ]