From bb6a2b6a885263da29facdeac6adfa12f7327550 Mon Sep 17 00:00:00 2001 From: Nicholas Albion Date: Wed, 4 Oct 2023 17:38:33 +1100 Subject: [PATCH] create Project after mocking --- pilot/helpers/test_Project.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/pilot/helpers/test_Project.py b/pilot/helpers/test_Project.py index 5fd4532..8c36a95 100644 --- a/pilot/helpers/test_Project.py +++ b/pilot/helpers/test_Project.py @@ -4,17 +4,19 @@ from helpers.Project import Project from database.models.files import File -project = Project({ +def create_project(): + project = Project({ 'app_id': 'test-project', 'name': 'TestProject', 'app_type': '' }, - name='TestProject', - architecture=[], - user_stories=[] -) -project.root_path = "/temp/gpt-pilot-test" -project.app = 'test' + name='TestProject', + architecture=[], + user_stories=[] + ) + project.root_path = "/temp/gpt-pilot-test" + project.app = 'test' + return project @pytest.mark.parametrize('test_data', [ @@ -54,6 +56,7 @@ def test_save_file( mock_update_file = mocker.patch('helpers.Project.update_file', return_value=None) mocker.patch('helpers.Project.File') + project = create_project() # When project.save_file(data) @@ -79,6 +82,10 @@ def test_save_file( ('./path/to/file.txt', 'file.txt', '/temp/gpt-pilot-test/./path/to/file.txt'), # ideally result would not have `./` ]) def test_get_full_path(file_path, file_name, expected): + # Given + project = create_project() + + # When relative_path, absolute_path = project.get_full_file_path(file_path, file_name) # Then @@ -93,6 +100,10 @@ def test_get_full_path(file_path, file_name, expected): ('~/path/to/file.txt', 'file.txt', '~/path/to/file.txt'), ]) def test_get_full_path_absolute(file_path, file_name, expected): + # Given + project = create_project() + + # When relative_path, absolute_path = project.get_full_file_path(file_path, file_name) # Then