Optimize microversion support
This changes is prepare to use microversion. This way is better to use version number and record the microversion change history in this architecture. If we want to add a microversion, we just need to add a constant parameter in [1](e.g. MINOR_1_PROJECT_ID=1) and update the MINOR_MAX_VERSION to MINOR_1_PROJECT_ID. [1] https://review.opendev.org/#/c/746282/6/cyborg/api/controllers/v2/versions.py@27 Change-Id: If2a2bc8178a6ee073f9e7cc6ac65df51f3034fa2
This commit is contained in:
parent
40259a25ec
commit
9179ed3053
@ -0,0 +1,18 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
import pecan
|
||||||
|
|
||||||
|
|
||||||
|
request = pecan.request
|
||||||
|
response = pecan.response
|
||||||
|
del pecan
|
@ -17,9 +17,26 @@
|
|||||||
# This is the version 2 API
|
# This is the version 2 API
|
||||||
BASE_VERSION = 2
|
BASE_VERSION = 2
|
||||||
|
|
||||||
|
|
||||||
|
# Here goes a short log of changes in every version.
|
||||||
|
# Refer to cyborg/api/rest_api-version-history.rst for a detailed
|
||||||
|
# explanation of what each version contains.
|
||||||
|
#
|
||||||
|
# v2.0: Initial minor version.
|
||||||
|
MINOR_0_INITIAL_VERSION = 0
|
||||||
|
|
||||||
|
|
||||||
|
# When adding another version, update:
|
||||||
|
# - MINOR_MAX_VERSION
|
||||||
|
# - cyborg/api/rest_api-version-history.rst with a detailed
|
||||||
|
# explanation of what changed in the new version
|
||||||
|
|
||||||
|
|
||||||
|
MINOR_MAX_VERSION = MINOR_0_INITIAL_VERSION
|
||||||
|
|
||||||
# String representations of the minor and maximum versions
|
# String representations of the minor and maximum versions
|
||||||
_MIN_VERSION_STRING = "2.0"
|
_MIN_VERSION_STRING = '{}.{}'.format(BASE_VERSION, MINOR_0_INITIAL_VERSION)
|
||||||
_MAX_VERSION_STRING = "2.0"
|
_MAX_VERSION_STRING = '{}.{}'.format(BASE_VERSION, MINOR_MAX_VERSION)
|
||||||
|
|
||||||
|
|
||||||
def service_type_string():
|
def service_type_string():
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from cyborg.api.controllers.v2 import versions
|
||||||
from cyborg.tests.unit.api.controllers.v2 import base as v2_test
|
from cyborg.tests.unit.api.controllers.v2 import base as v2_test
|
||||||
|
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ class TestAPI(v2_test.APITestV2):
|
|||||||
def test_get_api_v2(self):
|
def test_get_api_v2(self):
|
||||||
data = self.get_json('/', headers=self.headers)
|
data = self.get_json('/', headers=self.headers)
|
||||||
self.assertEqual(data['status'], "CURRENT")
|
self.assertEqual(data['status'], "CURRENT")
|
||||||
self.assertEqual(data['max_version'], "2.0")
|
self.assertEqual(data['max_version'], versions._MAX_VERSION_STRING)
|
||||||
self.assertEqual(data['id'], "v2.0")
|
self.assertEqual(data['id'], "v2.0")
|
||||||
result = isinstance(data['links'], list)
|
result = isinstance(data['links'], list)
|
||||||
self.assertTrue(result)
|
self.assertTrue(result)
|
||||||
|
Loading…
Reference in New Issue
Block a user