ironic/baremetal: add validation of host manager/state APIs

Add tests to ensure the ironic & baremetal HostManager and
HostState sub-classes comply with the API contract defined
in their parent class.

Related-bug: #1369151
Change-Id: Ic2cf17c59c06fe2222db4bc5ea0e68f87c4399e9
This commit is contained in:
Daniel P. Berrange 2014-09-15 16:40:12 +01:00
parent b4ce9490b9
commit 5e8f2a78c0
3 changed files with 26 additions and 1 deletions

View File

@ -271,7 +271,8 @@ class HostManager(object):
"""Base HostManager class."""
# Can be overridden in a subclass
host_state_cls = HostState
def host_state_cls(self, host, node, **kwargs):
return HostState(host, node, **kwargs)
def __init__(self):
self.host_state_map = {}

View File

@ -28,6 +28,18 @@ class BaremetalHostManagerTestCase(test.NoDBTestCase):
super(BaremetalHostManagerTestCase, self).setUp()
self.host_manager = baremetal_host_manager.BaremetalHostManager()
def test_manager_public_api_signatures(self):
self.assertPublicAPISignatures(host_manager.HostManager(),
self.host_manager)
def test_state_public_api_signatures(self):
self.assertPublicAPISignatures(
host_manager.HostState("dummy",
"dummy"),
baremetal_host_manager.BaremetalNodeState("dummy",
"dummy")
)
@mock.patch.object(baremetal_host_manager.BaremetalNodeState, '__init__')
def test_create_baremetal_node_state(self, init_mock):
init_mock.return_value = None

View File

@ -46,6 +46,18 @@ class IronicHostManagerTestCase(test.NoDBTestCase):
super(IronicHostManagerTestCase, self).setUp()
self.host_manager = ironic_host_manager.IronicHostManager()
def test_manager_public_api_signatures(self):
self.assertPublicAPISignatures(host_manager.HostManager(),
self.host_manager)
def test_state_public_api_signatures(self):
self.assertPublicAPISignatures(
host_manager.HostState("dummy",
"dummy"),
ironic_host_manager.IronicNodeState("dummy",
"dummy")
)
def test_get_all_host_states(self):
# Ensure .service is set and we have the values we expect to.
context = 'fake_context'