Skip to content

Commit

Permalink
Add: Extend tests for verifying the version in Python projects
Browse files Browse the repository at this point in the history
Ensure that `pontos-version verify current` works for Python projects as
expected.
  • Loading branch information
bjoernricks committed Mar 3, 2023
1 parent c4ae708 commit 83ca1bc
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions tests/version/test_python_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,12 @@ def test_current_version_not_equal_pyproject_toml_version(self):
PythonVersionCommand,
"version_file_path",
new=PropertyMock(return_value=fake_version_py),
), self.assertRaisesRegex(
VersionError,
"The version .* in .* doesn't match the current version .*.",
):
cmd = PythonVersionCommand()
with self.assertRaisesRegex(
VersionError,
"The version .* in .* doesn't match the current version .*.",
):
cmd.verify_version(Version("1.2.3"))
cmd.verify_version(Version("1.2.3"))

def test_current_version(self):
fake_version_py = Path("foo.py")
Expand All @@ -287,6 +286,30 @@ def test_current_version(self):
cmd = PythonVersionCommand()
cmd.verify_version("current")

def test_current_failure(self):
fake_version_py = Path("foo.py")
content = (
'[tool.poetry]\nversion = "1.2.4"\n'
'[tool.pontos.version]\nversion-module-file = "foo.py"'
)

with temp_file(
content, name="pyproject.toml", change_into=True
), patch.object(
PythonVersionCommand,
"get_current_version",
MagicMock(return_value=Version("1.2.3")),
), patch.object(
PythonVersionCommand,
"version_file_path",
new=PropertyMock(return_value=fake_version_py),
), self.assertRaisesRegex(
VersionError,
"The version .* in .* doesn't match the current version .*.",
):
cmd = PythonVersionCommand()
cmd.verify_version("current")

def test_provided_version_missmatch(self):
fake_version_py = Path("foo.py")
content = (
Expand Down

0 comments on commit 83ca1bc

Please sign in to comment.