Migrated flavors_client.py from tempest
This migrates the above files from tempest. This includes tempest commits: * flavors_client.py : Id153ba7b5ff838532fd7bf0e2b72815141c2e250 * test_flavors_client.py: Ibf160ba20e26a9c1f216a2e741bdfa9f45c4f0d0 * flavors.py : Ica929c402a3d042ae751302384e68853eb28b405 * flavors_access.py : Ica929c402a3d042ae751302384e68853eb28b405 * flavors_extra_specs.py: Ica929c402a3d042ae751302384e68853eb28b405 to see the commit history for these files refer to the above Change-Ids in the tempest repository Partially implements blueprint migrate-service-clients-to-tempest-lib Change-Id: I3de529b1e0db298530e54fd2c871d40f29614126
This commit is contained in:
103
tempest_lib/api_schema/response/compute/v2_1/flavors.py
Normal file
103
tempest_lib/api_schema/response/compute/v2_1/flavors.py
Normal file
@@ -0,0 +1,103 @@
|
||||
# Copyright 2014 NEC Corporation. All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
from tempest_lib.api_schema.response.compute.v2_1 import parameter_types
|
||||
|
||||
list_flavors = {
|
||||
'status_code': [200],
|
||||
'response_body': {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'flavors': {
|
||||
'type': 'array',
|
||||
'items': {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'name': {'type': 'string'},
|
||||
'links': parameter_types.links,
|
||||
'id': {'type': 'string'}
|
||||
},
|
||||
'additionalProperties': False,
|
||||
'required': ['name', 'links', 'id']
|
||||
}
|
||||
},
|
||||
'flavors_links': parameter_types.links
|
||||
},
|
||||
'additionalProperties': False,
|
||||
# NOTE(gmann): flavors_links attribute is not necessary
|
||||
# to be present always So it is not 'required'.
|
||||
'required': ['flavors']
|
||||
}
|
||||
}
|
||||
|
||||
common_flavor_info = {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'name': {'type': 'string'},
|
||||
'links': parameter_types.links,
|
||||
'ram': {'type': 'integer'},
|
||||
'vcpus': {'type': 'integer'},
|
||||
# 'swap' attributes comes as integer value but if it is empty
|
||||
# it comes as "". So defining type of as string and integer.
|
||||
'swap': {'type': ['integer', 'string']},
|
||||
'disk': {'type': 'integer'},
|
||||
'id': {'type': 'string'},
|
||||
'OS-FLV-DISABLED:disabled': {'type': 'boolean'},
|
||||
'os-flavor-access:is_public': {'type': 'boolean'},
|
||||
'rxtx_factor': {'type': 'number'},
|
||||
'OS-FLV-EXT-DATA:ephemeral': {'type': 'integer'}
|
||||
},
|
||||
'additionalProperties': False,
|
||||
# 'OS-FLV-DISABLED', 'os-flavor-access', 'rxtx_factor' and
|
||||
# 'OS-FLV-EXT-DATA' are API extensions. So they are not 'required'.
|
||||
'required': ['name', 'links', 'ram', 'vcpus', 'swap', 'disk', 'id']
|
||||
}
|
||||
|
||||
list_flavors_details = {
|
||||
'status_code': [200],
|
||||
'response_body': {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'flavors': {
|
||||
'type': 'array',
|
||||
'items': common_flavor_info
|
||||
},
|
||||
# NOTE(gmann): flavors_links attribute is not necessary
|
||||
# to be present always So it is not 'required'.
|
||||
'flavors_links': parameter_types.links
|
||||
},
|
||||
'additionalProperties': False,
|
||||
'required': ['flavors']
|
||||
}
|
||||
}
|
||||
|
||||
unset_flavor_extra_specs = {
|
||||
'status_code': [200]
|
||||
}
|
||||
|
||||
create_get_flavor_details = {
|
||||
'status_code': [200],
|
||||
'response_body': {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'flavor': common_flavor_info
|
||||
},
|
||||
'additionalProperties': False,
|
||||
'required': ['flavor']
|
||||
}
|
||||
}
|
||||
|
||||
delete_flavor = {
|
||||
'status_code': [202]
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
# Copyright 2014 NEC Corporation. All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
add_remove_list_flavor_access = {
|
||||
'status_code': [200],
|
||||
'response_body': {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'flavor_access': {
|
||||
'type': 'array',
|
||||
'items': {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'flavor_id': {'type': 'string'},
|
||||
'tenant_id': {'type': 'string'},
|
||||
},
|
||||
'additionalProperties': False,
|
||||
'required': ['flavor_id', 'tenant_id'],
|
||||
}
|
||||
}
|
||||
},
|
||||
'additionalProperties': False,
|
||||
'required': ['flavor_access']
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
# Copyright 2014 NEC Corporation. All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
set_get_flavor_extra_specs = {
|
||||
'status_code': [200],
|
||||
'response_body': {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'extra_specs': {
|
||||
'type': 'object',
|
||||
'patternProperties': {
|
||||
'^[a-zA-Z0-9_\-\. :]+$': {'type': 'string'}
|
||||
}
|
||||
}
|
||||
},
|
||||
'additionalProperties': False,
|
||||
'required': ['extra_specs']
|
||||
}
|
||||
}
|
||||
|
||||
set_get_flavor_extra_specs_key = {
|
||||
'status_code': [200],
|
||||
'response_body': {
|
||||
'type': 'object',
|
||||
'patternProperties': {
|
||||
'^[a-zA-Z0-9_\-\. :]+$': {'type': 'string'}
|
||||
}
|
||||
}
|
||||
}
|
170
tempest_lib/services/compute/flavors_client.py
Normal file
170
tempest_lib/services/compute/flavors_client.py
Normal file
@@ -0,0 +1,170 @@
|
||||
# Copyright 2012 OpenStack Foundation
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
from oslo_serialization import jsonutils as json
|
||||
from six.moves.urllib import parse as urllib
|
||||
|
||||
from tempest_lib.api_schema.response.compute.v2_1 import flavors as schema
|
||||
from tempest_lib.api_schema.response.compute.v2_1 import flavors_access \
|
||||
as schema_access
|
||||
from tempest_lib.api_schema.response.compute.v2_1 import flavors_extra_specs \
|
||||
as schema_extra_specs
|
||||
from tempest_lib.common import rest_client
|
||||
|
||||
|
||||
class FlavorsClient(rest_client.RestClient):
|
||||
|
||||
def list_flavors(self, detail=False, **params):
|
||||
url = 'flavors'
|
||||
_schema = schema.list_flavors
|
||||
|
||||
if detail:
|
||||
url += '/detail'
|
||||
_schema = schema.list_flavors_details
|
||||
if params:
|
||||
url += '?%s' % urllib.urlencode(params)
|
||||
|
||||
resp, body = self.get(url)
|
||||
body = json.loads(body)
|
||||
self.validate_response(_schema, resp, body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def show_flavor(self, flavor_id):
|
||||
resp, body = self.get("flavors/%s" % flavor_id)
|
||||
body = json.loads(body)
|
||||
self.validate_response(schema.create_get_flavor_details, resp, body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def create_flavor(self, **kwargs):
|
||||
"""Creates a new flavor or instance type.
|
||||
|
||||
Most parameters except the following are passed to the API without
|
||||
any changes.
|
||||
:param ephemeral: The name is changed to OS-FLV-EXT-DATA:ephemeral
|
||||
:param is_public: The name is changed to os-flavor-access:is_public
|
||||
"""
|
||||
if kwargs.get('ephemeral'):
|
||||
kwargs['OS-FLV-EXT-DATA:ephemeral'] = kwargs.pop('ephemeral')
|
||||
if kwargs.get('is_public'):
|
||||
kwargs['os-flavor-access:is_public'] = kwargs.pop('is_public')
|
||||
|
||||
post_body = json.dumps({'flavor': kwargs})
|
||||
resp, body = self.post('flavors', post_body)
|
||||
|
||||
body = json.loads(body)
|
||||
self.validate_response(schema.create_get_flavor_details, resp, body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def delete_flavor(self, flavor_id):
|
||||
"""Deletes the given flavor."""
|
||||
resp, body = self.delete("flavors/{0}".format(flavor_id))
|
||||
self.validate_response(schema.delete_flavor, resp, body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def is_resource_deleted(self, id):
|
||||
# Did not use show_flavor(id) for verification as it gives
|
||||
# 200 ok even for deleted id. LP #981263
|
||||
# we can remove the loop here and use get by ID when bug gets sortedout
|
||||
flavors = self.list_flavors(detail=True)['flavors']
|
||||
for flavor in flavors:
|
||||
if flavor['id'] == id:
|
||||
return False
|
||||
return True
|
||||
|
||||
@property
|
||||
def resource_type(self):
|
||||
"""Returns the primary type of resource this client works with."""
|
||||
return 'flavor'
|
||||
|
||||
def set_flavor_extra_spec(self, flavor_id, **kwargs):
|
||||
"""Sets extra Specs to the mentioned flavor."""
|
||||
post_body = json.dumps({'extra_specs': kwargs})
|
||||
resp, body = self.post('flavors/%s/os-extra_specs' % flavor_id,
|
||||
post_body)
|
||||
body = json.loads(body)
|
||||
self.validate_response(schema_extra_specs.set_get_flavor_extra_specs,
|
||||
resp, body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def list_flavor_extra_specs(self, flavor_id):
|
||||
"""Gets extra Specs details of the mentioned flavor."""
|
||||
resp, body = self.get('flavors/%s/os-extra_specs' % flavor_id)
|
||||
body = json.loads(body)
|
||||
self.validate_response(schema_extra_specs.set_get_flavor_extra_specs,
|
||||
resp, body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def show_flavor_extra_spec(self, flavor_id, key):
|
||||
"""Gets extra Specs key-value of the mentioned flavor and key."""
|
||||
resp, body = self.get('flavors/%s/os-extra_specs/%s' % (flavor_id,
|
||||
key))
|
||||
body = json.loads(body)
|
||||
self.validate_response(
|
||||
schema_extra_specs.set_get_flavor_extra_specs_key,
|
||||
resp, body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def update_flavor_extra_spec(self, flavor_id, key, **kwargs):
|
||||
"""Update specified extra Specs of the mentioned flavor and key."""
|
||||
resp, body = self.put('flavors/%s/os-extra_specs/%s' %
|
||||
(flavor_id, key), json.dumps(kwargs))
|
||||
body = json.loads(body)
|
||||
self.validate_response(
|
||||
schema_extra_specs.set_get_flavor_extra_specs_key,
|
||||
resp, body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def unset_flavor_extra_spec(self, flavor_id, key):
|
||||
"""Unsets extra Specs from the mentioned flavor."""
|
||||
resp, body = self.delete('flavors/%s/os-extra_specs/%s' %
|
||||
(flavor_id, key))
|
||||
self.validate_response(schema.unset_flavor_extra_specs, resp, body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def list_flavor_access(self, flavor_id):
|
||||
"""Gets flavor access information given the flavor id."""
|
||||
resp, body = self.get('flavors/%s/os-flavor-access' % flavor_id)
|
||||
body = json.loads(body)
|
||||
self.validate_response(schema_access.add_remove_list_flavor_access,
|
||||
resp, body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def add_flavor_access(self, flavor_id, tenant_id):
|
||||
"""Add flavor access for the specified tenant."""
|
||||
post_body = {
|
||||
'addTenantAccess': {
|
||||
'tenant': tenant_id
|
||||
}
|
||||
}
|
||||
post_body = json.dumps(post_body)
|
||||
resp, body = self.post('flavors/%s/action' % flavor_id, post_body)
|
||||
body = json.loads(body)
|
||||
self.validate_response(schema_access.add_remove_list_flavor_access,
|
||||
resp, body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def remove_flavor_access(self, flavor_id, tenant_id):
|
||||
"""Remove flavor access from the specified tenant."""
|
||||
post_body = {
|
||||
'removeTenantAccess': {
|
||||
'tenant': tenant_id
|
||||
}
|
||||
}
|
||||
post_body = json.dumps(post_body)
|
||||
resp, body = self.post('flavors/%s/action' % flavor_id, post_body)
|
||||
body = json.loads(body)
|
||||
self.validate_response(schema_access.add_remove_list_flavor_access,
|
||||
resp, body)
|
||||
return rest_client.ResponseBody(resp, body)
|
255
tempest_lib/tests/services/compute/test_flavors_client.py
Normal file
255
tempest_lib/tests/services/compute/test_flavors_client.py
Normal file
@@ -0,0 +1,255 @@
|
||||
# Copyright 2015 IBM Corp.
|
||||
#
|
||||
# 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 copy
|
||||
import httplib2
|
||||
|
||||
from oslo_serialization import jsonutils as json
|
||||
from oslotest import mockpatch
|
||||
|
||||
from tempest_lib.services.compute import flavors_client
|
||||
from tempest_lib.tests import fake_auth_provider
|
||||
from tempest_lib.tests.services.compute import base
|
||||
|
||||
|
||||
class TestFlavorsClient(base.BaseComputeServiceTest):
|
||||
|
||||
FAKE_FLAVOR = {
|
||||
"disk": 1,
|
||||
"id": "1",
|
||||
"links": [{
|
||||
"href": "http://openstack.example.com/v2/openstack/flavors/1",
|
||||
"rel": "self"}, {
|
||||
"href": "http://openstack.example.com/openstack/flavors/1",
|
||||
"rel": "bookmark"}],
|
||||
"name": "m1.tiny",
|
||||
"ram": 512,
|
||||
"swap": 1,
|
||||
"vcpus": 1
|
||||
}
|
||||
|
||||
EXTRA_SPECS = {"extra_specs": {
|
||||
"key1": "value1",
|
||||
"key2": "value2"}
|
||||
}
|
||||
|
||||
FAKE_FLAVOR_ACCESS = {
|
||||
"flavor_id": "10",
|
||||
"tenant_id": "1a951d988e264818afe520e78697dcbf"
|
||||
}
|
||||
|
||||
def setUp(self):
|
||||
super(TestFlavorsClient, self).setUp()
|
||||
fake_auth = fake_auth_provider.FakeAuthProvider()
|
||||
self.client = flavors_client.FlavorsClient(fake_auth,
|
||||
'compute', 'regionOne')
|
||||
|
||||
def _test_list_flavors(self, bytes_body=False):
|
||||
flavor = copy.deepcopy(TestFlavorsClient.FAKE_FLAVOR)
|
||||
# Remove extra attributes
|
||||
for attribute in ('disk', 'vcpus', 'ram', 'swap'):
|
||||
del flavor[attribute]
|
||||
expected = {'flavors': [flavor]}
|
||||
self.check_service_client_function(
|
||||
self.client.list_flavors,
|
||||
'tempest_lib.common.rest_client.RestClient.get',
|
||||
expected,
|
||||
bytes_body)
|
||||
|
||||
def test_list_flavors_str_body(self):
|
||||
self._test_list_flavors(bytes_body=False)
|
||||
|
||||
def test_list_flavors_byte_body(self):
|
||||
self._test_list_flavors(bytes_body=True)
|
||||
|
||||
def _test_show_flavor(self, bytes_body=False):
|
||||
expected = {"flavor": TestFlavorsClient.FAKE_FLAVOR}
|
||||
self.check_service_client_function(
|
||||
self.client.show_flavor,
|
||||
'tempest_lib.common.rest_client.RestClient.get',
|
||||
expected,
|
||||
bytes_body,
|
||||
flavor_id='fake-id')
|
||||
|
||||
def test_show_flavor_str_body(self):
|
||||
self._test_show_flavor(bytes_body=False)
|
||||
|
||||
def test_show_flavor_byte_body(self):
|
||||
self._test_show_flavor(bytes_body=True)
|
||||
|
||||
def _test_create_flavor(self, bytes_body=False):
|
||||
expected = {"flavor": TestFlavorsClient.FAKE_FLAVOR}
|
||||
request = copy.deepcopy(TestFlavorsClient.FAKE_FLAVOR)
|
||||
# The 'links' parameter should not be passed in
|
||||
del request['links']
|
||||
self.check_service_client_function(
|
||||
self.client.create_flavor,
|
||||
'tempest_lib.common.rest_client.RestClient.post',
|
||||
expected,
|
||||
bytes_body,
|
||||
**request)
|
||||
|
||||
def test_create_flavor_str_body(self):
|
||||
self._test_create_flavor(bytes_body=False)
|
||||
|
||||
def test_create_flavor__byte_body(self):
|
||||
self._test_create_flavor(bytes_body=True)
|
||||
|
||||
def test_delete_flavor(self):
|
||||
self.check_service_client_function(
|
||||
self.client.delete_flavor,
|
||||
'tempest_lib.common.rest_client.RestClient.delete',
|
||||
{}, status=202, flavor_id='c782b7a9-33cd-45f0-b795-7f87f456408b')
|
||||
|
||||
def _test_is_resource_deleted(self, flavor_id, is_deleted=True,
|
||||
bytes_body=False):
|
||||
body = json.dumps({'flavors': [TestFlavorsClient.FAKE_FLAVOR]})
|
||||
if bytes_body:
|
||||
body = body.encode('utf-8')
|
||||
response = (httplib2.Response({'status': 200}), body)
|
||||
self.useFixture(mockpatch.Patch(
|
||||
'tempest_lib.common.rest_client.RestClient.get',
|
||||
return_value=response))
|
||||
self.assertEqual(is_deleted,
|
||||
self.client.is_resource_deleted(flavor_id))
|
||||
|
||||
def test_is_resource_deleted_true_str_body(self):
|
||||
self._test_is_resource_deleted('2', bytes_body=False)
|
||||
|
||||
def test_is_resource_deleted_true_byte_body(self):
|
||||
self._test_is_resource_deleted('2', bytes_body=True)
|
||||
|
||||
def test_is_resource_deleted_false_str_body(self):
|
||||
self._test_is_resource_deleted('1', is_deleted=False, bytes_body=False)
|
||||
|
||||
def test_is_resource_deleted_false_byte_body(self):
|
||||
self._test_is_resource_deleted('1', is_deleted=False, bytes_body=True)
|
||||
|
||||
def _test_set_flavor_extra_spec(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.set_flavor_extra_spec,
|
||||
'tempest_lib.common.rest_client.RestClient.post',
|
||||
TestFlavorsClient.EXTRA_SPECS,
|
||||
bytes_body,
|
||||
flavor_id='8c7aae5a-d315-4216-875b-ed9b6a5bcfc6',
|
||||
**TestFlavorsClient.EXTRA_SPECS)
|
||||
|
||||
def test_set_flavor_extra_spec_str_body(self):
|
||||
self._test_set_flavor_extra_spec(bytes_body=False)
|
||||
|
||||
def test_set_flavor_extra_spec_byte_body(self):
|
||||
self._test_set_flavor_extra_spec(bytes_body=True)
|
||||
|
||||
def _test_list_flavor_extra_specs(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.list_flavor_extra_specs,
|
||||
'tempest_lib.common.rest_client.RestClient.get',
|
||||
TestFlavorsClient.EXTRA_SPECS,
|
||||
bytes_body,
|
||||
flavor_id='8c7aae5a-d315-4216-875b-ed9b6a5bcfc6')
|
||||
|
||||
def test_list_flavor_extra_specs_str_body(self):
|
||||
self._test_list_flavor_extra_specs(bytes_body=False)
|
||||
|
||||
def test_list_flavor_extra_specs__byte_body(self):
|
||||
self._test_list_flavor_extra_specs(bytes_body=True)
|
||||
|
||||
def _test_show_flavor_extra_spec(self, bytes_body=False):
|
||||
expected = {"key": "value"}
|
||||
self.check_service_client_function(
|
||||
self.client.show_flavor_extra_spec,
|
||||
'tempest_lib.common.rest_client.RestClient.get',
|
||||
expected,
|
||||
bytes_body,
|
||||
flavor_id='8c7aae5a-d315-4216-875b-ed9b6a5bcfc6',
|
||||
key='key')
|
||||
|
||||
def test_show_flavor_extra_spec_str_body(self):
|
||||
self._test_show_flavor_extra_spec(bytes_body=False)
|
||||
|
||||
def test_show_flavor_extra_spec__byte_body(self):
|
||||
self._test_show_flavor_extra_spec(bytes_body=True)
|
||||
|
||||
def _test_update_flavor_extra_spec(self, bytes_body=False):
|
||||
expected = {"key1": "value"}
|
||||
self.check_service_client_function(
|
||||
self.client.update_flavor_extra_spec,
|
||||
'tempest_lib.common.rest_client.RestClient.put',
|
||||
expected,
|
||||
bytes_body,
|
||||
flavor_id='8c7aae5a-d315-4216-875b-ed9b6a5bcfc6',
|
||||
key='key1', **expected)
|
||||
|
||||
def test_update_flavor_extra_spec_str_body(self):
|
||||
self._test_update_flavor_extra_spec(bytes_body=False)
|
||||
|
||||
def test_update_flavor_extra_spec_byte_body(self):
|
||||
self._test_update_flavor_extra_spec(bytes_body=True)
|
||||
|
||||
def test_unset_flavor_extra_spec(self):
|
||||
self.check_service_client_function(
|
||||
self.client.unset_flavor_extra_spec,
|
||||
'tempest_lib.common.rest_client.RestClient.delete', {},
|
||||
flavor_id='c782b7a9-33cd-45f0-b795-7f87f456408b', key='key')
|
||||
|
||||
def _test_list_flavor_access(self, bytes_body=False):
|
||||
expected = {'flavor_access': [TestFlavorsClient.FAKE_FLAVOR_ACCESS]}
|
||||
self.check_service_client_function(
|
||||
self.client.list_flavor_access,
|
||||
'tempest_lib.common.rest_client.RestClient.get',
|
||||
expected,
|
||||
bytes_body,
|
||||
flavor_id='8c7aae5a-d315-4216-875b-ed9b6a5bcfc6')
|
||||
|
||||
def test_list_flavor_access_str_body(self):
|
||||
self._test_list_flavor_access(bytes_body=False)
|
||||
|
||||
def test_list_flavor_access_byte_body(self):
|
||||
self._test_list_flavor_access(bytes_body=True)
|
||||
|
||||
def _test_add_flavor_access(self, bytes_body=False):
|
||||
expected = {
|
||||
"flavor_access": [TestFlavorsClient.FAKE_FLAVOR_ACCESS]
|
||||
}
|
||||
self.check_service_client_function(
|
||||
self.client.add_flavor_access,
|
||||
'tempest_lib.common.rest_client.RestClient.post',
|
||||
expected,
|
||||
bytes_body,
|
||||
flavor_id='8c7aae5a-d315-4216-875b-ed9b6a5bcfc6',
|
||||
tenant_id='1a951d988e264818afe520e78697dcbf')
|
||||
|
||||
def test_add_flavor_access_str_body(self):
|
||||
self._test_add_flavor_access(bytes_body=False)
|
||||
|
||||
def test_add_flavor_access_byte_body(self):
|
||||
self._test_add_flavor_access(bytes_body=True)
|
||||
|
||||
def _test_remove_flavor_access(self, bytes_body=False):
|
||||
expected = {
|
||||
"flavor_access": [TestFlavorsClient.FAKE_FLAVOR_ACCESS]
|
||||
}
|
||||
self.check_service_client_function(
|
||||
self.client.remove_flavor_access,
|
||||
'tempest_lib.common.rest_client.RestClient.post',
|
||||
expected,
|
||||
bytes_body,
|
||||
flavor_id='10',
|
||||
tenant_id='a6edd4d66ad04245b5d2d8716ecc91e3')
|
||||
|
||||
def test_remove_flavor_access_str_body(self):
|
||||
self._test_remove_flavor_access(bytes_body=False)
|
||||
|
||||
def test_remove_flavor_access_byte_body(self):
|
||||
self._test_remove_flavor_access(bytes_body=True)
|
Reference in New Issue
Block a user