xfconf/xfconf_info: add return value version (#9226)
* xfconf/xfconf_info: add return value version * add changelog frag * adapt test to helper improvements * rollback copyright update * replace tab with spaces in test yamlspull/9371/head
parent
d539b00d4c
commit
b429e8a2cf
|
@ -0,0 +1,3 @@
|
||||||
|
minor_changes:
|
||||||
|
- xfconf - add return value ``version`` (https://github.com/ansible-collections/community.general/pull/9226).
|
||||||
|
- xfconf_info - add return value ``version`` (https://github.com/ansible-collections/community.general/pull/9226).
|
|
@ -7,10 +7,10 @@ from __future__ import absolute_import, division, print_function
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
from ansible.module_utils.parsing.convert_bool import boolean
|
from ansible.module_utils.parsing.convert_bool import boolean
|
||||||
from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt as fmt
|
from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt
|
||||||
|
|
||||||
|
|
||||||
@fmt.unpack_args
|
@cmd_runner_fmt.unpack_args
|
||||||
def _values_fmt(values, value_types):
|
def _values_fmt(values, value_types):
|
||||||
result = []
|
result = []
|
||||||
for value, value_type in zip(values, value_types):
|
for value, value_type in zip(values, value_types):
|
||||||
|
@ -25,14 +25,21 @@ def xfconf_runner(module, **kwargs):
|
||||||
module,
|
module,
|
||||||
command='xfconf-query',
|
command='xfconf-query',
|
||||||
arg_formats=dict(
|
arg_formats=dict(
|
||||||
channel=fmt.as_opt_val("--channel"),
|
channel=cmd_runner_fmt.as_opt_val("--channel"),
|
||||||
property=fmt.as_opt_val("--property"),
|
property=cmd_runner_fmt.as_opt_val("--property"),
|
||||||
force_array=fmt.as_bool("--force-array"),
|
force_array=cmd_runner_fmt.as_bool("--force-array"),
|
||||||
reset=fmt.as_bool("--reset"),
|
reset=cmd_runner_fmt.as_bool("--reset"),
|
||||||
create=fmt.as_bool("--create"),
|
create=cmd_runner_fmt.as_bool("--create"),
|
||||||
list_arg=fmt.as_bool("--list"),
|
list_arg=cmd_runner_fmt.as_bool("--list"),
|
||||||
values_and_types=fmt.as_func(_values_fmt),
|
values_and_types=_values_fmt,
|
||||||
|
version=cmd_runner_fmt.as_fixed("--version"),
|
||||||
),
|
),
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
return runner
|
return runner
|
||||||
|
|
||||||
|
|
||||||
|
def get_xfconf_version(runner):
|
||||||
|
with runner("version") as ctx:
|
||||||
|
rc, out, err = ctx.run()
|
||||||
|
return out.splitlines()[0].split()[1]
|
||||||
|
|
|
@ -153,10 +153,17 @@ cmd:
|
||||||
- string
|
- string
|
||||||
- --set
|
- --set
|
||||||
- Pacific/Auckland
|
- Pacific/Auckland
|
||||||
|
version:
|
||||||
|
description:
|
||||||
|
- The version of the C(xfconf-query) command.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
|
sample: 4.18.1
|
||||||
|
version_added: 10.2.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.module_helper import StateModuleHelper
|
from ansible_collections.community.general.plugins.module_utils.module_helper import StateModuleHelper
|
||||||
from ansible_collections.community.general.plugins.module_utils.xfconf import xfconf_runner
|
from ansible_collections.community.general.plugins.module_utils.xfconf import xfconf_runner, get_xfconf_version
|
||||||
|
|
||||||
|
|
||||||
class XFConfProperty(StateModuleHelper):
|
class XFConfProperty(StateModuleHelper):
|
||||||
|
@ -183,8 +190,8 @@ class XFConfProperty(StateModuleHelper):
|
||||||
|
|
||||||
def __init_module__(self):
|
def __init_module__(self):
|
||||||
self.runner = xfconf_runner(self.module)
|
self.runner = xfconf_runner(self.module)
|
||||||
self.does_not = 'Property "{0}" does not exist on channel "{1}".'.format(self.vars.property,
|
self.vars.version = get_xfconf_version(self.runner)
|
||||||
self.vars.channel)
|
self.does_not = 'Property "{0}" does not exist on channel "{1}".'.format(self.vars.property, self.vars.channel)
|
||||||
self.vars.set('previous_value', self._get())
|
self.vars.set('previous_value', self._get())
|
||||||
self.vars.set('type', self.vars.value_type)
|
self.vars.set('type', self.vars.value_type)
|
||||||
self.vars.set_meta('value', initial_value=self.vars.previous_value)
|
self.vars.set_meta('value', initial_value=self.vars.previous_value)
|
||||||
|
@ -213,8 +220,7 @@ class XFConfProperty(StateModuleHelper):
|
||||||
self.vars.stdout = ctx.results_out
|
self.vars.stdout = ctx.results_out
|
||||||
self.vars.stderr = ctx.results_err
|
self.vars.stderr = ctx.results_err
|
||||||
self.vars.cmd = ctx.cmd
|
self.vars.cmd = ctx.cmd
|
||||||
if self.verbosity >= 4:
|
self.vars.set("run_info", ctx.run_info, verbosity=4)
|
||||||
self.vars.run_info = ctx.run_info
|
|
||||||
self.vars.value = None
|
self.vars.value = None
|
||||||
|
|
||||||
def state_present(self):
|
def state_present(self):
|
||||||
|
@ -244,8 +250,7 @@ class XFConfProperty(StateModuleHelper):
|
||||||
self.vars.stdout = ctx.results_out
|
self.vars.stdout = ctx.results_out
|
||||||
self.vars.stderr = ctx.results_err
|
self.vars.stderr = ctx.results_err
|
||||||
self.vars.cmd = ctx.cmd
|
self.vars.cmd = ctx.cmd
|
||||||
if self.verbosity >= 4:
|
self.vars.set("run_info", ctx.run_info, verbosity=4)
|
||||||
self.vars.run_info = ctx.run_info
|
|
||||||
|
|
||||||
if not self.vars.is_array:
|
if not self.vars.is_array:
|
||||||
self.vars.value = self.vars.value[0]
|
self.vars.value = self.vars.value[0]
|
||||||
|
|
|
@ -118,10 +118,17 @@ value_array:
|
||||||
- Main
|
- Main
|
||||||
- Work
|
- Work
|
||||||
- Tmp
|
- Tmp
|
||||||
|
version:
|
||||||
|
description:
|
||||||
|
- The version of the C(xfconf-query) command.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
|
sample: 4.18.1
|
||||||
|
version_added: 10.2.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.module_helper import ModuleHelper
|
from ansible_collections.community.general.plugins.module_utils.module_helper import ModuleHelper
|
||||||
from ansible_collections.community.general.plugins.module_utils.xfconf import xfconf_runner
|
from ansible_collections.community.general.plugins.module_utils.xfconf import xfconf_runner, get_xfconf_version
|
||||||
|
|
||||||
|
|
||||||
class XFConfInfo(ModuleHelper):
|
class XFConfInfo(ModuleHelper):
|
||||||
|
@ -139,6 +146,7 @@ class XFConfInfo(ModuleHelper):
|
||||||
|
|
||||||
def __init_module__(self):
|
def __init_module__(self):
|
||||||
self.runner = xfconf_runner(self.module, check_rc=True)
|
self.runner = xfconf_runner(self.module, check_rc=True)
|
||||||
|
self.vars.version = get_xfconf_version(self.runner)
|
||||||
self.vars.set("list_arg", False, output=False)
|
self.vars.set("list_arg", False, output=False)
|
||||||
self.vars.set("is_array", False)
|
self.vars.set("is_array", False)
|
||||||
|
|
||||||
|
|
|
@ -21,11 +21,23 @@
|
||||||
previous_value: '100'
|
previous_value: '100'
|
||||||
type: int
|
type: int
|
||||||
value: '90'
|
value: '90'
|
||||||
|
version: "4.18.1"
|
||||||
mocks:
|
mocks:
|
||||||
run_command:
|
run_command:
|
||||||
- command: [/testbin/xfconf-query, --channel, xfwm4, --property, /general/inactive_opacity]
|
- command: [/testbin/xfconf-query, --version]
|
||||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
|
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
|
||||||
rc: 0
|
rc: 0
|
||||||
|
out: &version-output |
|
||||||
|
xfconf-query 4.18.1
|
||||||
|
|
||||||
|
Copyright (c) 2008-2023
|
||||||
|
The Xfce development team. All rights reserved.
|
||||||
|
|
||||||
|
Please report bugs to <https://gitlab.xfce.org/xfce/xfconf>.
|
||||||
|
err: ""
|
||||||
|
- command: [/testbin/xfconf-query, --channel, xfwm4, --property, /general/inactive_opacity]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
out: "100\n"
|
out: "100\n"
|
||||||
err: ""
|
err: ""
|
||||||
- command: [/testbin/xfconf-query, --channel, xfwm4, --property, /general/inactive_opacity, --create, --type, int, --set, '90']
|
- command: [/testbin/xfconf-query, --channel, xfwm4, --property, /general/inactive_opacity, --create, --type, int, --set, '90']
|
||||||
|
@ -45,8 +57,14 @@
|
||||||
previous_value: '90'
|
previous_value: '90'
|
||||||
type: int
|
type: int
|
||||||
value: '90'
|
value: '90'
|
||||||
|
version: "4.18.1"
|
||||||
mocks:
|
mocks:
|
||||||
run_command:
|
run_command:
|
||||||
|
- command: [/testbin/xfconf-query, --version]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: *version-output
|
||||||
|
err: ""
|
||||||
- command: [/testbin/xfconf-query, --channel, xfwm4, --property, /general/inactive_opacity]
|
- command: [/testbin/xfconf-query, --channel, xfwm4, --property, /general/inactive_opacity]
|
||||||
environ: *env-def
|
environ: *env-def
|
||||||
rc: 0
|
rc: 0
|
||||||
|
@ -69,8 +87,14 @@
|
||||||
previous_value: 'true'
|
previous_value: 'true'
|
||||||
type: bool
|
type: bool
|
||||||
value: 'False'
|
value: 'False'
|
||||||
|
version: "4.18.1"
|
||||||
mocks:
|
mocks:
|
||||||
run_command:
|
run_command:
|
||||||
|
- command: [/testbin/xfconf-query, --version]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: *version-output
|
||||||
|
err: ""
|
||||||
- command: [/testbin/xfconf-query, --channel, xfce4-session, --property, /general/SaveOnExit]
|
- command: [/testbin/xfconf-query, --channel, xfce4-session, --property, /general/SaveOnExit]
|
||||||
environ: *env-def
|
environ: *env-def
|
||||||
rc: 0
|
rc: 0
|
||||||
|
@ -93,8 +117,14 @@
|
||||||
previous_value: [Main, Work, Tmp]
|
previous_value: [Main, Work, Tmp]
|
||||||
type: [string, string, string]
|
type: [string, string, string]
|
||||||
value: [A, B, C]
|
value: [A, B, C]
|
||||||
|
version: "4.18.1"
|
||||||
mocks:
|
mocks:
|
||||||
run_command:
|
run_command:
|
||||||
|
- command: [/testbin/xfconf-query, --version]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: *version-output
|
||||||
|
err: ""
|
||||||
- command: [/testbin/xfconf-query, --channel, xfwm4, --property, /general/workspace_names]
|
- command: [/testbin/xfconf-query, --channel, xfwm4, --property, /general/workspace_names]
|
||||||
environ: *env-def
|
environ: *env-def
|
||||||
rc: 0
|
rc: 0
|
||||||
|
@ -136,8 +166,14 @@
|
||||||
previous_value: [A, B, C]
|
previous_value: [A, B, C]
|
||||||
type: [string, string, string]
|
type: [string, string, string]
|
||||||
value: [A, B, C]
|
value: [A, B, C]
|
||||||
|
version: "4.18.1"
|
||||||
mocks:
|
mocks:
|
||||||
run_command:
|
run_command:
|
||||||
|
- command: [/testbin/xfconf-query, --version]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: *version-output
|
||||||
|
err: ""
|
||||||
- command: [/testbin/xfconf-query, --channel, xfwm4, --property, /general/workspace_names]
|
- command: [/testbin/xfconf-query, --channel, xfwm4, --property, /general/workspace_names]
|
||||||
environ: *env-def
|
environ: *env-def
|
||||||
rc: 0
|
rc: 0
|
||||||
|
@ -177,8 +213,14 @@
|
||||||
previous_value: [A, B, C]
|
previous_value: [A, B, C]
|
||||||
type:
|
type:
|
||||||
value:
|
value:
|
||||||
|
version: "4.18.1"
|
||||||
mocks:
|
mocks:
|
||||||
run_command:
|
run_command:
|
||||||
|
- command: [/testbin/xfconf-query, --version]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: *version-output
|
||||||
|
err: ""
|
||||||
- command: [/testbin/xfconf-query, --channel, xfwm4, --property, /general/workspace_names]
|
- command: [/testbin/xfconf-query, --channel, xfwm4, --property, /general/workspace_names]
|
||||||
environ: *env-def
|
environ: *env-def
|
||||||
rc: 0
|
rc: 0
|
||||||
|
|
|
@ -6,6 +6,13 @@
|
||||||
---
|
---
|
||||||
anchors:
|
anchors:
|
||||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||||
|
out: &version-output |
|
||||||
|
xfconf-query 4.18.1
|
||||||
|
|
||||||
|
Copyright (c) 2008-2023
|
||||||
|
The Xfce development team. All rights reserved.
|
||||||
|
|
||||||
|
Please report bugs to <https://gitlab.xfce.org/xfce/xfconf>.
|
||||||
test_cases:
|
test_cases:
|
||||||
- id: test_simple_property_get
|
- id: test_simple_property_get
|
||||||
input:
|
input:
|
||||||
|
@ -14,8 +21,14 @@ test_cases:
|
||||||
output:
|
output:
|
||||||
value: '100'
|
value: '100'
|
||||||
is_array: false
|
is_array: false
|
||||||
|
version: "4.18.1"
|
||||||
mocks:
|
mocks:
|
||||||
run_command:
|
run_command:
|
||||||
|
- command: [/testbin/xfconf-query, --version]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: *version-output
|
||||||
|
err: ""
|
||||||
- command: [/testbin/xfconf-query, --channel, xfwm4, --property, /general/inactive_opacity]
|
- command: [/testbin/xfconf-query, --channel, xfwm4, --property, /general/inactive_opacity]
|
||||||
environ: *env-def
|
environ: *env-def
|
||||||
rc: 0
|
rc: 0
|
||||||
|
@ -25,9 +38,15 @@ test_cases:
|
||||||
input:
|
input:
|
||||||
channel: xfwm4
|
channel: xfwm4
|
||||||
property: /general/i_dont_exist
|
property: /general/i_dont_exist
|
||||||
output: {}
|
output:
|
||||||
|
version: "4.18.1"
|
||||||
mocks:
|
mocks:
|
||||||
run_command:
|
run_command:
|
||||||
|
- command: [/testbin/xfconf-query, --version]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: *version-output
|
||||||
|
err: ""
|
||||||
- command: [/testbin/xfconf-query, --channel, xfwm4, --property, /general/i_dont_exist]
|
- command: [/testbin/xfconf-query, --channel, xfwm4, --property, /general/i_dont_exist]
|
||||||
environ: *env-def
|
environ: *env-def
|
||||||
rc: 1
|
rc: 1
|
||||||
|
@ -39,8 +58,6 @@ test_cases:
|
||||||
output:
|
output:
|
||||||
failed: true
|
failed: true
|
||||||
msg: "missing parameter(s) required by 'property': channel"
|
msg: "missing parameter(s) required by 'property': channel"
|
||||||
mocks:
|
|
||||||
run_command: []
|
|
||||||
- id: test_property_get_array
|
- id: test_property_get_array
|
||||||
input:
|
input:
|
||||||
channel: xfwm4
|
channel: xfwm4
|
||||||
|
@ -48,8 +65,14 @@ test_cases:
|
||||||
output:
|
output:
|
||||||
is_array: true
|
is_array: true
|
||||||
value_array: [Main, Work, Tmp]
|
value_array: [Main, Work, Tmp]
|
||||||
|
version: "4.18.1"
|
||||||
mocks:
|
mocks:
|
||||||
run_command:
|
run_command:
|
||||||
|
- command: [/testbin/xfconf-query, --version]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: *version-output
|
||||||
|
err: ""
|
||||||
- command: [/testbin/xfconf-query, --channel, xfwm4, --property, /general/workspace_names]
|
- command: [/testbin/xfconf-query, --channel, xfwm4, --property, /general/workspace_names]
|
||||||
environ: *env-def
|
environ: *env-def
|
||||||
rc: 0
|
rc: 0
|
||||||
|
@ -59,8 +82,14 @@ test_cases:
|
||||||
input: {}
|
input: {}
|
||||||
output:
|
output:
|
||||||
channels: [a, b, c]
|
channels: [a, b, c]
|
||||||
|
version: "4.18.1"
|
||||||
mocks:
|
mocks:
|
||||||
run_command:
|
run_command:
|
||||||
|
- command: [/testbin/xfconf-query, --version]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: *version-output
|
||||||
|
err: ""
|
||||||
- command: [/testbin/xfconf-query, --list]
|
- command: [/testbin/xfconf-query, --list]
|
||||||
environ: *env-def
|
environ: *env-def
|
||||||
rc: 0
|
rc: 0
|
||||||
|
@ -77,8 +106,14 @@ test_cases:
|
||||||
- /general/wrap_windows
|
- /general/wrap_windows
|
||||||
- /general/wrap_workspaces
|
- /general/wrap_workspaces
|
||||||
- /general/zoom_desktop
|
- /general/zoom_desktop
|
||||||
|
version: "4.18.1"
|
||||||
mocks:
|
mocks:
|
||||||
run_command:
|
run_command:
|
||||||
|
- command: [/testbin/xfconf-query, --version]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: *version-output
|
||||||
|
err: ""
|
||||||
- command: [/testbin/xfconf-query, --list, --channel, xfwm4]
|
- command: [/testbin/xfconf-query, --list, --channel, xfwm4]
|
||||||
environ: *env-def
|
environ: *env-def
|
||||||
rc: 0
|
rc: 0
|
||||||
|
|
Loading…
Reference in New Issue