示例#1
0
def test_list_deprecations():
    argument_spec = {
        'old': {
            'type': 'str',
            'removed_in_version': '2.5'
        },
        'foo': {
            'type': 'dict',
            'options': {
                'old': {
                    'type': 'str',
                    'removed_in_version': 1.0
                }
            }
        },
        'bar': {
            'type': 'list',
            'elements': 'dict',
            'options': {
                'old': {
                    'type': 'str',
                    'removed_in_version': '2.10'
                }
            }
        },
        # Ansible 2.10 compatibility:
        'compat': {
            'type': 'str',
            'removed_at_date': '2020-01-01',
            'removed_from_collection': 'foo.bar'
        },
    }

    params = {
        'name': 'rod',
        'old': 'option',
        'old2': 'option2',
        'foo': {
            'old': 'value'
        },
        'bar': [{
            'old': 'value'
        }, {}],
    }
    result = list_deprecations(argument_spec, params)
    assert len(result) == 3
    result.sort(key=lambda entry: entry['msg'])
    assert result[0][
        'msg'] == """Param 'bar["old"]' is deprecated. See the module docs for more information"""
    assert result[0]['version'] == '2.10'
    assert result[1][
        'msg'] == """Param 'foo["old"]' is deprecated. See the module docs for more information"""
    assert result[1]['version'] == 1.0
    assert result[2][
        'msg'] == "Param 'old' is deprecated. See the module docs for more information"
    assert result[2]['version'] == '2.5'
def test_list_deprecations():
    argument_spec = {'old': {'type': 'str', 'removed_in_version': '2.5'}}

    params = {
        'name': 'rod',
        'old': 'option',
    }
    result = list_deprecations(argument_spec, params)
    for item in result:
        assert item[
            'msg'] == "Param 'old' is deprecated. See the module docs for more information"
        assert item['version'] == '2.5'
示例#3
0
    def _handle_no_log_values(self, spec=None, param=None):
        if spec is None:
            spec = self.argument_spec
        if param is None:
            param = self.params

        try:
            self.no_log_values.update(list_no_log_values(spec, param))
        except TypeError as te:
            self.fail_json(msg="Failure when processing no_log parameters. Module invocation will be hidden. "
                               "%s" % to_native(te), invocation={'module_args': 'HIDDEN DUE TO FAILURE'})

        for message in list_deprecations(spec, param):
            self.deprecate(message['msg'], version=message.get('version'), date=message.get('date'),
                           collection_name=message.get('collection_name'))