test helper: adjusted unit tests using new features (#9563)
parent
568fcea15e
commit
3dcac2b030
|
@ -14,7 +14,7 @@ __metaclass__ = type
|
|||
|
||||
|
||||
from ansible_collections.community.general.plugins.modules import cpanm
|
||||
from .helper import Helper, RunCommandMock # pylint: disable=unused-import
|
||||
from .helper import Helper, RunCommandMock
|
||||
|
||||
|
||||
Helper.from_module(cpanm, __name__)
|
||||
Helper.from_module(cpanm, __name__, mocks=[RunCommandMock])
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
---
|
||||
anchors:
|
||||
environ_true: &env-def-true {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||
environ_false: &env-def-false {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
|
||||
test_cases:
|
||||
- id: install_dancer_compatibility
|
||||
input:
|
||||
name: Dancer
|
||||
|
@ -14,14 +18,14 @@
|
|||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/cpanm, --version]
|
||||
environ: &env-def-true {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||
environ: *env-def-true
|
||||
rc: 0
|
||||
out: |
|
||||
cpanm (App::cpanminus) version 1.7047 (/usr/local/bin/cpanm)
|
||||
perl version 5.041005 (/usr/local/bin/perl)
|
||||
err: ""
|
||||
- command: [/testbin/perl, -le, 'use Dancer;']
|
||||
environ: &env-def-false {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
|
||||
environ: *env-def-false
|
||||
rc: 2
|
||||
out: ""
|
||||
err: "error, not installed"
|
||||
|
|
|
@ -7,7 +7,7 @@ __metaclass__ = type
|
|||
|
||||
|
||||
from ansible_collections.community.general.plugins.modules import django_check
|
||||
from .helper import Helper, RunCommandMock # pylint: disable=unused-import
|
||||
from .helper import Helper, RunCommandMock
|
||||
|
||||
|
||||
Helper.from_module(django_check, __name__)
|
||||
Helper.from_module(django_check, __name__, mocks=[RunCommandMock])
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
---
|
||||
anchors:
|
||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||
test_cases:
|
||||
- id: success
|
||||
input:
|
||||
settings: whatever.settings
|
||||
|
@ -12,7 +15,7 @@
|
|||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/python, -m, django, --version]
|
||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||
environ: *env-def
|
||||
rc: 0
|
||||
out: "5.1.2\n"
|
||||
err: ""
|
||||
|
|
|
@ -7,7 +7,7 @@ __metaclass__ = type
|
|||
|
||||
|
||||
from ansible_collections.community.general.plugins.modules import django_command
|
||||
from .helper import Helper, RunCommandMock # pylint: disable=unused-import
|
||||
from .helper import Helper, RunCommandMock
|
||||
|
||||
|
||||
Helper.from_module(django_command, __name__)
|
||||
Helper.from_module(django_command, __name__, mocks=[RunCommandMock])
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
---
|
||||
anchors:
|
||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||
test_cases:
|
||||
- id: command_success
|
||||
input:
|
||||
command: check
|
||||
|
@ -16,7 +19,7 @@
|
|||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/python, -m, django, --version]
|
||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||
environ: *env-def
|
||||
rc: 0
|
||||
out: "5.1.2\n"
|
||||
err: ""
|
||||
|
|
|
@ -7,7 +7,7 @@ __metaclass__ = type
|
|||
|
||||
|
||||
from ansible_collections.community.general.plugins.modules import django_createcachetable
|
||||
from .helper import Helper, RunCommandMock # pylint: disable=unused-import
|
||||
from .helper import Helper, RunCommandMock
|
||||
|
||||
|
||||
Helper.from_module(django_createcachetable, __name__)
|
||||
Helper.from_module(django_createcachetable, __name__, mocks=[RunCommandMock])
|
||||
|
|
|
@ -4,13 +4,16 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
---
|
||||
anchors:
|
||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||
test_cases:
|
||||
- id: command_success
|
||||
input:
|
||||
settings: whatever.settings
|
||||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/python, -m, django, --version]
|
||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||
environ: *env-def
|
||||
rc: 0
|
||||
out: "5.1.2\n"
|
||||
err: ""
|
||||
|
|
|
@ -8,7 +8,7 @@ __metaclass__ = type
|
|||
|
||||
|
||||
from ansible_collections.community.general.plugins.modules import facter_facts
|
||||
from .helper import Helper, RunCommandMock # pylint: disable=unused-import
|
||||
from .helper import Helper, RunCommandMock
|
||||
|
||||
|
||||
Helper.from_module(facter_facts, __name__)
|
||||
Helper.from_module(facter_facts, __name__, mocks=[RunCommandMock])
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
---
|
||||
anchors:
|
||||
environ: &env-def {check_rc: true}
|
||||
test_cases:
|
||||
- id: simple run
|
||||
output:
|
||||
ansible_facts:
|
||||
|
@ -14,7 +17,7 @@
|
|||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/facter, --json]
|
||||
environ: &env-def {check_rc: true}
|
||||
environ: *env-def
|
||||
rc: 0
|
||||
out: >
|
||||
{ "a": 1, "b": 2, "c": 3 }
|
||||
|
|
|
@ -8,7 +8,7 @@ __metaclass__ = type
|
|||
|
||||
|
||||
from ansible_collections.community.general.plugins.modules import gconftool2
|
||||
from .helper import Helper, RunCommandMock # pylint: disable=unused-import
|
||||
from .helper import Helper, RunCommandMock
|
||||
|
||||
|
||||
Helper.from_module(gconftool2, __name__)
|
||||
Helper.from_module(gconftool2, __name__, mocks=[RunCommandMock])
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
---
|
||||
anchors:
|
||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||
test_cases:
|
||||
- id: test_simple_element_set
|
||||
input:
|
||||
state: present
|
||||
|
@ -17,7 +20,7 @@
|
|||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/gconftool-2, --version]
|
||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||
environ: *env-def
|
||||
rc: 0
|
||||
out: "3.2.6\n"
|
||||
err: ""
|
||||
|
|
|
@ -8,7 +8,7 @@ __metaclass__ = type
|
|||
|
||||
|
||||
from ansible_collections.community.general.plugins.modules import gconftool2_info
|
||||
from .helper import Helper, RunCommandMock # pylint: disable=unused-import
|
||||
from .helper import Helper, RunCommandMock
|
||||
|
||||
|
||||
Helper.from_module(gconftool2_info, __name__)
|
||||
Helper.from_module(gconftool2_info, __name__, mocks=[RunCommandMock])
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
---
|
||||
anchors:
|
||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||
test_cases:
|
||||
- id: test_simple_element_get
|
||||
input:
|
||||
key: /desktop/gnome/background/picture_filename
|
||||
|
@ -12,7 +15,7 @@
|
|||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/gconftool-2, --version]
|
||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||
environ: *env-def
|
||||
rc: 0
|
||||
out: "3.2.6\n"
|
||||
err: ""
|
||||
|
|
|
@ -8,7 +8,7 @@ __metaclass__ = type
|
|||
|
||||
|
||||
from ansible_collections.community.general.plugins.modules import gio_mime
|
||||
from .helper import Helper, RunCommandMock # pylint: disable=unused-import
|
||||
from .helper import Helper, RunCommandMock
|
||||
|
||||
|
||||
Helper.from_module(gio_mime, __name__)
|
||||
Helper.from_module(gio_mime, __name__, mocks=[RunCommandMock])
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
---
|
||||
anchors:
|
||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||
test_cases:
|
||||
- id: test_set_handler
|
||||
input:
|
||||
handler: google-chrome.desktop
|
||||
|
@ -14,7 +17,7 @@
|
|||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/gio, --version]
|
||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||
environ: *env-def
|
||||
rc: 0
|
||||
out: "2.80.0\n"
|
||||
err: ""
|
||||
|
|
|
@ -8,7 +8,7 @@ __metaclass__ = type
|
|||
|
||||
|
||||
from ansible_collections.community.general.plugins.modules import krb_ticket
|
||||
from .helper import Helper, RunCommandMock # pylint: disable=unused-import
|
||||
from .helper import Helper, RunCommandMock
|
||||
|
||||
|
||||
Helper.from_module(krb_ticket, __name__)
|
||||
Helper.from_module(krb_ticket, __name__, mocks=[RunCommandMock])
|
||||
|
|
|
@ -4,6 +4,11 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
---
|
||||
anchors:
|
||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
|
||||
environ_data: &env-data {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true, data: cool_password}
|
||||
environ_norc: &env-norc {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||
test_cases:
|
||||
- id: test_kinit_default
|
||||
input:
|
||||
state: present
|
||||
|
@ -13,12 +18,12 @@
|
|||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/klist]
|
||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
|
||||
environ: *env-def
|
||||
rc: 1
|
||||
out: ""
|
||||
err: ""
|
||||
- command: [/testbin/kinit]
|
||||
environ: &env-data {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true, data: cool_password}
|
||||
environ: *env-data
|
||||
rc: 0
|
||||
out: ""
|
||||
err: ""
|
||||
|
@ -54,7 +59,7 @@
|
|||
out: ""
|
||||
err: ""
|
||||
- command: [/testbin/kdestroy]
|
||||
environ: &env-norc {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||
environ: *env-norc
|
||||
rc: 0
|
||||
out: ""
|
||||
err: ""
|
||||
|
|
|
@ -8,7 +8,7 @@ __metaclass__ = type
|
|||
|
||||
|
||||
from ansible_collections.community.general.plugins.modules import opkg
|
||||
from .helper import Helper, RunCommandMock # pylint: disable=unused-import
|
||||
from .helper import Helper, RunCommandMock
|
||||
|
||||
|
||||
Helper.from_module(opkg, __name__)
|
||||
Helper.from_module(opkg, __name__, mocks=[RunCommandMock])
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
---
|
||||
anchors:
|
||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
|
||||
test_cases:
|
||||
- id: install_zlibdev
|
||||
input:
|
||||
name: zlib-dev
|
||||
|
@ -13,7 +16,7 @@
|
|||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/opkg, --version]
|
||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
|
||||
environ: *env-def
|
||||
rc: 0
|
||||
out: ""
|
||||
err: ""
|
||||
|
|
|
@ -14,7 +14,7 @@ __metaclass__ = type
|
|||
|
||||
|
||||
from ansible_collections.community.general.plugins.modules import puppet
|
||||
from .helper import Helper, RunCommandMock # pylint: disable=unused-import
|
||||
from .helper import Helper, RunCommandMock
|
||||
|
||||
|
||||
Helper.from_module(puppet, __name__)
|
||||
Helper.from_module(puppet, __name__, mocks=[RunCommandMock])
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
---
|
||||
anchors:
|
||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
|
||||
test_cases:
|
||||
- id: puppet_agent_plain
|
||||
input: {}
|
||||
output:
|
||||
|
@ -11,7 +14,7 @@
|
|||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/puppet, config, print, agent_disabled_lockfile]
|
||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
|
||||
environ: *env-def
|
||||
rc: 0
|
||||
out: "blah, anything"
|
||||
err: ""
|
||||
|
|
|
@ -9,7 +9,7 @@ __metaclass__ = type
|
|||
import sys
|
||||
|
||||
from ansible_collections.community.general.plugins.modules import snap
|
||||
from .helper import Helper, RunCommandMock # pylint: disable=unused-import
|
||||
from .helper import Helper, RunCommandMock
|
||||
|
||||
|
||||
issue_6803_status_out = """Name Version Rev Tracking Publisher Notes
|
||||
|
@ -475,4 +475,4 @@ TEST_CASES = [
|
|||
),
|
||||
]
|
||||
|
||||
Helper.from_spec(sys.modules[__name__], snap, TEST_CASES)
|
||||
Helper.from_spec(sys.modules[__name__], snap, TEST_CASES, mocks=[RunCommandMock])
|
||||
|
|
|
@ -14,7 +14,7 @@ __metaclass__ = type
|
|||
|
||||
|
||||
from ansible_collections.community.general.plugins.modules import xfconf
|
||||
from .helper import Helper, RunCommandMock # pylint: disable=unused-import
|
||||
from .helper import Helper, RunCommandMock
|
||||
|
||||
|
||||
Helper.from_module(xfconf, __name__)
|
||||
Helper.from_module(xfconf, __name__, mocks=[RunCommandMock])
|
||||
|
|
|
@ -4,6 +4,16 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
---
|
||||
anchors:
|
||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
|
||||
version_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:
|
||||
- id: test_missing_input
|
||||
input: {}
|
||||
output:
|
||||
|
@ -25,15 +35,9 @@
|
|||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/xfconf-query, --version]
|
||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
|
||||
environ: *env-def
|
||||
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>.
|
||||
out: *version-output
|
||||
err: ""
|
||||
- command: [/testbin/xfconf-query, --channel, xfwm4, --property, /general/inactive_opacity]
|
||||
environ: *env-def
|
||||
|
|
Loading…
Reference in New Issue