Merge flavor_manage 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 flavor_manage functional tests.

This commit also tags FlavorManageSampleJsonTests as ADMIN_API to avoid
AuthenticationException when create a test flavor

Change-Id: I5fe68870285cfee2b3254184209a7111b24f7223
This commit is contained in:
parklong 2015-04-02 14:39:41 +08:00
parent ef42f74a07
commit 5fb5170adf
8 changed files with 35 additions and 89 deletions

View File

@ -1,9 +0,0 @@
{
"flavor": {
"name": "test_flavor",
"ram": 1024,
"vcpus": 2,
"disk": 10,
"id": "10"
}
}

View File

@ -1,19 +0,0 @@
{
"flavor": {
"disk": 10,
"id": "10",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/10",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/10",
"rel": "bookmark"
}
],
"name": "test_flavor",
"ram": 1024,
"vcpus": 2
}
}

View File

@ -7,11 +7,11 @@
"id": "10",
"links": [
{
"href": "http://openstack.example.com/v3/flavors/10",
"href": "http://openstack.example.com/v2/openstack/flavors/10",
"rel": "self"
},
{
"href": "http://openstack.example.com/flavors/10",
"href": "http://openstack.example.com/openstack/flavors/10",
"rel": "bookmark"
}
],

View File

@ -1,9 +0,0 @@
{
"flavor": {
"name": "%(flavor_name)s",
"ram": 1024,
"vcpus": 2,
"disk": 10,
"id": "%(flavor_id)s"
}
}

View File

@ -1,19 +0,0 @@
{
"flavor": {
"disk": 10,
"id": "%(flavor_id)s",
"links": [
{
"href": "%(host)s/v2/openstack/flavors/%(flavor_id)s",
"rel": "self"
},
{
"href": "%(host)s/openstack/flavors/%(flavor_id)s",
"rel": "bookmark"
}
],
"name": "%(flavor_name)s",
"ram": 1024,
"vcpus": 2
}
}

View File

@ -1849,35 +1849,6 @@ class ExtendedVIFNetSampleJsonTests(ServersSampleBase):
self._verify_response('vifs-list-resp', subs, response, 200)
class FlavorManageSampleJsonTests(ApiSampleTestBaseV2):
ADMIN_API = True
extension_name = ("nova.api.openstack.compute.contrib.flavormanage."
"Flavormanage")
def _create_flavor(self):
"""Create a flavor."""
subs = {
'flavor_id': 10,
'flavor_name': "test_flavor"
}
response = self._do_post("flavors",
"flavor-create-post-req",
subs)
subs.update(self._get_regexes())
self._verify_response("flavor-create-post-resp", subs, response, 200)
def test_create_flavor(self):
# Get api sample to create a flavor.
self._create_flavor()
def test_delete_flavor(self):
# Get api sample to delete a flavor.
self._create_flavor()
response = self._do_delete("flavors/10")
self.assertEqual(response.status_code, 202)
self.assertEqual(response.content, '')
class ServerPasswordSampleJsonTests(ServersSampleBase):
extension_name = ("nova.api.openstack.compute.contrib.server_password."
"Server_password")

View File

@ -4,11 +4,11 @@
"id": "%(flavor_id)s",
"links": [
{
"href": "%(host)s/v3/flavors/%(flavor_id)s",
"href": "%(host)s/v2/openstack/flavors/%(flavor_id)s",
"rel": "self"
},
{
"href": "%(host)s/flavors/%(flavor_id)s",
"href": "%(host)s/openstack/flavors/%(flavor_id)s",
"rel": "bookmark"
}
],

View File

@ -13,11 +13,42 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from nova.tests.functional.v3 import api_sample_base
CONF = cfg.CONF
CONF.import_opt('osapi_compute_extension',
'nova.api.openstack.compute.extensions')
class FlavorManageSampleJsonTests(api_sample_base.ApiSampleTestBaseV3):
ADMIN_API = True
extension_name = 'flavor-manage'
# 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'
def _get_flags(self):
f = super(FlavorManageSampleJsonTests, self)._get_flags()
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.contrib.flavormanage.'
'Flavormanage')
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.contrib.flavor_disabled.'
'Flavor_disabled')
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.contrib.flavor_access.'
'Flavor_access')
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.contrib.flavorextradata.'
'Flavorextradata')
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.contrib.flavor_swap.'
'Flavor_swap')
return f
def _create_flavor(self):
"""Create a flavor."""