mirror of
https://github.com/OMGeeky/gpt-pilot.git
synced 2026-02-23 15:49:50 +01:00
Fix handling of GET_TEST_TYPE response.
The recent function calling changes has does not include `None` values in the tuples returned from `convo.send_message()`
This commit is contained in:
@@ -51,3 +51,46 @@ class TestDeveloper:
|
||||
# Then
|
||||
assert llm_response == 'DONE'
|
||||
mock_execute_command.assert_called_once_with(self.project, 'python --version', 10)
|
||||
|
||||
@patch('helpers.AgentConvo.get_saved_development_step')
|
||||
@patch('helpers.AgentConvo.save_development_step')
|
||||
# GET_TEST_TYPE has optional properties, so we need to be able to handle missing args.
|
||||
@patch('helpers.AgentConvo.create_gpt_chat_completion',
|
||||
return_value={'text': '{"type": "command_test", "command": {"command": "npm run test", "timeout": 3000}}'})
|
||||
# 2nd arg of return_value: `None` to debug, 'DONE' if successful
|
||||
@patch('helpers.cli.execute_command', return_value=('stdout:\n```\n\n```', 'DONE'))
|
||||
# @patch('helpers.cli.ask_user', return_value='yes')
|
||||
# @patch('helpers.cli.get_saved_command_run')
|
||||
def test_code_changes_command_test(self, mock_get_saved_step, mock_save, mock_chat_completion,
|
||||
# Note: the 2nd line below will use the LLM to debug, uncomment the @patches accordingly
|
||||
mock_execute_command):
|
||||
# mock_ask_user, mock_get_saved_command_run):
|
||||
# Given
|
||||
monkey = None
|
||||
convo = AgentConvo(self.developer)
|
||||
convo.save_branch = lambda branch_name=None: branch_name
|
||||
|
||||
# When
|
||||
# "Now, we need to verify if this change was successfully implemented...
|
||||
result = self.developer.test_code_changes(monkey, convo)
|
||||
|
||||
# Then
|
||||
assert result == {'success': True, 'cli_response': 'stdout:\n```\n\n```'}
|
||||
|
||||
@patch('helpers.AgentConvo.get_saved_development_step')
|
||||
@patch('helpers.AgentConvo.save_development_step')
|
||||
# GET_TEST_TYPE has optional properties, so we need to be able to handle missing args.
|
||||
@patch('helpers.AgentConvo.create_gpt_chat_completion',
|
||||
return_value={'text': '{"type": "manual_test", "manual_test_description": "Does it look good?"}'})
|
||||
@patch('helpers.Project.ask_user', return_value='continue')
|
||||
def test_code_changes_manual_test(self, mock_get_saved_step, mock_save, mock_chat_completion, mock_ask_user):
|
||||
# Given
|
||||
monkey = None
|
||||
convo = AgentConvo(self.developer)
|
||||
convo.save_branch = lambda branch_name=None: branch_name
|
||||
|
||||
# When
|
||||
result = self.developer.test_code_changes(monkey, convo)
|
||||
|
||||
# Then
|
||||
assert result == {'success': True, 'user_input': 'continue'}
|
||||
|
||||
Reference in New Issue
Block a user