def test_shell_precmd_one_char_cmd(self): """ Test 'precmd' method one char. """ options = MagicMock() options.nohistory = True shell = SpacewalkShell(options, "", None) shell.config["server"] = "" shell.session = True assert shell.precmd("x") == "x"
def test_shell_precmd_history(self): """ Test 'precmd' method getting history item. """ options = MagicMock() options.nohistory = True shell = SpacewalkShell(options, "", None) shell.config["server"] = "" shell.session = True assert shell.precmd("!!") == "repeated item"
def test_shell_postcmd(self): """ Test 'postcmd' method of the shell. """ options = MagicMock() options.nohistory = True shell = SpacewalkShell(options, "", None) shell.config["server"] = "" shell.session = True shell.ssm = {1: "one"} shell.postcmd("result", "command") assert shell.prompt == "spacecmd {SSM:1}> "
def test_shell_precmd_help_keyword(self): """ Test 'precmd' method of the shell on --help/-h arguments. """ options = MagicMock() options.nohistory = True shell = SpacewalkShell(options, "", None) shell.config["server"] = "" shell.session = True assert shell.precmd("system_list --help") == "help system_list" assert shell.precmd("system_list -h") == "help system_list"
def test_shell_default(self): """ Test 'default' method of the shell. """ cmd = MagicMock() with patch("spacecmd.shell.Cmd.default", cmd): options = MagicMock() options.nohistory = True shell = SpacewalkShell(options, "", None) shell.config["server"] = "" shell.session = True with pytest.raises(UnknownCallException): shell.default("test") assert cmd.call_args[0][1] == "test"