

@mock.patch.object(imcsdk, 'ImcHandle', autospec=True)
@mock.patch.object(cimc_common, 'handle_login', autospec=True)
def test_cimc_handle(self, mock_login, mock_handle):
    mo_hand = mock.MagicMock()
    mo_hand.username = self.node.driver_info.get('cimc_username')
    mo_hand.password = self.node.driver_info.get('cimc_password')
    mo_hand.name = self.node.driver_info.get('cimc_address')
    mock_handle.return_value = mo_hand
    info = cimc_common.parse_driver_info(self.node)
    with task_manager.acquire(self.context, self.node.uuid, shared=False) as task:
        with cimc_common.cimc_handle(task) as handle:
            self.assertEqual(handle, mock_handle.return_value)
    mock_login.assert_called_once_with(task, mock_handle.return_value, info)
    mock_handle.return_value.logout.assert_called_once_with()

dataset/ETHPy150Open openstack/ironic/ironic/tests/unit/drivers/modules/cimc/test_common.py CIMCHandleTestCase.test_cimc_handle/original