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:
parent
b4ce9490b9
commit
5e8f2a78c0
|
@ -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 = {}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in New Issue