mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Test helper more (#7421)
* facter: add option to return facts instead of output variables * Update plugins/modules/facter.py Co-authored-by: Felix Fontein <felix@fontein.de> * add output doc * add changelog frag * reversed facter.py, created facter_facts.py * remove chglog fragment for new module * test helper: add Helper.from_module() * change case in variable name --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
bb59962061
commit
3b87f58070
10 changed files with 18 additions and 11 deletions
|
@ -103,10 +103,17 @@ class Helper(object):
|
|||
|
||||
@staticmethod
|
||||
def from_file(module_main, filename):
|
||||
with open(filename, "r") as TEST_CASES:
|
||||
helper = Helper(module_main, test_cases=TEST_CASES)
|
||||
with open(filename, "r") as test_cases:
|
||||
helper = Helper(module_main, test_cases=test_cases)
|
||||
return helper
|
||||
|
||||
@staticmethod
|
||||
def from_module(module):
|
||||
basename = module.__name__.split(".")[-1]
|
||||
test_spec = "tests/unit/plugins/modules/test_{0}.yaml".format(basename)
|
||||
helper = Helper.from_file(module.main, test_spec)
|
||||
return helper
|
||||
|
||||
def __init__(self, module_main, test_cases):
|
||||
self.module_main = module_main
|
||||
self._test_cases = test_cases
|
||||
|
|
|
@ -17,6 +17,6 @@ from ansible_collections.community.general.plugins.modules import cpanm
|
|||
from .helper import Helper
|
||||
|
||||
|
||||
helper = Helper.from_file(cpanm.main, "tests/unit/plugins/modules/test_cpanm.yaml")
|
||||
helper = Helper.from_module(cpanm)
|
||||
patch_bin = helper.cmd_fixture
|
||||
test_module = helper.test_module
|
||||
|
|
|
@ -11,6 +11,6 @@ from ansible_collections.community.general.plugins.modules import facter_facts
|
|||
from .helper import Helper
|
||||
|
||||
|
||||
helper = Helper.from_file(facter_facts.main, "tests/unit/plugins/modules/test_facter_facts.yaml")
|
||||
helper = Helper.from_module(facter_facts)
|
||||
patch_bin = helper.cmd_fixture
|
||||
test_module = helper.test_module
|
||||
|
|
|
@ -11,6 +11,6 @@ from ansible_collections.community.general.plugins.modules import gconftool2
|
|||
from .helper import Helper
|
||||
|
||||
|
||||
helper = Helper.from_file(gconftool2.main, "tests/unit/plugins/modules/test_gconftool2.yaml")
|
||||
helper = Helper.from_module(gconftool2)
|
||||
patch_bin = helper.cmd_fixture
|
||||
test_module = helper.test_module
|
||||
|
|
|
@ -11,6 +11,6 @@ from ansible_collections.community.general.plugins.modules import gconftool2_inf
|
|||
from .helper import Helper
|
||||
|
||||
|
||||
helper = Helper.from_file(gconftool2_info.main, "tests/unit/plugins/modules/test_gconftool2_info.yaml")
|
||||
helper = Helper.from_module(gconftool2_info)
|
||||
patch_bin = helper.cmd_fixture
|
||||
test_module = helper.test_module
|
||||
|
|
|
@ -11,6 +11,6 @@ from ansible_collections.community.general.plugins.modules import gio_mime
|
|||
from .helper import Helper
|
||||
|
||||
|
||||
helper = Helper.from_file(gio_mime.main, "tests/unit/plugins/modules/test_gio_mime.yaml")
|
||||
helper = Helper.from_module(gio_mime)
|
||||
patch_bin = helper.cmd_fixture
|
||||
test_module = helper.test_module
|
||||
|
|
|
@ -11,6 +11,6 @@ from ansible_collections.community.general.plugins.modules import opkg
|
|||
from .helper import Helper
|
||||
|
||||
|
||||
helper = Helper.from_file(opkg.main, "tests/unit/plugins/modules/test_opkg.yaml")
|
||||
helper = Helper.from_module(opkg)
|
||||
patch_bin = helper.cmd_fixture
|
||||
test_module = helper.test_module
|
||||
|
|
|
@ -17,6 +17,6 @@ from ansible_collections.community.general.plugins.modules import puppet
|
|||
from .helper import Helper
|
||||
|
||||
|
||||
helper = Helper.from_file(puppet.main, "tests/unit/plugins/modules/test_puppet.yaml")
|
||||
helper = Helper.from_module(puppet)
|
||||
patch_bin = helper.cmd_fixture
|
||||
test_module = helper.test_module
|
||||
|
|
|
@ -17,6 +17,6 @@ from ansible_collections.community.general.plugins.modules import xfconf
|
|||
from .helper import Helper
|
||||
|
||||
|
||||
helper = Helper.from_file(xfconf.main, "tests/unit/plugins/modules/test_xfconf.yaml")
|
||||
helper = Helper.from_module(xfconf)
|
||||
patch_bin = helper.cmd_fixture
|
||||
test_module = helper.test_module
|
||||
|
|
|
@ -10,6 +10,6 @@ from ansible_collections.community.general.plugins.modules import xfconf_info
|
|||
from .helper import Helper
|
||||
|
||||
|
||||
helper = Helper.from_file(xfconf_info.main, "tests/unit/plugins/modules/test_xfconf_info.yaml")
|
||||
helper = Helper.from_module(xfconf_info)
|
||||
patch_bin = helper.cmd_fixture
|
||||
test_module = helper.test_module
|
||||
|
|
Loading…
Reference in a new issue