def test_werk_versions(precompiled_werks): parsed_version = cmk_version.Version(cmk_version.__version__) for werk_id, werk in cmk.utils.werks.load().items(): parsed_werk_version = cmk_version.Version(werk["version"]) assert ( parsed_werk_version <= parsed_version ), "Version %s of werk #%d is not allowed in this branch" % (werk["version"], werk_id)
def test_werk_versions_after_tagged(precompiled_werks): list_of_offenders = [] for werk_id, werk in cmk.utils.werks.load().items(): if werk_id < 8800: continue # Do not care about older versions for the moment # Some werks were added after the version was released. Mostly they were forgotten by # the developer. Consider it a hall of shame ;) if werk_id in {10062, 10063, 10064, 10125, 12836}: continue tag_name = "v%s" % werk["version"] if not _git_tag_exists(tag_name): # print "No tag found in git: %s. Assuming version was not released yet." % tag_name continue if not _werk_exists_in_git_tag(tag_name, ".werks/%d" % werk_id): werk_tags = sorted( _tags_containing_werk(werk_id), key=lambda t: cmk_version.Version(t[1:]), ) list_of_offenders.append( (werk_id, werk["version"], tag_name, werk_tags[0] if werk_tags else "-") ) assert not list_of_offenders, ( "The following Werks are not found in the git tag corresponding to their Version. " "Looks like the wrong version was declared in these werks:\n" + "\n".join( "Werk #%d has version %s, not found in git tag %s, first found in %s" % entry for entry in list_of_offenders ) )
def test_version_comparison(version_str_a, version_str_b): a = cmk_version.Version(version_str_a) b = cmk_version.Version(version_str_b) assert a > b
def test_old_parse_check_mk_version_equals_new_version_class(version_str): assert ( cmk_version.parse_check_mk_version(version_str) == cmk_version.Version(version_str).parse_to_int() )