mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-11 03:31:29 -07:00
Move _handle_no_log_values() out of basic.py (#48628)
* Rename method and make private * Use is_iterable, combine transformations * Remove unused return_values from network modules * Improve docstrings in new functions * Add new PASS_VAR * Add unit tests for list_no_log_values * Fix unit tests for Python 2.6
This commit is contained in:
parent
a7cee49913
commit
aba4bed803
22 changed files with 176 additions and 66 deletions
|
@ -0,0 +1,35 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2019 Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
import pytest
|
||||
|
||||
from ansible.module_utils.common.parameters import list_deprecations
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def params():
|
||||
return {
|
||||
'name': 'bob',
|
||||
'dest': '/etc/hosts',
|
||||
'state': 'present',
|
||||
'value': 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'
|
|
@ -0,0 +1,41 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2019 Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
import pytest
|
||||
|
||||
from ansible.module_utils.common.parameters import list_no_log_values
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def params():
|
||||
return {
|
||||
'secret': 'undercookwovennativity',
|
||||
'other_secret': 'cautious-slate-makeshift',
|
||||
'state': 'present',
|
||||
'value': 5,
|
||||
}
|
||||
|
||||
|
||||
def test_list_no_log_values(params):
|
||||
argument_spec = {
|
||||
'secret': {'type': 'str', 'no_log': True},
|
||||
'other_secret': {'type': 'str', 'no_log': True},
|
||||
'state': {'type': 'str'},
|
||||
'value': {'type': 'int'},
|
||||
}
|
||||
result = set(('undercookwovennativity', 'cautious-slate-makeshift'))
|
||||
assert result == list_no_log_values(argument_spec, params)
|
||||
|
||||
|
||||
def test_list_no_log_values_no_secrets(params):
|
||||
argument_spec = {
|
||||
'other_secret': {'type': 'str', 'no_log': False},
|
||||
'state': {'type': 'str'},
|
||||
'value': {'type': 'int'},
|
||||
}
|
||||
result = set()
|
||||
assert result == list_no_log_values(argument_spec, params)
|
Loading…
Add table
Add a link
Reference in a new issue