mirror of
https://github.com/OMGeeky/gpt-pilot.git
synced 2026-02-23 15:49:50 +01:00
fixed some unit tests
This commit is contained in:
@@ -42,9 +42,8 @@ class TestDeveloper:
|
||||
@patch('helpers.AgentConvo.save_development_step')
|
||||
@patch('helpers.AgentConvo.create_gpt_chat_completion',
|
||||
return_value={'text': '{"command": "python --version", "timeout": 10}'})
|
||||
@patch('helpers.cli.styled_text', return_value='no')
|
||||
@patch('helpers.cli.execute_command', return_value=('', 'DONE'))
|
||||
def test_install_technology(self, mock_execute_command, mock_styled_text,
|
||||
def test_install_technology(self, mock_execute_command,
|
||||
mock_completion, mock_save, mock_get_saved_step):
|
||||
# Given
|
||||
self.developer.convo_os_specific_tech = AgentConvo(self.developer)
|
||||
|
||||
@@ -2,6 +2,7 @@ import os
|
||||
from pathlib import Path
|
||||
from database.database import save_user_app
|
||||
|
||||
|
||||
def get_parent_folder(folder_name):
|
||||
current_path = Path(os.path.abspath(__file__)) # get the path of the current script
|
||||
|
||||
@@ -11,7 +12,14 @@ def get_parent_folder(folder_name):
|
||||
return current_path.parent
|
||||
|
||||
|
||||
def setup_workspace(args):
|
||||
def setup_workspace(args) -> str:
|
||||
"""
|
||||
Creates & returns the path to the project workspace.
|
||||
Also creates a 'tests' folder inside the workspace.
|
||||
:param args: may contain 'workspace' or 'root' keys
|
||||
"""
|
||||
# `args['workspace']` can be used to work with an existing workspace at the specified path.
|
||||
# `args['root']` is used by VS Code for (nearly) the same purpose, but `args['name']` is appended to it.
|
||||
workspace = args.get('workspace')
|
||||
if workspace:
|
||||
try:
|
||||
@@ -23,7 +31,6 @@ def setup_workspace(args):
|
||||
return args['workspace']
|
||||
|
||||
root = args.get('root') or get_parent_folder('pilot')
|
||||
create_directory(root, 'workspace')
|
||||
project_path = create_directory(os.path.join(root, 'workspace'), args.get('name', 'default_project_name'))
|
||||
create_directory(project_path, 'tests')
|
||||
return project_path
|
||||
|
||||
@@ -96,6 +96,7 @@ class TestSchemaValidation:
|
||||
}
|
||||
'''.strip(), DEVELOPMENT_PLAN['definitions']))
|
||||
|
||||
|
||||
class TestLlmConnection:
|
||||
def setup_method(self):
|
||||
builtins.print, ipc_client_instance = get_custom_print({})
|
||||
@@ -121,9 +122,12 @@ class TestLlmConnection:
|
||||
|
||||
mock_post.return_value = mock_response
|
||||
|
||||
# When
|
||||
with patch('utils.llm_connection.requests.post', return_value=mock_response):
|
||||
response = stream_gpt_completion({}, '')
|
||||
# When
|
||||
response = stream_gpt_completion({
|
||||
'model': 'gpt-4',
|
||||
'messages': [],
|
||||
}, '', project)
|
||||
|
||||
# Then
|
||||
assert response == {'text': '{\n "foo": "bar",\n "prompt": "Hello",\n "choices": []\n}'}
|
||||
@@ -174,7 +178,7 @@ solution-oriented decision-making in areas where precise instructions were not p
|
||||
function_calls = ARCHITECTURE
|
||||
|
||||
# When
|
||||
response = create_gpt_chat_completion(convo.messages, '', function_calls=function_calls)
|
||||
response = create_gpt_chat_completion(convo.messages, '', project, function_calls=function_calls)
|
||||
|
||||
# Then
|
||||
assert convo.messages[0]['content'].startswith('You are an experienced software architect')
|
||||
@@ -225,19 +229,19 @@ The development process will include the creation of user stories and tasks, bas
|
||||
# Retry on bad LLM responses
|
||||
mock_questionary = MockQuestionary(['', '', 'no'])
|
||||
|
||||
# with patch('utils.llm_connection.questionary', mock_questionary):
|
||||
# When
|
||||
with patch('utils.llm_connection.questionary', mock_questionary):
|
||||
response = create_gpt_chat_completion(convo.messages, '', function_calls=function_calls)
|
||||
response = create_gpt_chat_completion(convo.messages, '', project, function_calls=function_calls)
|
||||
|
||||
# Then
|
||||
assert convo.messages[0]['content'].startswith('You are a tech lead in a software development agency')
|
||||
assert convo.messages[1]['content'].startswith('You are working in a software development agency and a project manager and software architect approach you')
|
||||
# Then
|
||||
assert convo.messages[0]['content'].startswith('You are a tech lead in a software development agency')
|
||||
assert convo.messages[1]['content'].startswith('You are working in a software development agency and a project manager and software architect approach you')
|
||||
|
||||
assert response is not None
|
||||
response = parse_agent_response(response, function_calls)
|
||||
assert_non_empty_string(response[0]['description'])
|
||||
assert_non_empty_string(response[0]['programmatic_goal'])
|
||||
assert_non_empty_string(response[0]['user_review_goal'])
|
||||
assert response is not None
|
||||
response = parse_agent_response(response, function_calls)
|
||||
assert_non_empty_string(response[0]['description'])
|
||||
assert_non_empty_string(response[0]['programmatic_goal'])
|
||||
assert_non_empty_string(response[0]['user_review_goal'])
|
||||
|
||||
|
||||
# def test_break_down_development_task(self):
|
||||
|
||||
Reference in New Issue
Block a user