

@mock.patch.object(shade.OperatorCloud, 'ironic_client')
@mock.patch.object(shade.OperatorCloud, 'node_set_provision_state')
def test_register_machine_enroll_timeout(self, mock_set_state, mock_client):
    machine_uuid = '00000000-0000-0000-0000-000000000000'

    class fake_node_init_state():
        uuid = machine_uuid
        provision_state = 'enroll'
        reservation = 'do you have a flag?'
        last_error = None
    mock_client.node.get.return_value = fake_node_init_state
    mock_client.node.create.return_value = fake_node_init_state
    nics = [{
        'mac': '00:00:00:00:00:00',
    }]
    self.assertRaises(shade.OpenStackCloudException, mock_client.cloud.register_machine, nics, lock_timeout=0.001)
    self.assertTrue(mock_client.node.create.called)
    self.assertTrue(mock_client.port.create.called)
    self.assertTrue(mock_client.node.get.called)
    mock_client.node.get.reset_mock()
    mock_client.node.create.reset_mock()
    self.assertRaises(shade.OpenStackCloudException, self.cloud.register_machine, nics, wait=True, timeout=0.001)
    self.assertTrue(mock_client.node.create.called)
    self.assertTrue(mock_client.port.create.called)
    self.assertTrue(mock_client.node.get.called)

dataset/ETHPy150Open openstack-infra/shade/shade/tests/unit/test_shade_operator.py TestShadeOperator.test_register_machine_enroll_timeout/VarMisuse@112/210 `self`->`mock_client`