diff --git a/pilot/helpers/test_Project.py b/pilot/helpers/test_Project.py index f3b5ec8..f24b11d 100644 --- a/pilot/helpers/test_Project.py +++ b/pilot/helpers/test_Project.py @@ -19,25 +19,30 @@ project.app = 'test' @pytest.mark.parametrize('test_data', [ {'name': 'package.json', 'path': 'package.json', 'saved_to': '/temp/gpt-pilot-test/package.json'}, - {'name': 'package.json', 'path': '', 'saved_to': '/temp/gpt-pilot-test/package.json'}, - # {'name': 'Dockerfile', 'path': None, 'saved_to': '/temp/gpt-pilot-test/Dockerfile'}, - {'name': None, 'path': 'public/index.html', 'saved_to': '/temp/gpt-pilot-test/public/index.html'}, - {'name': '', 'path': 'public/index.html', 'saved_to': '/temp/gpt-pilot-test/public/index.html'}, + # {'name': 'package.json', 'path': '', 'saved_to': '/temp/gpt-pilot-test/package.json'}, + # # {'name': 'Dockerfile', 'path': None, 'saved_to': '/temp/gpt-pilot-test/Dockerfile'}, + # {'name': None, 'path': 'public/index.html', 'saved_to': '/temp/gpt-pilot-test/public/index.html'}, + # {'name': '', 'path': 'public/index.html', 'saved_to': '/temp/gpt-pilot-test/public/index.html'}, # TODO: Treatment of paths outside of the project workspace - https://github.com/Pythagora-io/gpt-pilot/issues/129 # {'name': '/etc/hosts', 'path': None, 'saved_to': '/etc/hosts'}, # {'name': '.gitconfig', 'path': '~', 'saved_to': '~/.gitconfig'}, # {'name': '.gitconfig', 'path': '~/.gitconfig', 'saved_to': '~/.gitconfig'}, # {'name': 'gpt-pilot.log', 'path': '/temp/gpt-pilot.log', 'saved_to': '/temp/gpt-pilot.log'}, -], ids=[ - 'name == path', 'empty path', - # 'None path', - 'None name', 'empty name', +# ], ids=[ +# 'name == path', 'empty path', +# # 'None path', +# 'None name', 'empty name', # 'None path absolute file', 'home path', 'home path same name', 'absolute path with name' ]) -@patch('helpers.Project.update_file') -@patch('database.models.files.File.insert') -def test_save_file(mock_file_insert, mock_update_file, test_data): +# @patch('helpers.Project.update_file') +@patch('helpers.Project.File') +def test_save_file(mock_file_insert, + # mock_update_file, + test_data, + # monkeypatch + mocker + ): # Given data = {'content': 'Hello World!'} if test_data['name'] is not None: @@ -45,6 +50,9 @@ def test_save_file(mock_file_insert, mock_update_file, test_data): if test_data['path'] is not None: data['path'] = test_data['path'] + mock_update_file = mocker.patch('helpers.Project.update_file', return_value=None) + + # When project.save_file(data) diff --git a/requirements.txt b/requirements.txt index 986e162..5e9ca4e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,6 +12,7 @@ prompt-toolkit==3.0.39 psycopg2-binary==2.9.6 python-dotenv==1.0.0 python-editor==1.0.4 +pytest-mock==3.11.1 questionary==1.10.0 readchar==4.0.5 regex==2023.6.3