

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

    class fake_node():
        uuid = '00000000-0000-0000-0000-000000000000'
        provision_state = 'available'
        reservation = None
        last_error = None
    expected_return_value = dict(uuid='00000000-0000-0000-0000-000000000000', provision_state='available', reservation=None, last_error=None)
    mock_client.node.create.return_value = fake_node
    mock_client.node.get.return_value = fake_node
    nics = [{
        'mac': '00:00:00:00:00:00',
    }]
    return_value = self.cloud.register_machine(nics)
    self.assertDictEqual(expected_return_value, return_value)
    self.assertTrue(mock_client.node.create.called)
    self.assertTrue(mock_client.port.create.called)
    self.assertFalse(mock_client.node.get.called)

dataset/ETHPy150Open openstack-infra/shade/shade/tests/unit/test_shade_operator.py TestShadeOperator.test_register_machine/original