Merge "Adds an orchestration API test for resource types"

This commit is contained in:
Jenkins 2014-09-01 11:20:07 +00:00 committed by Gerrit Code Review
commit 0fc2ffe160
2 changed files with 65 additions and 0 deletions

View File

@ -0,0 +1,44 @@
# 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.api.orchestration import base
from tempest import test
class ResourceTypesTest(base.BaseOrchestrationTest):
@test.attr(type='smoke')
def test_resource_type_list(self):
"""Verify it is possible to list resource types."""
resource_types = self.client.list_resource_types()
self.assertIsInstance(resource_types, list)
self.assertIn('OS::Nova::Server', resource_types)
@test.attr(type='smoke')
def test_resource_type_show(self):
"""Verify it is possible to get schema about resource types."""
resource_types = self.client.list_resource_types()
self.assertNotEmpty(resource_types)
for resource_type in resource_types:
type_schema = self.client.get_resource_type(resource_type)
self.assert_fields_in_dict(type_schema, 'properties',
'attributes', 'resource_type')
self.assertEqual(resource_type, type_schema['resource_type'])
@test.attr(type='smoke')
def test_resource_type_template(self):
"""Verify it is possible to get template about resource types."""
type_template = self.client.get_resource_type_template(
'OS::Nova::Server')
self.assert_fields_in_dict(type_template, 'Outputs',
'Parameters', 'Resources')

View File

@ -280,6 +280,27 @@ class OrchestrationClient(rest_client.RestClient):
}
return self._validate_template(post_body)
def list_resource_types(self):
"""List resource types."""
resp, body = self.get('resource_types')
self.expected_success(200, resp.status)
body = json.loads(body)
return body['resource_types']
def get_resource_type(self, resource_type_name):
"""Return the schema of a resource type."""
url = 'resource_types/%s' % resource_type_name
resp, body = self.get(url)
self.expected_success(200, resp.status)
return json.loads(body)
def get_resource_type_template(self, resource_type_name):
"""Return the template of a resource type."""
url = 'resource_types/%s/template' % resource_type_name
resp, body = self.get(url)
self.expected_success(200, resp.status)
return json.loads(body)
def create_software_config(self, name=None, config=None, group=None,
inputs=None, outputs=None, options=None):
headers, body = self._prep_software_config_create(