mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 20:01:25 -07:00
gconftool2: fix change output (#6270)
* gconftool2: fix change output * add changelog frag * gconftool2: improve visibility on the output * fix obtaining updated value after `set` * use issue URL in the changelog fragment * fix further issues * fix return value docs + changelog frag * Update plugins/modules/gconftool2.py Co-authored-by: Felix Fontein <felix@fontein.de> * fix return value doc --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
d254372d37
commit
3c20261264
3 changed files with 134 additions and 15 deletions
|
@ -36,7 +36,6 @@ TEST_CASES = [
|
|||
(0, '100\n', '',),
|
||||
),
|
||||
],
|
||||
'new_value': '100',
|
||||
}
|
||||
],
|
||||
[
|
||||
|
@ -50,11 +49,10 @@ TEST_CASES = [
|
|||
(0, '', "No value set for `/desktop/gnome/background/picture_filename'\n",),
|
||||
),
|
||||
],
|
||||
'new_value': None,
|
||||
}
|
||||
],
|
||||
[
|
||||
{'state': 'present', 'key': '/desktop/gnome/background/picture_filename', 'value': '200', 'value_type': 'int'},
|
||||
{'state': 'present', 'key': '/desktop/gnome/background/picture_filename', 'value': 200, 'value_type': 'int'},
|
||||
{
|
||||
'id': 'test_simple_element_set',
|
||||
'run_command.calls': [
|
||||
|
@ -66,10 +64,104 @@ TEST_CASES = [
|
|||
(
|
||||
['/testbin/gconftool-2', '--type', 'int', '--set', '/desktop/gnome/background/picture_filename', '200'],
|
||||
{'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': True},
|
||||
(0, '', '',),
|
||||
),
|
||||
(
|
||||
['/testbin/gconftool-2', '--get', '/desktop/gnome/background/picture_filename'],
|
||||
{'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': True},
|
||||
(0, '200\n', '',),
|
||||
),
|
||||
],
|
||||
'new_value': '200',
|
||||
'changed': True,
|
||||
}
|
||||
],
|
||||
[
|
||||
{'state': 'present', 'key': '/desktop/gnome/background/picture_filename', 'value': 200, 'value_type': 'int'},
|
||||
{
|
||||
'id': 'test_simple_element_set_idempotency_int',
|
||||
'run_command.calls': [
|
||||
(
|
||||
['/testbin/gconftool-2', '--get', '/desktop/gnome/background/picture_filename'],
|
||||
{'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': True},
|
||||
(0, '200\n', '',),
|
||||
),
|
||||
(
|
||||
['/testbin/gconftool-2', '--type', 'int', '--set', '/desktop/gnome/background/picture_filename', '200'],
|
||||
{'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': True},
|
||||
(0, '', '',),
|
||||
),
|
||||
(
|
||||
['/testbin/gconftool-2', '--get', '/desktop/gnome/background/picture_filename'],
|
||||
{'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': True},
|
||||
(0, '200\n', '',),
|
||||
),
|
||||
],
|
||||
'new_value': '200',
|
||||
'changed': False,
|
||||
}
|
||||
],
|
||||
[
|
||||
{'state': 'present', 'key': '/apps/gnome_settings_daemon/screensaver/start_screensaver', 'value': 'false', 'value_type': 'bool'},
|
||||
{
|
||||
'id': 'test_simple_element_set_idempotency_bool',
|
||||
'run_command.calls': [
|
||||
(
|
||||
['/testbin/gconftool-2', '--get', '/apps/gnome_settings_daemon/screensaver/start_screensaver'],
|
||||
{'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': True},
|
||||
(0, 'false\n', '',),
|
||||
),
|
||||
(
|
||||
['/testbin/gconftool-2', '--type', 'bool', '--set', '/apps/gnome_settings_daemon/screensaver/start_screensaver', 'false'],
|
||||
{'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': True},
|
||||
(0, '', '',),
|
||||
),
|
||||
(
|
||||
['/testbin/gconftool-2', '--get', '/apps/gnome_settings_daemon/screensaver/start_screensaver'],
|
||||
{'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': True},
|
||||
(0, 'false\n', '',),
|
||||
),
|
||||
],
|
||||
'new_value': 'false',
|
||||
'changed': False,
|
||||
}
|
||||
],
|
||||
[
|
||||
{'state': 'absent', 'key': '/desktop/gnome/background/picture_filename'},
|
||||
{
|
||||
'id': 'test_simple_element_unset',
|
||||
'run_command.calls': [
|
||||
(
|
||||
['/testbin/gconftool-2', '--get', '/desktop/gnome/background/picture_filename'],
|
||||
{'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': True},
|
||||
(0, '200\n', '',),
|
||||
),
|
||||
(
|
||||
['/testbin/gconftool-2', '--unset', '/desktop/gnome/background/picture_filename'],
|
||||
{'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': True},
|
||||
(0, '', '',),
|
||||
),
|
||||
],
|
||||
'changed': True,
|
||||
}
|
||||
],
|
||||
[
|
||||
{'state': 'absent', 'key': '/apps/gnome_settings_daemon/screensaver/start_screensaver'},
|
||||
{
|
||||
'id': 'test_simple_element_unset_idempotency',
|
||||
'run_command.calls': [
|
||||
(
|
||||
['/testbin/gconftool-2', '--get', '/apps/gnome_settings_daemon/screensaver/start_screensaver'],
|
||||
{'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': True},
|
||||
(0, '', '',),
|
||||
),
|
||||
(
|
||||
['/testbin/gconftool-2', '--unset', '/apps/gnome_settings_daemon/screensaver/start_screensaver'],
|
||||
{'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': True},
|
||||
(0, '', '',),
|
||||
),
|
||||
],
|
||||
'changed': False,
|
||||
}
|
||||
],
|
||||
]
|
||||
|
@ -101,6 +193,11 @@ def test_gconftool2(mocker, capfd, patch_gconftool2, testcase):
|
|||
print("testcase =\n%s" % testcase)
|
||||
print("results =\n%s" % results)
|
||||
|
||||
if 'changed' in testcase:
|
||||
assert results.get('changed', False) == testcase['changed']
|
||||
if 'new_value' in testcase:
|
||||
assert results.get('new_value', None) == testcase['new_value']
|
||||
|
||||
for conditional_test_result in ('value',):
|
||||
if conditional_test_result in testcase:
|
||||
assert conditional_test_result in results, "'{0}' not found in {1}".format(conditional_test_result, results)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue