Fix lower_version: versions cannot be negative numbers

property lower_version always substracted 1 from the microversion,
without considering the resulting value could be negative

Change-Id: I08b5635186105e2ada712e0359a73f4888c9e517
This commit is contained in:
Eduardo Olivares 2022-08-04 11:43:42 +02:00
parent 212c9958d5
commit 8c8dd5bb21
2 changed files with 22 additions and 2 deletions

View File

@ -170,11 +170,21 @@ class OvercloudProcessesTest(testtools.TestCase):
@tripleo.skip_if_missing_undercloud
class OvercloudVersionTest(unittest.TestCase):
# TODO(eolivare): move the properties to a common class, since they are
# duplicate in OvercloudVersionTest and UndercloudVersionTest
@property
def lower_version(self) -> str:
v = tripleo.overcloud_version()
return f"{v.major}.{v.minor}.{v.micro - 1}"
if v.micro > 0:
lower_v = f"{v.major}.{v.minor}.{v.micro - 1}"
elif v.minor > 0:
lower_v = f"{v.major}.{v.minor -1}.{v.micro}"
elif v.major > 0:
lower_v = f"{v.major -1}.{v.minor}.{v.micro}"
else:
raise ValueError(f"wrong version: {v}")
return lower_v
@property
def same_version(self) -> str:

View File

@ -78,11 +78,21 @@ class UndercloudKeystoneClientTest(testtools.TestCase):
@tripleo.skip_if_missing_undercloud
class UndercloudVersionTest(unittest.TestCase):
# TODO(eolivare): move the properties to a common class, since they are
# duplicate in OvercloudVersionTest and UndercloudVersionTest
@property
def lower_version(self) -> str:
v = tripleo.undercloud_version()
return f"{v.major}.{v.minor}.{v.micro - 1}"
if v.micro > 0:
lower_v = f"{v.major}.{v.minor}.{v.micro - 1}"
elif v.minor > 0:
lower_v = f"{v.major}.{v.minor -1}.{v.micro}"
elif v.major > 0:
lower_v = f"{v.major -1}.{v.minor}.{v.micro}"
else:
raise ValueError(f"wrong version: {v}")
return lower_v
@property
def same_version(self) -> str: