

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

    class client_return_value():
        uuid = '00000000-0000-0000-0000-000000000000'
        name = 'evil'
    expected_patch = [dict(op='replace', path='/name', value='good')]
    mock_client.node.get.return_value = client_return_value
    update_dict = self.cloud.update_machine('evil', name='good')
    self.assertIsNotNone(update_dict['changes'])
    self.assertEqual('/name', update_dict['changes'][0])
    self.assertTrue(mock_patch.called)
    mock_patch.assert_called_with('00000000-0000-0000-0000-000000000000', expected_patch)

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