mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-27 10:40:22 -07:00
Bump version of main to 8.0.0; remove deprecations, deprecate some leftovers (#7358)
* Remove disable_facts from xfconf module. * Remove deprecated module_helper CmdMixin and users. * Deprecate ArgFormat as well, which wasn't explicitly deprecated yet. * Remove state=get from gconftool2. * Remove default of access_level in gitlab_runner. * Remove state=list from manageiq_polices. * Remove state=list from manageiq_tags. * Consul: when state=absent, certain options can no longer be specified. * Remove support for Ansible 2.9 and ansible-base 2.10 from ansible_galaxy_install. * Bump community.general version to 8.0.0. * Fix gconftool2 tests. * Remove mh.mixins.cmd module_utils completely. * Re-add removed anchor on its first non-removed usage. * remove references in return doc, refactor method _setup210plus * remove no longer needed check in function parse_check * improve expression * Fix YAML. * Lint. --------- Co-authored-by: Alexei Znamensky <russoz@gmail.com>
This commit is contained in:
parent
c7084c6c30
commit
40809ed953
21 changed files with 88 additions and 514 deletions
|
@ -10,7 +10,7 @@ __metaclass__ = type
|
|||
import pytest
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils.module_helper import (
|
||||
ArgFormat, DependencyCtxMgr, VarMeta, VarDict, cause_changes
|
||||
DependencyCtxMgr, VarMeta, VarDict, cause_changes
|
||||
)
|
||||
|
||||
|
||||
|
@ -18,80 +18,6 @@ def single_lambda_2star(x, y, z):
|
|||
return ["piggies=[{0},{1},{2}]".format(x, y, z)]
|
||||
|
||||
|
||||
ARG_FORMATS = dict(
|
||||
simple_boolean_true=("--superflag", ArgFormat.BOOLEAN, 0,
|
||||
True, ["--superflag"]),
|
||||
simple_boolean_false=("--superflag", ArgFormat.BOOLEAN, 0,
|
||||
False, []),
|
||||
simple_boolean_none=("--superflag", ArgFormat.BOOLEAN, 0,
|
||||
None, []),
|
||||
simple_boolean_not_true=("--superflag", ArgFormat.BOOLEAN_NOT, 0,
|
||||
True, []),
|
||||
simple_boolean_not_false=("--superflag", ArgFormat.BOOLEAN_NOT, 0,
|
||||
False, ["--superflag"]),
|
||||
simple_boolean_not_none=("--superflag", ArgFormat.BOOLEAN_NOT, 0,
|
||||
None, ["--superflag"]),
|
||||
single_printf=("--param=%s", ArgFormat.PRINTF, 0,
|
||||
"potatoes", ["--param=potatoes"]),
|
||||
single_printf_no_substitution=("--param", ArgFormat.PRINTF, 0,
|
||||
"potatoes", ["--param"]),
|
||||
single_printf_none=("--param=%s", ArgFormat.PRINTF, 0,
|
||||
None, []),
|
||||
multiple_printf=(["--param", "free-%s"], ArgFormat.PRINTF, 0,
|
||||
"potatoes", ["--param", "free-potatoes"]),
|
||||
single_format=("--param={0}", ArgFormat.FORMAT, 0,
|
||||
"potatoes", ["--param=potatoes"]),
|
||||
single_format_none=("--param={0}", ArgFormat.FORMAT, 0,
|
||||
None, []),
|
||||
single_format_no_substitution=("--param", ArgFormat.FORMAT, 0,
|
||||
"potatoes", ["--param"]),
|
||||
multiple_format=(["--param", "free-{0}"], ArgFormat.FORMAT, 0,
|
||||
"potatoes", ["--param", "free-potatoes"]),
|
||||
multiple_format_none=(["--param", "free-{0}"], ArgFormat.FORMAT, 0,
|
||||
None, []),
|
||||
single_lambda_0star=((lambda v: ["piggies=[{0},{1},{2}]".format(v[0], v[1], v[2])]), None, 0,
|
||||
['a', 'b', 'c'], ["piggies=[a,b,c]"]),
|
||||
single_lambda_0star_none=((lambda v: ["piggies=[{0},{1},{2}]".format(v[0], v[1], v[2])]), None, 0,
|
||||
None, []),
|
||||
single_lambda_1star=((lambda a, b, c: ["piggies=[{0},{1},{2}]".format(a, b, c)]), None, 1,
|
||||
['a', 'b', 'c'], ["piggies=[a,b,c]"]),
|
||||
single_lambda_1star_none=((lambda a, b, c: ["piggies=[{0},{1},{2}]".format(a, b, c)]), None, 1,
|
||||
None, []),
|
||||
single_lambda_2star=(single_lambda_2star, None, 2,
|
||||
dict(z='c', x='a', y='b'), ["piggies=[a,b,c]"]),
|
||||
single_lambda_2star_none=(single_lambda_2star, None, 2,
|
||||
None, []),
|
||||
)
|
||||
ARG_FORMATS_IDS = sorted(ARG_FORMATS.keys())
|
||||
|
||||
|
||||
@pytest.mark.parametrize('fmt, style, stars, value, expected',
|
||||
(ARG_FORMATS[tc] for tc in ARG_FORMATS_IDS),
|
||||
ids=ARG_FORMATS_IDS)
|
||||
def test_arg_format(fmt, style, stars, value, expected):
|
||||
af = ArgFormat('name', fmt, style, stars)
|
||||
actual = af.to_text(value)
|
||||
print("formatted string = {0}".format(actual))
|
||||
assert actual == expected, "actual = {0}".format(actual)
|
||||
|
||||
|
||||
ARG_FORMATS_FAIL = dict(
|
||||
int_fmt=(3, None, 0, "", [""]),
|
||||
bool_fmt=(True, None, 0, "", [""]),
|
||||
)
|
||||
ARG_FORMATS_FAIL_IDS = sorted(ARG_FORMATS_FAIL.keys())
|
||||
|
||||
|
||||
@pytest.mark.parametrize('fmt, style, stars, value, expected',
|
||||
(ARG_FORMATS_FAIL[tc] for tc in ARG_FORMATS_FAIL_IDS),
|
||||
ids=ARG_FORMATS_FAIL_IDS)
|
||||
def test_arg_format_fail(fmt, style, stars, value, expected):
|
||||
with pytest.raises(TypeError):
|
||||
af = ArgFormat('name', fmt, style, stars)
|
||||
actual = af.to_text(value)
|
||||
print("formatted string = {0}".format(actual))
|
||||
|
||||
|
||||
def test_dependency_ctxmgr():
|
||||
ctx = DependencyCtxMgr("POTATOES", "Potatoes must be installed")
|
||||
with ctx:
|
||||
|
|
|
@ -4,28 +4,6 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
---
|
||||
- id: test_simple_element_get
|
||||
input:
|
||||
state: get
|
||||
key: /desktop/gnome/background/picture_filename
|
||||
output: {}
|
||||
run_command_calls:
|
||||
- command: [/testbin/gconftool-2, --get, /desktop/gnome/background/picture_filename]
|
||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||
rc: 0
|
||||
out: "100\n"
|
||||
err: ""
|
||||
- id: test_simple_element_get_not_found
|
||||
input:
|
||||
state: get
|
||||
key: /desktop/gnome/background/picture_filename
|
||||
output: {}
|
||||
run_command_calls:
|
||||
- command: [/testbin/gconftool-2, --get, /desktop/gnome/background/picture_filename]
|
||||
environ: *env-def
|
||||
rc: 0
|
||||
out: ""
|
||||
err: "No value set for `/desktop/gnome/background/picture_filename'\n"
|
||||
- id: test_simple_element_set
|
||||
input:
|
||||
state: present
|
||||
|
@ -37,7 +15,7 @@
|
|||
changed: true
|
||||
run_command_calls:
|
||||
- command: [/testbin/gconftool-2, --get, /desktop/gnome/background/picture_filename]
|
||||
environ: *env-def
|
||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||
rc: 0
|
||||
out: "100\n"
|
||||
err: ""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue