MCPcopy Create free account
hub / github.com/copier-org/copier / test_api

Function test_api

tests/test_tmpdir.py:42–68  ·  view source on GitHub ↗
(
    template_path: str,
    tmp_path_factory: pytest.TempPathFactory,
    monkeypatch: pytest.MonkeyPatch,
)

Source from the content-addressed store, hash-verified

40
41
42def test_api(
43 template_path: str,
44 tmp_path_factory: pytest.TempPathFactory,
45 monkeypatch: pytest.MonkeyPatch,
46) -> None:
47 tmp, dst = map(tmp_path_factory.mktemp, ["tmp", "dst"])
48 _git = git["-C", dst]
49 # Mock tmp dir to assert it ends up clean
50 monkeypatch.setattr("tempfile.tempdir", str(tmp))
51 # Copy
52 run_copy(template_path, dst, vcs_ref="v1", quiet=True, defaults=True)
53 assert (dst / "fav.txt").read_text() == "Copier"
54 assert not (dst / "v2").exists()
55 _git("init")
56 _git("add", "-A")
57 _git("commit", "-m", "Initial commit")
58 empty_dir(tmp)
59 # Recopy
60 run_recopy(dst, vcs_ref="v1", quiet=True, defaults=True)
61 assert (dst / "fav.txt").read_text() == "Copier"
62 assert not (dst / "v2").exists()
63 empty_dir(tmp)
64 # Update
65 run_update(dst, quiet=True, defaults=True, overwrite=True)
66 assert (dst / "fav.txt").read_text() == "Copier"
67 assert (dst / "v2").read_text() == "true"
68 empty_dir(tmp)
69
70
71def test_cli(

Callers

nothing calls this directly

Calls 4

run_copyFunction · 0.90
run_recopyFunction · 0.90
run_updateFunction · 0.90
empty_dirFunction · 0.85

Tested by

no test coverage detected