Module: check_mk
Branch: master
Commit: c1f299c99c1aa44b1de5875e9dd00be4321d660f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c1f299c99c1aa4…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Jun 12 10:31:53 2017 +0200
Added git test to prevent adding werks with wrong versions to version branches
Change-Id: Ia6ab0a5d0baaa417335bb070d6736b603968ee6e
---
tests/lib/test_werks.py | 22 ++++++++++++++++++++++
tests/testlib/__init__.py | 4 ++++
2 files changed, 26 insertions(+)
diff --git a/tests/lib/test_werks.py b/tests/lib/test_werks.py
index 8a4c06b..7b38e4e 100644
--- a/tests/lib/test_werks.py
+++ b/tests/lib/test_werks.py
@@ -61,3 +61,25 @@ def test_write_precompiled_werks(tmpdir, site, monkeypatch):
merged_werks.update(cmc_werks)
assert merged_werks == werks_loaded
+
+
+def test_werk_versions(site):
+ import cmk_base.utils
+
+ # All versions are allowed in master branch. We only want to ensure that version
specific
+ # branches don't have werks with newer version numbers.
+ v = cmk.omd_version()
+ if cmk_base.utils.is_daily_build_version(v):
+ branch = cmk_base.utils.branch_of_daily_build(v)
+ if branch == "master":
+ return
+ else:
+ v = branch
+
+ parsed_version = cmk.werks.parse_check_mk_version(v)
+
+ for werk_id, werk in cmk.werks.load().items():
+ parsed_werk_version =
cmk.werks.parse_check_mk_version(werk["version"])
+
+ assert parsed_werk_version <= parsed_version, \
+ "Version %s of werk #%d is not allowed in this branch" %
(werk["version"], werk_id)
diff --git a/tests/testlib/__init__.py b/tests/testlib/__init__.py
index 274aabd..af416c2 100644
--- a/tests/testlib/__init__.py
+++ b/tests/testlib/__init__.py
@@ -104,6 +104,10 @@ class CMKVersion(object):
self.version = version
+ def branch(self):
+ return self._branch
+
+
def edition(self):
return self.edition_short == CMKVersion.CRE and "raw" or
"enterprise"