def test__given_files_to_clean_with_non_existing_files__when_cleaning__should_still_clean_remaining_files( ): source_fs_spy = new_mock_filesystem() target_fs = new_mock_filesystem(["funny.gif"]) sut = EnvironmentPreparation(source_fs_spy, target_fs) sut.files_to_clean([ "file.txt", "funny.gif", ]) sut.clean() assert target_fs.exists("funny.gif") is False
def test__given_files_to_clean__when_cleaning__should_delete_files(): source_fs = new_mock_filesystem() target_fs_spy = new_mock_filesystem(["file.txt", "funny.gif"]) sut = EnvironmentPreparation(source_fs, target_fs_spy) sut.files_to_clean([ "file.txt", "funny.gif", ]) sut.clean() assert target_fs_spy.exists("file.txt") is False assert target_fs_spy.exists("funny.gif") is False
def test__given_files_to_clean_with_non_existing_files__when_cleaning__should_log_error_to_ui( ): source_fs_spy = new_mock_filesystem() target_fs = new_mock_filesystem(["funny.gif"]) ui_spy = MagicMock() sut = EnvironmentPreparation(source_fs_spy, target_fs, ui_spy) sut.files_to_clean([ "file.txt", "funny.gif", ]) sut.clean() ui_spy.error.assert_called_with( "FileNotFoundError: Cannot delete file 'file.txt'")
def _clean_files(self, env_prep: EnvironmentPreparation, ui: UI) -> None: env_prep.files_to_clean(self._clean) ui.info("Cleaning files...") env_prep.clean() ui.success("Done")