Skip to content

Commit

Permalink
Extend testing of cmk.utils.version
Browse files Browse the repository at this point in the history
for
- invalid combos
- round trip
- stable daily rc aware and version with rc

Change-Id: Ibb68491b1a49b057ec4337aa98b94dec12cbd3bf
  • Loading branch information
JonasScharpf committed Nov 6, 2024
1 parent 08d907f commit 44ef781
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions tests/unit/cmk/utils/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,23 @@ def test_invalid_combo(self) -> None:
Version.from_str("2.2.0rc1")
with pytest.raises(ValueError):
Version.from_str("2.2.0p5-rc")
with pytest.raises(ValueError):
Version.from_str("1.2.3-2023.12.24-rc1")
with pytest.raises(ValueError):
Version.from_str("2023.12.24-rc1")

def test_roundtrip(self) -> None:
v = Version.from_str("2.3.0p34-rc42+security")
assert Version.from_str(str(v)) == v
@pytest.mark.parametrize(
"vers",
[
Version.from_str("2.3.0p34"),
Version.from_str("2.3.0p34-rc42"),
Version.from_str("2.3.0p34-rc42+security"),
Version.from_str("1.2.3-2023.12.24"),
Version.from_str("2023.12.24"),
],
)
def test_roundtrip(self, vers: Version) -> None:
assert Version.from_str(str(vers)) == vers

def test_version_base_master(self) -> None:
assert Version.from_str("1984.04.01").version_base == ""
Expand All @@ -62,6 +75,9 @@ def test_version_base_stable(self) -> None:
def test_version_base_release(self) -> None:
assert Version.from_str("4.5.6p8").version_base == "4.5.6"

def test_version_base_stable_daily(self) -> None:
assert Version.from_str("1.2.3-2023.12.24").version_base == "1.2.3"

def test_version_release_candidate(self) -> None:
assert Version.from_str("2.3.0b4-rc1").release_candidate.value == 1

Expand All @@ -77,18 +93,27 @@ def test_version_without_rc_release(self) -> None:
def test_version_without_rc_release_candidate(self) -> None:
assert Version.from_str("2.3.0b4-rc1").version_without_rc == "2.3.0b4"

def test_version_without_rc_stable_daily(self) -> None:
assert Version.from_str("1.2.3-2023.12.24").version_without_rc == "1.2.3-2023.12.24"

def test_version_rc_aware_master(self) -> None:
assert Version.from_str("1984.04.01").version_rc_aware == "1984.04.01"

def test_version_rc_aware_stable(self) -> None:
assert Version.from_str("1.2.3").version_rc_aware == "1.2.3"

def test_version_rc_aware_stable_release_candidate(self) -> None:
assert Version.from_str("1.2.3-rc1").version_rc_aware == "1.2.3-rc1"

def test_version_rc_aware_release(self) -> None:
assert Version.from_str("4.5.6p8").version_rc_aware == "4.5.6p8"

def test_version_rc_aware_release_candidate(self) -> None:
assert Version.from_str("2.3.0b4-rc1").version_rc_aware == "2.3.0b4-rc1"

def test_version_rc_aware_stable_daily(self) -> None:
assert Version.from_str("1.2.3-2023.12.24").version_rc_aware == "1.2.3-2023.12.24"

def test_version_meta_data(self) -> None:
assert Version.from_str("2.3.0p21+security").meta.value == "security"

Expand Down

0 comments on commit 44ef781

Please sign in to comment.