diff options
Diffstat (limited to 'ironicclient/tests')
| -rw-r--r-- | ironicclient/tests/v1/test_node.py | 54 | ||||
| -rw-r--r-- | ironicclient/tests/v1/test_node_shell.py | 28 |
2 files changed, 82 insertions, 0 deletions
diff --git a/ironicclient/tests/v1/test_node.py b/ironicclient/tests/v1/test_node.py index e13b90f..4f9a57e 100644 --- a/ironicclient/tests/v1/test_node.py +++ b/ironicclient/tests/v1/test_node.py @@ -64,6 +64,9 @@ CONSOLE_DATA_ENABLED = {'console_enabled': True, 'console_info': {'test-console': 'test-console-data'}} CONSOLE_DATA_DISABLED = {'console_enabled': False, 'console_info': None} +BOOT_DEVICE = {'boot_device': 'pxe', 'persistent': False} +SUPPORTED_BOOT_DEVICE = {'supported_boot_devices': ['pxe']} + CREATE_NODE = copy.deepcopy(NODE1) del CREATE_NODE['id'] del CREATE_NODE['uuid'] @@ -202,6 +205,24 @@ fake_responses = { CONSOLE_DATA_DISABLED, ), }, + '/v1/nodes/%s/management/boot_device' % NODE1['uuid']: + { + 'GET': ( + {}, + BOOT_DEVICE, + ), + 'PUT': ( + {}, + None, + ), + }, + '/v1/nodes/%s/management/boot_device/supported' % NODE1['uuid']: + { + 'GET': ( + {}, + SUPPORTED_BOOT_DEVICE, + ), + }, } fake_responses_pagination = { @@ -494,3 +515,36 @@ class NodeManagerTest(testtools.TestCase): update_mock.assert_once_called_with(final_path, vendor_passthru_args, method='POST') + + def _test_node_set_boot_device(self, boot_device, persistent=False): + self.mgr.set_boot_device(NODE1['uuid'], boot_device, persistent) + body = {'boot_device': boot_device, 'persistent': persistent} + expect = [ + ('PUT', '/v1/nodes/%s/management/boot_device' % NODE1['uuid'], + {}, body), + ] + self.assertEqual(expect, self.api.calls) + + def test_node_set_boot_device(self): + self._test_node_set_boot_device('pxe') + + def test_node_set_boot_device_persistent(self): + self._test_node_set_boot_device('pxe', persistent=True) + + def test_node_get_boot_device(self): + boot_device = self.mgr.get_boot_device(NODE1['uuid']) + expect = [ + ('GET', '/v1/nodes/%s/management/boot_device' % NODE1['uuid'], + {}, None), + ] + self.assertEqual(expect, self.api.calls) + self.assertEqual(BOOT_DEVICE, boot_device) + + def test_node_get_supported_boot_devices(self): + boot_device = self.mgr.get_supported_boot_devices(NODE1['uuid']) + expect = [ + ('GET', '/v1/nodes/%s/management/boot_device/supported' % + NODE1['uuid'], {}, None), + ] + self.assertEqual(expect, self.api.calls) + self.assertEqual(SUPPORTED_BOOT_DEVICE, boot_device) diff --git a/ironicclient/tests/v1/test_node_shell.py b/ironicclient/tests/v1/test_node_shell.py index 3494a0c..5185c4e 100644 --- a/ironicclient/tests/v1/test_node_shell.py +++ b/ironicclient/tests/v1/test_node_shell.py @@ -78,3 +78,31 @@ class NodeShellTest(utils.BaseTestCase): 'args': {} } client_mock.node.vendor_passthru.assert_called_once_with(**kwargs) + + def test_do_node_set_boot_device(self): + client_mock = mock.MagicMock() + args = mock.MagicMock() + args.node = 'node_uuid' + args.persistent = False + args.device = 'pxe' + + n_shell.do_node_set_boot_device(client_mock, args) + client_mock.node.set_boot_device.assert_called_once_with( + 'node_uuid', 'pxe', False) + + def test_do_node_get_boot_device(self): + client_mock = mock.MagicMock() + args = mock.MagicMock() + args.node = 'node_uuid' + + n_shell.do_node_get_boot_device(client_mock, args) + client_mock.node.get_boot_device.assert_called_once_with('node_uuid') + + def test_do_node_get_supported_boot_devices(self): + client_mock = mock.MagicMock() + args = mock.MagicMock() + args.node = 'node_uuid' + + n_shell.do_node_get_supported_boot_devices(client_mock, args) + client_mock.node.get_supported_boot_devices.assert_called_once_with( + 'node_uuid') |
