test for scan, keys, and sccan
@@ -159,4 +159,93 @@ def test_render_list_or_string():
def test_list_or_string():
config.raw = False
assert renders.render_string_or_int(b"10.1") == '"10.1"'
- assert renders.render_string_or_int(3) == FormattedText([('class:type', '(integer) '), ('', '3')])
+ assert renders.render_string_or_int(3) == FormattedText(
+ [("class:type", "(integer) "), ("", "3")]
+ )
+
+
+def test_command_keys(completer):
+ completer.completers["key"].words = []
+ config.raw = False
+ rendered = renders.command_keys([b"cat", b"dog", b"banana"], completer)
+
+ assert rendered == FormattedText(
+ [
+ ("", "1)"),
+ ("", " "),
+ ("class:key", '"cat"'),
+ ("", "\n"),
+ ("", "2)"),
+ ("", " "),
+ ("class:key", '"dog"'),
+ ("", "\n"),
+ ("", "3)"),
+ ("", " "),
+ ("class:key", '"banana"'),
+ ]
+ )
+ assert completer.completers["keys"].words == ["banana", "dog", "cat"]
+
+
+def test_command_scan(completer):
+ completer.completers["key"].words = []
+ config.raw = False
+ rendered = renders.command_scan(
+ [b"44", [b"a", b"key:__rand_int__", b"dest", b" a"]], completer
+ )
+
+ assert rendered == FormattedText(
+ [
+ ("class:type", "(cursor) "),
+ ("class:integer", "44"),
+ ("", "\n"),
+ ("", "1)"),
+ ("", " "),
+ ("class:key", '"a"'),
+ ("", "\n"),
+ ("", "2)"),
+ ("", " "),
+ ("class:key", '"key:__rand_int__"'),
+ ("", "\n"),
+ ("", "3)"),
+ ("", " "),
+ ("class:key", '"dest"'),
+ ("", "\n"),
+ ("", "4)"),
+ ("", " "),
+ ("class:key", '" a"'),
+ ]
+ )
+ assert completer.completers["keys"].words == [" a", "dest", "key:__rand_int__", "a"]
+
+
+def test_command_sscan(completer):
+ completer.completers["member"].words = []
+ config.raw = False
+ rendered = renders.command_sscan(
+ [b"44", [b"a", b"member:__rand_int__", b"dest", b" a"]], completer
+ )
+
+ assert rendered == FormattedText(
+ [
+ ("class:type", "(cursor) "),
+ ("class:integer", "44"),
+ ("", "\n"),
+ ("", "1)"),
+ ("", " "),
+ ("class:member", '"a"'),
+ ("", "\n"),
+ ("", "2)"),
+ ("", " "),
+ ("class:member", '"member:__rand_int__"'),
+ ("", "\n"),
+ ("", "3)"),
+ ("", " "),
+ ("class:member", '"dest"'),
+ ("", "\n"),
+ ("", "4)"),
+ ("", " "),
+ ("class:member", '" a"'),
+ ]
+ )
+ assert completer.completers["members"].words == [" a", "dest", "member:__rand_int__", "a"]
