Merge "Adding tests for hosts api"

This commit is contained in:
Jenkins
2013-05-15 23:00:39 +00:00
committed by Gerrit Code Review
2 changed files with 43 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
"""
Copyright 2013 Rackspace
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 cafe.drivers.unittest.decorators import tags
from cloudcafe.compute.common.types import HostServiceTypes
from test_repo.compute.fixtures import ComputeAdminFixture
class HostsAdminTest(ComputeAdminFixture):
@classmethod
def setUpClass(cls):
super(HostsAdminTest, cls).setUpClass()
@classmethod
def tearDownClass(cls):
super(HostsAdminTest, cls).tearDownClass()
@tags(type='smoke', net='no')
def test_list_hosts(self):
hosts = self.admin_hosts_client.list_hosts().entity
self.assertTrue(len(hosts) > 0, "The hosts list is empty.")
for host in hosts:
if host.service == HostServiceTypes.COMPUTE:
return
self.fail("The expected host: %s"
" is not found in hosts list." % HostServiceTypes.COMPUTE)

View File

@@ -27,6 +27,7 @@ from cloudcafe.compute.common.exception_handler import ExceptionHandler
from cloudcafe.compute.flavors_api.client import FlavorsClient
from cloudcafe.compute.servers_api.client import ServersClient
from cloudcafe.compute.images_api.client import ImagesClient
from cloudcafe.compute.hosts_api.client import HostsClient
from cloudcafe.compute.extensions.keypairs_api.client import KeypairsClient
from cloudcafe.compute.extensions.security_groups_api.client import \
SecurityGroupsClient
@@ -211,6 +212,8 @@ class ComputeAdminFixture(ComputeFixture):
cls.admin_images_behaviors = ImageBehaviors(cls.admin_images_client,
cls.admin_servers_client,
cls.images_config)
cls.admin_hosts_client = HostsClient(url, access_data.token.id_,
'json', 'json')
cls.admin_servers_client.add_exception_handler(ExceptionHandler())
@classmethod