testcase: add tests for paging peek, help.
@@ -2,6 +2,7 @@ import os
import sys
import pexpect
import pathlib
+from contextlib import contextmanager
from textwrap import dedent
@@ -21,19 +22,46 @@ env_pager_numbers = "{0} {1} {2}".format(
)
-def test_using_pager_when_rows_too_high(clean_redis):
+@contextmanager
+def pager_enabled_cli():
env = os.environ
env["PAGER"] = env_pager
child = pexpect.spawn(f"iredis -n 15", timeout=3, env=env)
child.logfile_read = open("cli_test.log", "ab")
child.expect("127.0.0.1")
+ try:
+ yield child
+ finally:
+ child.close()
+
+
+def test_using_pager_when_rows_too_high(clean_redis):
for index in range(100):
clean_redis.lpush("long-list", f"value-{index}")
+ with pager_enabled_cli() as child:
child.sendline("lrange long-list 0 -1")
child.expect(TEST_PAGER_BOUNDARY)
child.expect("value-1")
child.expect(TEST_PAGER_BOUNDARY)
- child.close()
+
+
+def test_using_pager_works_for_help():
+ with pager_enabled_cli() as child:
+ child.sendline("help set")
+ child.expect(TEST_PAGER_BOUNDARY)
+ child.expect("Set the string value of a key")
+ child.expect(TEST_PAGER_BOUNDARY)
+
+
+def test_pager_works_for_peek(clean_redis):
+ for index in range(100):
+ clean_redis.lpush("long-list", f"value-{index}")
+ with pager_enabled_cli() as child:
+ child.sendline("peek long-list")
+ child.expect(TEST_PAGER_BOUNDARY)
+ child.expect("(quicklist)")
+ child.expect("value-1")
+ child.expect(TEST_PAGER_BOUNDARY)
def test_using_pager_from_config(clean_redis):
