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

Function test_cli

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

Source from the content-addressed store, hash-verified

69
70
71def test_cli(
72 template_path: str,
73 tmp_path_factory: pytest.TempPathFactory,
74 monkeypatch: pytest.MonkeyPatch,
75) -> None:
76 tmp, dst = map(tmp_path_factory.mktemp, ["tmp", "dst"])
77 _git = git["-C", dst]
78 # Mock tmp dir to assert it ends up clean
79 monkeypatch.setattr("tempfile.tempdir", str(tmp))
80 # Copy
81 run_result = CopierApp.run(
82 [
83 "copier",
84 "copy",
85 "-fqrv1",
86 template_path,
87 str(dst),
88 ],
89 exit=False,
90 )
91 assert run_result[1] == 0
92 assert (dst / "fav.txt").read_text() == "Copier"
93 assert not (dst / "v2").exists()
94 empty_dir(tmp)
95 _git("init")
96 _git("add", "-A")
97 _git("commit", "-m", "Initial commit")
98 # Recopy
99 run_result = CopierApp.run(["copier", "recopy", "-fqrv1", str(dst)], exit=False)
100 assert run_result[1] == 0
101 assert (dst / "fav.txt").read_text() == "Copier"
102 assert not (dst / "v2").exists()
103 empty_dir(tmp)
104 # Update
105 run_result = CopierApp.run(["copier", "update", "-fq", str(dst)], exit=False)
106 assert run_result[1] == 0
107 assert (dst / "fav.txt").read_text() == "Copier"
108 assert (dst / "v2").read_text() == "true"
109 empty_dir(tmp)

Callers

nothing calls this directly

Calls 1

empty_dirFunction · 0.85

Tested by

no test coverage detected