示例#1
0
def test__given_files_to_clean__but_not_cleaning__should_not_do_anything():
    source_fs = new_mock_filesystem()
    target_fs_spy = new_mock_filesystem(["file1.txt"])

    sut = EnvironmentPreparation(source_fs, target_fs_spy)
    sut.files_to_clean(["file1.txt"])

    assert target_fs_spy.exists("file1.txt")
示例#2
0
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
示例#3
0
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
示例#4
0
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'")
示例#5
0
 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")