Adding Unit Test Cases for cloudpulse api
Partially implements: blueprint unit-tests Change-Id: Ib912b24efeba0ad3a54c6b3fafbb8f7c7e6fab43
This commit is contained in:
@@ -22,6 +22,7 @@ import datetime
|
||||
|
||||
import pecan
|
||||
from pecan import rest
|
||||
from webob import exc
|
||||
import wsme
|
||||
from wsme import types as wtypes
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
@@ -29,6 +30,17 @@ import wsmeext.pecan as wsme_pecan
|
||||
from cloudpulse.api.controllers import link
|
||||
from cloudpulse.api.controllers.v1 import cpulse
|
||||
|
||||
BASE_VERSION = 1
|
||||
|
||||
MIN_VER_STR = '1.1'
|
||||
|
||||
# v1.1: Add API changelog here
|
||||
MAX_VER_STR = '1.1'
|
||||
|
||||
|
||||
MIN_VER = '1.1'
|
||||
MAX_VER = '1.1'
|
||||
|
||||
|
||||
class APIBase(wtypes.Base):
|
||||
|
||||
@@ -112,4 +124,25 @@ class Controller(rest.RestController):
|
||||
# the request object to make the links.
|
||||
return V1.convert()
|
||||
|
||||
def _check_version(self, version, headers=None):
|
||||
if headers is None:
|
||||
headers = {}
|
||||
# ensure that major version in the URL matches the header
|
||||
if version.major != BASE_VERSION:
|
||||
raise exc.HTTPNotAcceptable(_(
|
||||
"Mutually exclusive versions requested. Version %(ver)s "
|
||||
"requested but not supported by this service."
|
||||
"The supported version range is: "
|
||||
"[%(min)s, %(max)s].") % {'ver': version,
|
||||
'min': MIN_VER_STR,
|
||||
'max': MAX_VER_STR},
|
||||
headers=headers)
|
||||
# ensure the minor version is within the supported range
|
||||
if version < MIN_VER or version > MAX_VER:
|
||||
raise exc.HTTPNotAcceptable(_(
|
||||
"Version %(ver)s was requested but the minor version is not "
|
||||
"supported by this service. The supported version range is: "
|
||||
"[%(min)s, %(max)s].") % {'ver': version, 'min': MIN_VER_STR,
|
||||
'max': MAX_VER_STR}, headers=headers)
|
||||
|
||||
__all__ = (Controller)
|
||||
|
||||
Reference in New Issue
Block a user