Esempio n. 1
0
def test_empty(tmp_path: Path):

    (tmp_path / "source").mkdir()
    (tmp_path / "target").mkdir()

    merge(tmp_path / "source", tmp_path / "target")

    assert_same_index(index(tmp_path / "target"), {"."})
Esempio n. 2
0
def test_invalid_target(relative_path: str, tmp_path: Path):

    (tmp_path / "source").mkdir()
    (tmp_path / "file").touch()
    (tmp_path / "symlink").symlink_to(tmp_path / "file")

    with pytest.raises(ValueError):

        merge(tmp_path / "source", tmp_path / relative_path)
Esempio n. 3
0
def test_file_replaced_by_dir(tmp_path: Path):

    (tmp_path / "source").mkdir()
    (tmp_path / "source/foo").mkdir()
    (tmp_path / "target").mkdir()
    (tmp_path / "target/foo").touch()

    merge(tmp_path / "source", tmp_path / "target", overwrite=True)

    assert (tmp_path / "target/foo").is_dir()
Esempio n. 4
0
def test_collision_detection_dir_and_file(tmp_path: Path):

    (tmp_path / "source").mkdir()
    (tmp_path / "source/foo").mkdir()
    (tmp_path / "target").mkdir()
    (tmp_path / "target/foo").touch()

    with pytest.raises(ValueError):

        merge(tmp_path / "source", tmp_path / "target")
Esempio n. 5
0
def test_file_replaced_by_file(tmp_path: Path):

    (tmp_path / "source").mkdir()
    (tmp_path / "source/foo").write_text("foo")
    (tmp_path / "target").mkdir()
    (tmp_path / "target/foo").write_text("bar")

    merge(tmp_path / "source", tmp_path / "target", overwrite=True)

    assert (tmp_path / "target/foo").read_text() == "foo"
Esempio n. 6
0
def test_no_collisions(tmp_path: Path):

    (tmp_path / "source").mkdir()
    (tmp_path / "source/file1").touch()
    (tmp_path / "source/dir1").mkdir()
    (tmp_path / "source/dir1/file2").touch()

    (tmp_path / "target").mkdir()
    (tmp_path / "target/file3").touch()
    (tmp_path / "target/dir1").mkdir()
    (tmp_path / "target/dir1/file4").touch()

    merge(tmp_path / "source", tmp_path / "target")

    assert_same_index(index(tmp_path / "target"), {
        ".",
        "file1",
        "file3",
        "dir1",
        "dir1/file2",
        "dir1/file4",
    })