Skip to content

Commit 3fe96f0

Browse files
committed
Fixed test coverage
1 parent a53cddc commit 3fe96f0

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tests/test_cli.py

+44
Original file line numberDiff line numberDiff line change
@@ -385,3 +385,47 @@ def test_replace(mocker, tmp_path, fixtures_path):
385385
assert len(configured_files) == 3
386386
actual_filenames = {f.path for f in configured_files}
387387
assert actual_filenames == {"setup.py", "CHANGELOG.md", "bumpversion/__init__.py"}
388+
389+
390+
def test_replace_no_newversion(mocker, tmp_path, fixtures_path):
391+
"""The replace subcommand should set new_version to None in the context."""
392+
# Arrange
393+
toml_path = fixtures_path / "basic_cfg.toml"
394+
config_path = tmp_path / "pyproject.toml"
395+
shutil.copy(toml_path, config_path)
396+
397+
mocked_modify_files = mocker.patch("bumpversion.cli.modify_files")
398+
runner: CliRunner = CliRunner()
399+
with inside_dir(tmp_path):
400+
result: Result = runner.invoke(cli.cli, ["replace"])
401+
402+
if result.exit_code != 0:
403+
print(result.output)
404+
405+
assert result.exit_code == 0
406+
407+
call_args = mocked_modify_files.call_args[0]
408+
assert call_args[2] is None
409+
410+
411+
def test_replace_specific_files(mocker, git_repo, fixtures_path):
412+
"""The replace subcommand should set the files to only the specified files."""
413+
# Arrange
414+
toml_path = fixtures_path / "basic_cfg.toml"
415+
config_path = git_repo / "pyproject.toml"
416+
shutil.copy(toml_path, config_path)
417+
418+
mocked_modify_files = mocker.patch("bumpversion.cli.modify_files")
419+
runner: CliRunner = CliRunner()
420+
with inside_dir(git_repo):
421+
result: Result = runner.invoke(cli.cli, ["replace", "--no-configured-files", "VERSION"])
422+
423+
if result.exit_code != 0:
424+
print(result.output)
425+
426+
assert result.exit_code == 0
427+
428+
call_args = mocked_modify_files.call_args[0]
429+
configured_files = call_args[0]
430+
assert len(configured_files) == 1
431+
assert configured_files[0].path == "VERSION"

0 commit comments

Comments
 (0)