def test_create_chassis_no_nodes(self, mock_create_nodes): chassis = {'description': 'fake'} self.client.chassis.create.return_value = mock.Mock(uuid='uuid') self.assertEqual([], create_resources.create_chassis(self.client, [chassis])) self.client.chassis.create.assert_called_once_with(description='fake') self.assertFalse(mock_create_nodes.called)
def test_create_chassis_no_nodes(self, mock_create_nodes): chassis = {'description': 'fake'} self.client.chassis.create.return_value = mock.Mock(uuid='uuid') self.assertEqual([], create_resources.create_chassis(self.client, [chassis])) self.client.chassis.create.assert_called_once_with(description='fake') self.assertFalse(mock_create_nodes.called)
def test_create_chassis_exception(self, mock_create_nodes): chassis = {'description': 'fake', 'nodes': ['list of nodes']} self.client.chassis.create.side_effect = exc.ClientException('bar') errs = create_resources.create_chassis(self.client, [chassis]) self.client.chassis.create.assert_called_once_with(description='fake') self.assertFalse(mock_create_nodes.called) self.assertEqual(1, len(errs)) self.assertIsInstance(errs[0], exc.ClientException)
def test_create_chassis(self, mock_create_nodes): chassis = {'description': 'fake', 'nodes': ['list of nodes']} self.client.chassis.create.return_value = mock.Mock(uuid='uuid') self.assertEqual([], create_resources.create_chassis(self.client, [chassis])) self.client.chassis.create.assert_called_once_with(description='fake') mock_create_nodes.assert_called_once_with( self.client, ['list of nodes'], chassis_uuid='uuid')
def test_create_chassis_exception(self, mock_create_nodes): chassis = {'description': 'fake', 'nodes': ['list of nodes']} self.client.chassis.create.side_effect = exc.ClientException('bar') errs = create_resources.create_chassis(self.client, [chassis]) self.client.chassis.create.assert_called_once_with(description='fake') self.assertFalse(mock_create_nodes.called) self.assertEqual(1, len(errs)) self.assertIsInstance(errs[0], exc.ClientException)
def test_create_chassis(self, mock_create_nodes): chassis = {'description': 'fake', 'nodes': ['list of nodes']} self.client.chassis.create.return_value = mock.Mock(uuid='uuid') self.assertEqual([], create_resources.create_chassis(self.client, [chassis])) self.client.chassis.create.assert_called_once_with(description='fake') mock_create_nodes.assert_called_once_with( self.client, ['list of nodes'], chassis_uuid='uuid')