mirror of
https://github.com/OMGeeky/gpt-pilot.git
synced 2026-01-19 08:44:46 +01:00
new_callable=MagicMock
This commit is contained in:
@@ -41,7 +41,7 @@ class TestCodeMonkey:
|
||||
self.codeMonkey = CodeMonkey(self.project, developer=self.developer)
|
||||
|
||||
@patch('helpers.AgentConvo.get_saved_development_step', return_value=None)
|
||||
@patch('helpers.AgentConvo.save_development_step', return_value=None)
|
||||
@patch('helpers.AgentConvo.save_development_step', new_callable=MagicMock)
|
||||
@patch('os.get_terminal_size', mock_terminal_size)
|
||||
@patch.object(File, 'insert')
|
||||
def test_implement_code_changes(self, mock_get_dev, mock_save_dev, mock_file_insert):
|
||||
@@ -79,7 +79,7 @@ class TestCodeMonkey:
|
||||
assert called_data['content'] == 'Washington'
|
||||
|
||||
@patch('helpers.AgentConvo.get_saved_development_step', return_value=None)
|
||||
@patch('helpers.AgentConvo.save_development_step', return_value=None)
|
||||
@patch('helpers.AgentConvo.save_development_step', new_callable=MagicMock)
|
||||
@patch('os.get_terminal_size', mock_terminal_size)
|
||||
@patch.object(File, 'insert')
|
||||
def test_implement_code_changes_with_read(self, mock_get_dev, mock_save_dev, mock_file_insert):
|
||||
|
||||
@@ -2,7 +2,7 @@ import builtins
|
||||
import json
|
||||
import os
|
||||
import pytest
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
import requests
|
||||
|
||||
@@ -59,6 +59,7 @@ class TestDeveloper:
|
||||
@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',
|
||||
new_callable = MagicMock,
|
||||
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'))
|
||||
@@ -85,7 +86,7 @@ class TestDeveloper:
|
||||
# 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')
|
||||
@patch('helpers.Project.ask_user', return_value='continue', new_callable=MagicMock)
|
||||
def test_code_changes_manual_test_continue(self, mock_get_saved_step, mock_save, mock_chat_completion, mock_ask_user):
|
||||
# Given
|
||||
monkey = None
|
||||
@@ -100,7 +101,7 @@ class TestDeveloper:
|
||||
|
||||
@patch('helpers.AgentConvo.get_saved_development_step')
|
||||
@patch('helpers.AgentConvo.save_development_step')
|
||||
@patch('helpers.AgentConvo.create_gpt_chat_completion')
|
||||
@patch('helpers.AgentConvo.create_gpt_chat_completion', new_callable=MagicMock)
|
||||
@patch('utils.questionary.get_saved_user_input')
|
||||
# https://github.com/Pythagora-io/gpt-pilot/issues/35
|
||||
def test_code_changes_manual_test_no(self, mock_get_saved_user_input, mock_chat_completion, mock_save, mock_get_saved_step):
|
||||
@@ -128,7 +129,7 @@ class TestDeveloper:
|
||||
|
||||
@patch('helpers.cli.execute_command', return_value=('stdout:\n```\n\n```', 'DONE'))
|
||||
@patch('helpers.AgentConvo.get_saved_development_step')
|
||||
@patch('helpers.AgentConvo.save_development_step')
|
||||
@patch('helpers.AgentConvo.save_development_step', new_callable=MagicMock)
|
||||
@patch('utils.llm_connection.requests.post')
|
||||
@patch('utils.questionary.get_saved_user_input')
|
||||
def test_test_code_changes_invalid_json(self, mock_get_saved_user_input,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import pytest
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import patch, MagicMock
|
||||
from helpers.Project import Project
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ project.app = 'test'
|
||||
# 'None path absolute file', 'home path', 'home path same name', 'absolute path with name'
|
||||
])
|
||||
@patch('helpers.Project.update_file')
|
||||
@patch('helpers.Project.File.insert')
|
||||
@patch('helpers.Project.File.insert', new_callable=MagicMock)
|
||||
def test_save_file(mock_file_insert, mock_update_file, test_data):
|
||||
# Given
|
||||
data = {'content': 'Hello World!'}
|
||||
|
||||
Reference in New Issue
Block a user