

@mock.patch.object(shade.OperatorCloud, 'ironic_client')
def test_register_machine_port_create_failed(self, mock_client):

    class fake_node():
        uuid = '00000000-0000-0000-0000-000000000000'
        provision_state = 'available'
        resevation = None
        last_error = None
    nics = [{
        'mac': '00:00:00:00:00:00',
    }]
    mock_client.node.create.return_value = fake_node
    mock_client.port.create.side_effect = exc.OpenStackCloudException('Error')
    self.assertRaises(exc.OpenStackCloudException, self.cloud.register_machine, nics)
    self.assertTrue(mock_client.node.create.called)
    self.assertTrue(mock_client.port.create.called)
    mock_client.assertTrue(mock_client.node.delete.called)

dataset/ETHPy150Open openstack-infra/shade/shade/tests/unit/test_shade_operator.py TestShadeOperator.test_register_machine_port_create_failed/VarMisuse@132/207 `self`->`mock_client`