mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-23 22:04:59 +00:00
refactor: Move test_cmd_load_with_switch_coder to test file
This commit is contained in:
parent
20bc718bdc
commit
761fb93aba
2 changed files with 30 additions and 30 deletions
|
@ -1320,36 +1320,6 @@ class Commands:
|
||||||
f"Command '{cmd}' is only supported in interactive mode, skipping."
|
f"Command '{cmd}' is only supported in interactive mode, skipping."
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_cmd_load_with_switch_coder(self):
|
|
||||||
with GitTemporaryDirectory() as repo_dir:
|
|
||||||
io = InputOutput(pretty=False, fancy_input=False, yes=True)
|
|
||||||
coder = Coder.create(self.GPT35, None, io)
|
|
||||||
commands = Commands(io, coder)
|
|
||||||
|
|
||||||
# Create a temporary file with commands
|
|
||||||
commands_file = Path(repo_dir) / "test_commands.txt"
|
|
||||||
commands_file.write_text("/ask Tell me about the code\n/model gpt-4\n")
|
|
||||||
|
|
||||||
# Mock run to raise SwitchCoder for /ask and /model
|
|
||||||
def mock_run(cmd):
|
|
||||||
if cmd.startswith(("/ask", "/model")):
|
|
||||||
raise SwitchCoder()
|
|
||||||
return None
|
|
||||||
|
|
||||||
with mock.patch.object(commands, "run", side_effect=mock_run):
|
|
||||||
# Capture tool_error output
|
|
||||||
with mock.patch.object(io, "tool_error") as mock_tool_error:
|
|
||||||
commands.cmd_load(str(commands_file))
|
|
||||||
|
|
||||||
# Check that appropriate error messages were shown
|
|
||||||
mock_tool_error.assert_any_call(
|
|
||||||
"Command '/ask Tell me about the code' is only supported in interactive"
|
|
||||||
" mode, skipping."
|
|
||||||
)
|
|
||||||
mock_tool_error.assert_any_call(
|
|
||||||
"Command '/model gpt-4' is only supported in interactive mode, skipping."
|
|
||||||
)
|
|
||||||
|
|
||||||
def completions_raw_save(self, document, complete_event):
|
def completions_raw_save(self, document, complete_event):
|
||||||
return self.completions_raw_read_only(document, complete_event)
|
return self.completions_raw_read_only(document, complete_event)
|
||||||
|
|
||||||
|
|
|
@ -1721,3 +1721,33 @@ class TestCommands(TestCase):
|
||||||
|
|
||||||
del coder
|
del coder
|
||||||
del commands
|
del commands
|
||||||
|
|
||||||
|
def test_cmd_load_with_switch_coder(self):
|
||||||
|
with GitTemporaryDirectory() as repo_dir:
|
||||||
|
io = InputOutput(pretty=False, fancy_input=False, yes=True)
|
||||||
|
coder = Coder.create(self.GPT35, None, io)
|
||||||
|
commands = Commands(io, coder)
|
||||||
|
|
||||||
|
# Create a temporary file with commands
|
||||||
|
commands_file = Path(repo_dir) / "test_commands.txt"
|
||||||
|
commands_file.write_text("/ask Tell me about the code\n/model gpt-4\n")
|
||||||
|
|
||||||
|
# Mock run to raise SwitchCoder for /ask and /model
|
||||||
|
def mock_run(cmd):
|
||||||
|
if cmd.startswith(("/ask", "/model")):
|
||||||
|
raise SwitchCoder()
|
||||||
|
return None
|
||||||
|
|
||||||
|
with mock.patch.object(commands, "run", side_effect=mock_run):
|
||||||
|
# Capture tool_error output
|
||||||
|
with mock.patch.object(io, "tool_error") as mock_tool_error:
|
||||||
|
commands.cmd_load(str(commands_file))
|
||||||
|
|
||||||
|
# Check that appropriate error messages were shown
|
||||||
|
mock_tool_error.assert_any_call(
|
||||||
|
"Command '/ask Tell me about the code' is only supported in interactive"
|
||||||
|
" mode, skipping."
|
||||||
|
)
|
||||||
|
mock_tool_error.assert_any_call(
|
||||||
|
"Command '/model gpt-4' is only supported in interactive mode, skipping."
|
||||||
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue