def test_templated_prompt_custom_envops(tmp_path): conf = make_config("./tests/demo_templated_prompt", tmp_path, force=True) assert conf.data["sentence"] == "It's over 9000!" conf = make_config("./tests/demo_templated_prompt", tmp_path, data={"powerlevel": 1}, force=True) assert conf.data["sentence"] == "It's only 1..."
def test_make_config_good_data(tmp_path): conf = make_config("./tests/demo_data", tmp_path) assert conf is not None assert "_folder_name" in conf.data assert conf.data["_folder_name"] == tmp_path.name assert conf.exclude == ["exclude1", "exclude2"] assert conf.skip_if_exists == ["skip_if_exists1", "skip_if_exists2"] assert conf.tasks == ["touch 1", "touch 2"] assert conf.extra_paths == [Path("tests").resolve()]
def test_make_config_good_data(dst): conf, flags = make_config("./tests/demo_data", dst) assert conf is not None assert flags is not None assert "folder_name" in conf.data assert conf.data["folder_name"] == dst.name assert conf.exclude == ["exclude1", "exclude2"] assert conf.include == ["include1", "include2"] assert conf.skip_if_exists == ["skip_if_exists1", "skip_if_exists2"] assert conf.tasks == ["touch 1", "touch 2"] assert conf.extra_paths == [Path("tests").resolve()]
def test_minimum_version_update(tmp_path, monkeypatch): monkeypatch.setattr("copier.__version__", "99.99.99") copier.copy("./tests/demo_minimum_version", tmp_path) with local.cwd(tmp_path): git("init") git("config", "user.name", "Copier Test") git("config", "user.email", "test@copier") git("add", ".") git("commit", "-m", "hello world") monkeypatch.setattr("copier.__version__", "0.0.0") with pytest.raises(UserMessageError): make_config("./tests/demo_minimum_version", tmp_path) monkeypatch.setattr("copier.__version__", "10.5.1") # assert no error make_config("./tests/demo_minimum_version", tmp_path) monkeypatch.setattr("copier.__version__", "99.99.99") # assert no error make_config("./tests/demo_minimum_version", tmp_path)
def test_make_config_precedence(tmp_path, test_input, expected): conf = make_config(dst_path=tmp_path, vcs_ref="HEAD", **test_input) assert is_subdict(expected, conf.dict())
def test_make_config_bad_data(tmp_path): with pytest.raises(ValidationError): make_config("./i_do_not_exist", tmp_path)
def test_make_config_precedence(dst, test_input, expected): conf, flags = make_config(dst_path=dst, **test_input) assert is_subdict(expected, conf.dict())
def test_version_less_than_required(monkeypatch): monkeypatch.setattr("copier.__version__", "0.0.0") with pytest.raises(UserMessageError): make_config("./tests/demo_minimum_version")
def test_version_greater_than_required(monkeypatch): monkeypatch.setattr("copier.__version__", "99.99.99") # assert no error make_config("./tests/demo_minimum_version")
def test_version_equal_required(monkeypatch): monkeypatch.setattr("copier.__version__", "10.5.1") # assert no error make_config("./tests/demo_minimum_version")
def test_version_0_0_0_ignored(monkeypatch): monkeypatch.setattr("copier.__version__", "0.0.0") # assert no error make_config("./tests/demo_minimum_version")