Adding port mac validation tests
Unit tests added to expose valid and invalid Server Profile connection validation with port. Change-Id: Ibf2e66c6dc59df2181b67e80d284e60b96f84d97
This commit is contained in:
parent
870d3f57c4
commit
5947f02f3c
@ -333,7 +333,7 @@ class Client(object):
|
||||
primary_boot_connection = None
|
||||
for connection in server_profile_json.get('connections'):
|
||||
boot = connection.get('boot')
|
||||
if boot is not None and boot.get('priority') == 'Primary':
|
||||
if boot is not None and boot.get('priority').lower() == 'primary':
|
||||
primary_boot_connection = connection
|
||||
|
||||
if primary_boot_connection is None:
|
||||
|
@ -39,6 +39,13 @@ DRIVER_INFO_DICT = {'server_hardware_uri': 'fake_sh_uri',
|
||||
'server_profile_template_uri': 'fake_spt_uri'}
|
||||
|
||||
|
||||
class TestablePort(object):
|
||||
|
||||
def __init__(self, obj_address):
|
||||
self.obj_address = obj_address
|
||||
self._obj_address = obj_address
|
||||
|
||||
|
||||
class OneViewClientAuthTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
@ -653,6 +660,38 @@ class OneViewClientTestCase(unittest.TestCase):
|
||||
oneview_client.verify_oneview_version
|
||||
)
|
||||
|
||||
@mock.patch.object(client.Client, 'get_server_profile_from_hardware')
|
||||
def test_is_mac_compatible_with_server_profile(
|
||||
self, mock_get_server_profile_from_hardware, mock__authenticate):
|
||||
oneview_client = client.Client(self.manager_url,
|
||||
self.username,
|
||||
self.password)
|
||||
mock_get_server_profile_from_hardware.return_value = (
|
||||
{'connections': [{'boot': {'priority': 'Primary'},
|
||||
'mac': 'AA:BB:CC:DD:EE:FF'}]})
|
||||
|
||||
port = TestablePort('AA:BB:CC:DD:EE:FF')
|
||||
node_info = None
|
||||
ports = [port]
|
||||
oneview_client.is_node_port_mac_compatible_with_server_profile(
|
||||
node_info, ports)
|
||||
|
||||
@mock.patch.object(client.Client, 'get_server_profile_from_hardware')
|
||||
def test_is_mac_compatible_with_server_profile_with_no_ports(
|
||||
self, mock_get_server_profile_from_hardware, mock__authenticate):
|
||||
oneview_client = client.Client(self.manager_url,
|
||||
self.username,
|
||||
self.password)
|
||||
mock_get_server_profile_from_hardware.return_value = (
|
||||
{'connections': [{'boot': {'priority': 'Primary'},
|
||||
'mac': 'AA:BB:CC:DD:EE:FF'}]})
|
||||
|
||||
node_info = None
|
||||
ports = []
|
||||
with self.assertRaises(exceptions.OneViewInconsistentResource):
|
||||
oneview_client.is_node_port_mac_compatible_with_server_profile(
|
||||
node_info, ports)
|
||||
|
||||
@mock.patch.object(client.Client, 'get_server_profile_from_hardware')
|
||||
def test_is_mac_compatible_with_server_profile_without_boot_in_connection(
|
||||
self, mock_get_server_profile_from_hardware, mock__authenticate):
|
||||
|
Loading…
Reference in New Issue
Block a user