Add test ensure all the microversions are sequential in placement API

It is easy to make mistake when added multiple versioned methods and it
generates a gap between mulitple versioned methods. This test ensures no
gap between each versioned method.

Change-Id: Ib91eba000ecd4ce28f51e44cc74be32fc2200a2f
This commit is contained in:
He Jie Xu 2017-04-19 20:39:20 +08:00
parent 36aa8b3782
commit bb027fcd2d

View File

@ -156,3 +156,18 @@ class TestMicroversionUtility(test.NoDBTestCase):
self.assertRaises(KeyError, self.assertRaises(KeyError,
microversion.raise_http_status_code_if_not_version, microversion.raise_http_status_code_if_not_version,
self.req, 999, '1.5') self.req, 999, '1.5')
class MicroversionSequentialTest(test.NoDBTestCase):
def test_microversion_sequential(self):
for method_name, method_list in microversion.VERSIONED_METHODS.items():
previous_min_version = method_list[0][0]
for method in method_list[1:]:
previous_min_version = microversion.parse_version_string(
'%s.%s' % (previous_min_version.major,
previous_min_version.minor - 1))
self.assertEqual(previous_min_version, method[1],
"The microversions aren't sequential in the mehtod %s" %
method_name)
previous_min_version = method[0]