From bb027fcd2d9cb8ed1ac7ef77e553697af8ce121f Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Wed, 19 Apr 2017 20:39:20 +0800 Subject: [PATCH] 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 --- .../api/openstack/placement/test_microversion.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/nova/tests/unit/api/openstack/placement/test_microversion.py b/nova/tests/unit/api/openstack/placement/test_microversion.py index 992f10837..22e631703 100644 --- a/nova/tests/unit/api/openstack/placement/test_microversion.py +++ b/nova/tests/unit/api/openstack/placement/test_microversion.py @@ -156,3 +156,18 @@ class TestMicroversionUtility(test.NoDBTestCase): self.assertRaises(KeyError, microversion.raise_http_status_code_if_not_version, 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]