Ejemplo n.º 1
0
def test__given_files_to_collect_with_file_already_existing_on_source_fs__when_collecting__should_still_collect_remaining_files(
):
    source_fs_spy = new_mock_filesystem(["copy_file.txt"])
    target_fs = new_mock_filesystem(["file.txt", "funny.gif"])

    sut = EnvironmentPreparation(source_fs_spy, target_fs)

    sut.files_to_collect([
        CopyInstruction("file.txt", "copy_file.txt", False),
        CopyInstruction("funny.gif", "copy_funny.gif", False),
    ])

    sut.collect()

    assert source_fs_spy.exists("copy_funny.gif")
Ejemplo n.º 2
0
def test__given_files_to_collect__when_collect__should_copy_to_source_fs():
    source_fs_spy = new_mock_filesystem(["copy_file.txt"])
    target_fs = new_mock_filesystem(["file.txt", "funny.gif"])

    sut = EnvironmentPreparation(source_fs_spy, target_fs)

    sut.files_to_collect([
        CopyInstruction("file.txt", "copy_file.txt", True),
        CopyInstruction("funny.gif", "copy_funny.gif", False),
    ])

    sut.collect()

    assert source_fs_spy.exists("copy_file.txt")
    assert source_fs_spy.exists("copy_funny.gif")
Ejemplo n.º 3
0
def test__given_files_to_collect_with_file_already_existing_on_source_fs__when_collecting__should_log_error_to_ui(
):
    source_fs_spy = new_mock_filesystem(["copy_file.txt"])
    target_fs = new_mock_filesystem(["file.txt", "funny.gif"])

    ui_spy = MagicMock()
    sut = EnvironmentPreparation(source_fs_spy, target_fs, ui_spy)

    sut.files_to_collect([
        CopyInstruction("file.txt", "copy_file.txt", False),
        CopyInstruction("funny.gif", "copy_funny.gif", False),
    ])

    sut.collect()

    ui_spy.error.assert_called_with(
        "FileExistsError: Cannot copy file 'file.txt'")
Ejemplo n.º 4
0
 def _collect_files(self, env_prep: EnvironmentPreparation, ui: UI) -> None:
     env_prep.files_to_collect(self._collect)
     ui.info("Collecting files...")
     env_prep.collect()
     ui.success("Done")