Commit e36f73ab authored by Klaus Aehlig's avatar Klaus Aehlig

Merge branch 'stable-2.11' into stable-2.12

* stable-2.11
  Fix capitalization of TestCase
  Trigger renew-crypto on downgrade to 2.11

Conflicts:
	tools/post-upgrade: use 2.12 condition on when to run the hook
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarPetr Pudlak <pudlak@google.com>
parents ed2787f4 4b5a9759
......@@ -181,3 +181,29 @@ def IsBefore(version, major, minor, revision):
return True
return version < (major, minor, revision)
def IsEqual(version, major, minor, revision):
"""Decide if a given version matches the given version.
If the revision is set to None, only major and minor are compared.
@param version: (major, minor, revision) or None, with None being
before all versions
@type version: (int, int, int) or None
@param major: major version
@type major: int
@param minor: minor version
@type minor: int
@param revision: revision
@type revision: int
"""
if version is None:
return False
if revision is None:
current_major, current_minor, _ = version
return (current_major, current_minor) == (major, minor)
return version == (major, minor, revision)
......@@ -91,6 +91,16 @@ class IsBeforeTest(unittest.TestCase):
self.assertTrue(version.IsBefore((2, 10, 1), 2, 11, 0))
self.assertFalse(version.IsBefore((2, 11, 0), 2, 10, 3))
class IsEqualTest(unittest.TestCase):
def testIsEqual(self):
self.assertTrue(version.IsEqual((2, 10, 0), 2, 10, 0))
self.assertFalse(version.IsEqual((2, 10, 0), 2, 10, 2))
self.assertFalse(version.IsEqual((2, 10, 0), 2, 12, 0))
self.assertFalse(version.IsEqual((2, 10, 0), 3, 10, 0))
self.assertTrue(version.IsEqual((2, 10, 0), 2, 10, None))
self.assertTrue(version.IsEqual((2, 10, 5), 2, 10, None))
self.assertFalse(version.IsEqual((2, 11, 5), 2, 10, None))
self.assertFalse(version.IsEqual((3, 10, 5), 2, 10, None))
if __name__ == "__main__":
testutils.GanetiTestProgram()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment