(self)
| 973 | self.assertEqual(len(coder2.abs_fnames), 1) |
| 974 | |
| 975 | def test_suggest_shell_commands(self): |
| 976 | with GitTemporaryDirectory(): |
| 977 | io = InputOutput(yes=True) |
| 978 | coder = Coder.create(self.GPT35, "diff", io=io) |
| 979 | |
| 980 | def mock_send(*args, **kwargs): |
| 981 | coder.partial_response_content = """Here's a shell command to run: |
| 982 | |
| 983 | ```bash |
| 984 | echo "Hello, World!" |
| 985 | ``` |
| 986 | |
| 987 | This command will print 'Hello, World!' to the console.""" |
| 988 | coder.partial_response_function_call = dict() |
| 989 | return [] |
| 990 | |
| 991 | coder.send = mock_send |
| 992 | |
| 993 | # Mock the handle_shell_commands method to check if it's called |
| 994 | coder.handle_shell_commands = MagicMock() |
| 995 | |
| 996 | # Run the coder with a message |
| 997 | coder.run(with_message="Suggest a shell command") |
| 998 | |
| 999 | # Check if the shell command was added to the list |
| 1000 | self.assertEqual(len(coder.shell_commands), 1) |
| 1001 | self.assertEqual(coder.shell_commands[0].strip(), 'echo "Hello, World!"') |
| 1002 | |
| 1003 | # Check if handle_shell_commands was called with the correct argument |
| 1004 | coder.handle_shell_commands.assert_called_once() |
| 1005 | |
| 1006 | def test_no_suggest_shell_commands(self): |
| 1007 | with GitTemporaryDirectory(): |
nothing calls this directly
no test coverage detected