Esempio n. 1
0
    def test_deprecated_alias(self, capfd, mocker, stdin, complex_argspec):
        """Test a deprecated alias"""
        am = basic.AnsibleModule(**complex_argspec)

        assert "Alias 'zodraz' is deprecated." in get_deprecation_messages(
        )[0]['msg']
        assert get_deprecation_messages()[0]['version'] == '9.99'
Esempio n. 2
0
    def test_deprecated_alias(self, capfd, mocker, stdin, complex_argspec,
                              monkeypatch):
        """Test a deprecated alias"""
        monkeypatch.setattr(warnings, '_global_deprecations', [])

        am = basic.AnsibleModule(**complex_argspec)

        assert "Alias 'zodraz' is deprecated." in get_deprecation_messages(
        )[0]['msg']
        assert get_deprecation_messages()[0]['version'] == '9.99'
Esempio n. 3
0
def test_get_deprecation_messages(deprecation_messages):
    for d in deprecation_messages:
        deprecate(**d)

    accessor_deprecations = get_deprecation_messages()
    assert isinstance(accessor_deprecations, tuple)
    assert len(accessor_deprecations) == 3
def test_alias_deprecation():
    arg_spec = {
        'path': {
            'aliases': ['not_yo_path'],
            'deprecated_aliases': [{
                'name': 'not_yo_path',
                'version': '1.7',
            }]
        }
    }

    parameters = {
        'not_yo_path': '/tmp',
    }

    expected = {
        'path': '/tmp',
        'not_yo_path': '/tmp',
    }

    v = ArgumentSpecValidator(arg_spec, parameters)
    passed = v.validate()

    assert passed is True
    assert v.validated_parameters == expected
    assert v.error_messages == []
    assert "Alias 'not_yo_path' is deprecated." in get_deprecation_messages(
    )[0]['msg']
Esempio n. 5
0
def test_aliases(arg_spec, parameters, expected, passfail, error, deprecation,
                 warning):
    v = ArgumentSpecValidator(arg_spec, parameters)
    passed = v.validate()

    assert passed is passfail
    assert v.validated_parameters == expected

    if not error:
        assert v.error_messages == []
    else:
        assert error in v.error_messages[0]

    deprecations = get_deprecation_messages()
    if not deprecations:
        assert deprecations == ()
    else:
        assert deprecation in get_deprecation_messages()[0]['msg']

    warnings = get_warning_messages()
    if not warning:
        assert warnings == ()
    else:
        assert warning in warnings[0]