'Test case for updating stack with changed parameters.
Use a template with existing parameters, then update with a
template containing additional parameters and a list of
parameters to be removed.'

def test_stack_update_existing_parameters_remove(self):

    stack_name = 'service_update_test_stack_existing_parameters_remove'
    update_params = {'encrypted_param_names': [], 'parameter_defaults': {}, 'event_sinks': [], 'parameters': {'newparam': 123}, 'resource_registry': {'resources': {}}}
    api_args = {rpc_api.PARAM_TIMEOUT: 60, rpc_api.PARAM_EXISTING: True, rpc_api.PARAM_CLEAR_PARAMETERS: ['removeme']}
    t = template_format.parse(tools.wp_template)
    t['parameters']['removeme'] = {'type': 'string'}
    stk = utils.parse_stack(t, stack_name=stack_name, params={'KeyName': 'test', 'removeme': 'foo'})
    stk.set_stack_user_project_id('1234')
    self.assertEqual({'KeyName': 'test', 'removeme': 'foo'}, stk.t.env.params)
    t['parameters']['newparam'] = {'type': 'number'}
    with mock.patch('heat.engine.stack.Stack') as mock_stack:
        stk.update = mock.Mock()
        mock_stack.load.return_value = stk
        mock_stack.validate.return_value = None
        result = self.man.update_stack(self.ctx, stk.identifier(), t, update_params, None, api_args)
        tmpl = mock_stack.call_args[0][2]
        self.assertEqual({'KeyName': 'test', 'newparam': 123}, tmpl.env.params)
        self.assertEqual(stk.identifier(), result)
