Merge extension-info functional tests of v2 and v2.1

Currently v2 and v2.1 have separate functional tests and their
corresponding sample files. As v2 and v2.1 are supposed to be identical,
there is overhead to maintain two set of functional tests and sample files.
We can have one set of tests which can run for both v2 and v2.1.

This commit merges extension-info functional tests.

ExtensionInfoSamplesJsonTest is v3 only, leave it as before.

ExtensionInfoAllSamplesJsonTest, the response data is different,
tag the template files with version.

Change-Id: Id7b7bf08cda58d606325ddb82568a73f0bb99f60
This commit is contained in:
parklong 2015-04-07 11:08:03 +08:00
parent 88dcf64b47
commit 6ccc90ec1a
4 changed files with 13 additions and 10 deletions

View File

@ -197,15 +197,6 @@ class ServersSampleMultiStatusJsonTest(ServersSampleBase):
self._verify_response('servers-list-resp', subs, response, 200)
class ExtensionsSampleJsonTest(ApiSampleTestBaseV2):
all_extensions = True
def test_extensions_get(self):
response = self._do_get('extensions')
subs = self._get_regexes()
self._verify_response('extensions-get-resp', subs, response, 200)
class FlavorsSampleJsonTest(ApiSampleTestBaseV2):
sample_dir = 'flavors'

View File

@ -14,10 +14,15 @@
# under the License.
import mock
from oslo_config import cfg
from nova.api.openstack import extensions as api_extensions
from nova.tests.functional.v3 import api_sample_base
CONF = cfg.CONF
CONF.import_opt('osapi_compute_extension',
'nova.api.openstack.compute.extensions')
def fake_soft_extension_authorizer(extension_name, core=False):
def authorize(context, action=None):
@ -27,13 +32,20 @@ def fake_soft_extension_authorizer(extension_name, core=False):
class ExtensionInfoAllSamplesJsonTest(api_sample_base.ApiSampleTestBaseV3):
all_extensions = True
# TODO(park): Overriding '_api_version' till all functional tests
# are merged between v2 and v2.1. After that base class variable
# itself can be changed to 'v2'
_api_version = 'v2'
@mock.patch.object(api_extensions, 'os_compute_soft_authorizer')
def test_list_extensions(self, soft_auth):
soft_auth.side_effect = fake_soft_extension_authorizer
response = self._do_get('extensions')
subs = self._get_regexes()
self._verify_response('extensions-list-resp', subs, response, 200)
template = 'extensions-list-resp'
if self._test == 'v2':
template = 'extensions-list-resp-v2'
self._verify_response(template, subs, response, 200)
class ExtensionInfoSamplesJsonTest(api_sample_base.ApiSampleTestBaseV3):