diff --git a/pilot/helpers/Project.py b/pilot/helpers/Project.py index 9bc3a83..f5b5590 100644 --- a/pilot/helpers/Project.py +++ b/pilot/helpers/Project.py @@ -229,12 +229,12 @@ class Project: update_file(data['full_path'], data['content']) - # (File.insert(app=self.app, path=data['path'], name=data['name'], full_path=data['full_path']) - # .on_conflict( - # conflict_target=[File.app, File.name, File.path], - # preserve=[], - # update={'name': data['name'], 'path': data['path'], 'full_path': data['full_path']}) - # .execute()) + (File.insert(app=self.app, path=data['path'], name=data['name'], full_path=data['full_path']) + .on_conflict( + conflict_target=[File.app, File.name, File.path], + preserve=[], + update={'name': data['name'], 'path': data['path'], 'full_path': data['full_path']}) + .execute()) def get_full_file_path(self, file_path: str, file_name: str) -> Tuple[str, str]: diff --git a/pilot/helpers/test_Project.py b/pilot/helpers/test_Project.py index a7ae6f4..3ad9e24 100644 --- a/pilot/helpers/test_Project.py +++ b/pilot/helpers/test_Project.py @@ -37,14 +37,14 @@ def create_project(): # 'None name', 'empty name', # 'None path absolute file', 'home path', 'home path same name', 'absolute path with name' ]) -# @patch('helpers.Project.update_file') -# @patch('helpers.Project.File') +@patch('helpers.Project.update_file') +@patch('helpers.Project.File') def test_save_file( - # mock_file_insert, - # mock_update_file, + mock_file_insert, + mock_update_file, test_data, # monkeypatch - mocker + # mocker ): # Given data = {'content': 'Hello World!'} @@ -53,15 +53,14 @@ def test_save_file( if test_data['path'] is not None: data['path'] = test_data['path'] - mock_update_file = mocker.patch('helpers.Project.update_file', return_value=None) - mocker.patch('helpers.Project.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) - # Then assert that update_file with the correct path expected_saved_to = test_data['saved_to'] mock_update_file.assert_called_once_with(expected_saved_to, 'Hello World!')