Move V2 sample files to respective directory

Some sample files like server, images etc are kept under api_samples/
directory.
As plan is to create clean directory structure for sample files for
V2, V2.1 and microversion, moving these sample files to respective directory
will help to achieve that.

Change-Id: I284d035f6fadb26a94bcb3586f4a8c72942ee423
This commit is contained in:
ghanshyam 2015-03-03 17:25:31 +09:00 committed by Ghanshyam Mann
parent 83be099a7a
commit f2cc1bd7bc
76 changed files with 25 additions and 2 deletions

View File

@ -32,6 +32,7 @@ class ApiSampleTestBase(integrated_helpers._IntegratedTestBase):
ctype = 'json'
all_extensions = False
extension_name = None
sample_dir = None
request_api_version = None
_use_common_server_api_samples = False
@ -54,8 +55,13 @@ class ApiSampleTestBase(integrated_helpers._IntegratedTestBase):
if cls.all_extensions:
parts.append('all_extensions')
# Note(gmann): if _use_common_server_api_samples is set to True
# then common server sample files will be used.
if not cls._use_common_server_api_samples and cls.extension_name:
# then common server sample files present in 'servers' directory
# will be used.
elif cls._use_common_server_api_samples:
parts.append('servers')
elif cls.sample_dir:
parts.append(cls.sample_dir)
elif cls.extension_name:
alias = importutils.import_class(cls.extension_name).alias
parts.append(alias)
parts.append(name + "." + cls.ctype + suffix)

View File

@ -161,6 +161,8 @@ class ApiSamplesTrap(ApiSampleTestBaseV2):
class VersionsSampleJsonTest(ApiSampleTestBaseV2):
sample_dir = 'versions'
def test_versions_get(self):
response = self._do_get('', strip_version=True)
subs = self._get_regexes()
@ -192,6 +194,8 @@ class ServersSampleBase(ApiSampleTestBaseV2):
class ServersSampleJsonTest(ServersSampleBase):
sample_dir = 'servers'
def test_servers_post(self):
return self._post_server()
@ -228,6 +232,7 @@ class ServersSampleAllExtensionJsonTest(ServersSampleJsonTest):
class ServersSampleHideAddressesJsonTest(ServersSampleJsonTest):
sample_dir = None
extension_name = '.'.join(('nova.api.openstack.compute.contrib',
'hide_server_addresses',
'Hide_server_addresses'))
@ -247,6 +252,8 @@ class ServersSampleMultiStatusJsonTest(ServersSampleBase):
class ServersMetadataJsonTest(ServersSampleBase):
sample_dir = 'servers'
def _create_and_set(self, subs):
uuid = self._post_server()
response = self._do_put('servers/%s/metadata' % uuid,
@ -308,6 +315,8 @@ class ServersMetadataJsonTest(ServersSampleBase):
class ServersIpsJsonTest(ServersSampleBase):
sample_dir = 'servers'
def test_get(self):
# Test getting a server's IP information.
uuid = self._post_server()
@ -333,6 +342,7 @@ class ExtensionsSampleJsonTest(ApiSampleTestBaseV2):
class FlavorsSampleJsonTest(ApiSampleTestBaseV2):
sample_dir = 'flavors'
def test_flavors_get(self):
response = self._do_get('flavors/1')
@ -386,6 +396,8 @@ class FlavorsSampleAllExtensionJsonTest(FlavorsSampleJsonTest):
class ImagesSampleJsonTest(ApiSampleTestBaseV2):
sample_dir = 'images'
def test_images_list(self):
# Get api sample of images get list request.
response = self._do_get('images')
@ -450,6 +462,8 @@ class ImagesSampleJsonTest(ApiSampleTestBaseV2):
class LimitsSampleJsonTest(ApiSampleTestBaseV2):
sample_dir = 'limits'
def test_limits_get(self):
response = self._do_get('limits')
subs = self._get_regexes()
@ -457,6 +471,8 @@ class LimitsSampleJsonTest(ApiSampleTestBaseV2):
class ServersActionsJsonTest(ServersSampleBase):
sample_dir = 'servers'
def _test_server_action(self, uuid, action,
subs=None, resp_tpl=None, code=202):
subs = subs or {}
@ -4057,6 +4073,7 @@ class ServerGroupsSampleJsonTest(ServersSampleBase):
class ServerGroupQuotas_LimitsSampleJsonTest(LimitsSampleJsonTest):
sample_dir = None
extension_name = ("nova.api.openstack.compute.contrib."
"server_group_quotas.Server_group_quotas")