parent
085bcb22a2
commit
8e324881a6
|
@ -10,5 +10,5 @@ plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt
|
||||||
plugins/modules/udm_user.py import-3.12 # Uses deprecated stdlib library 'crypt'
|
plugins/modules/udm_user.py import-3.12 # Uses deprecated stdlib library 'crypt'
|
||||||
plugins/modules/xfconf.py validate-modules:return-syntax-error
|
plugins/modules/xfconf.py validate-modules:return-syntax-error
|
||||||
plugins/module_utils/univention_umc.py pylint:use-yield-from # suggested construct does not work with Python 2
|
plugins/module_utils/univention_umc.py pylint:use-yield-from # suggested construct does not work with Python 2
|
||||||
tests/unit/plugins/modules/helper.py pylint:use-yield-from # suggested construct does not work with Python 2
|
tests/unit/plugins/modules/uthelper.py pylint:use-yield-from # suggested construct does not work with Python 2
|
||||||
tests/unit/plugins/modules/test_gio_mime.yaml no-smart-quotes
|
tests/unit/plugins/modules/test_gio_mime.yaml no-smart-quotes
|
||||||
|
|
|
@ -10,5 +10,5 @@ plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt
|
||||||
plugins/modules/udm_user.py import-3.12 # Uses deprecated stdlib library 'crypt'
|
plugins/modules/udm_user.py import-3.12 # Uses deprecated stdlib library 'crypt'
|
||||||
plugins/modules/xfconf.py validate-modules:return-syntax-error
|
plugins/modules/xfconf.py validate-modules:return-syntax-error
|
||||||
plugins/module_utils/univention_umc.py pylint:use-yield-from # suggested construct does not work with Python 2
|
plugins/module_utils/univention_umc.py pylint:use-yield-from # suggested construct does not work with Python 2
|
||||||
tests/unit/plugins/modules/helper.py pylint:use-yield-from # suggested construct does not work with Python 2
|
tests/unit/plugins/modules/uthelper.py pylint:use-yield-from # suggested construct does not work with Python 2
|
||||||
tests/unit/plugins/modules/test_gio_mime.yaml no-smart-quotes
|
tests/unit/plugins/modules/test_gio_mime.yaml no-smart-quotes
|
||||||
|
|
|
@ -10,5 +10,5 @@ plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt
|
||||||
plugins/modules/udm_user.py import-3.12 # Uses deprecated stdlib library 'crypt'
|
plugins/modules/udm_user.py import-3.12 # Uses deprecated stdlib library 'crypt'
|
||||||
plugins/modules/xfconf.py validate-modules:return-syntax-error
|
plugins/modules/xfconf.py validate-modules:return-syntax-error
|
||||||
plugins/module_utils/univention_umc.py pylint:use-yield-from # suggested construct does not work with Python 2
|
plugins/module_utils/univention_umc.py pylint:use-yield-from # suggested construct does not work with Python 2
|
||||||
tests/unit/plugins/modules/helper.py pylint:use-yield-from # suggested construct does not work with Python 2
|
tests/unit/plugins/modules/uthelper.py pylint:use-yield-from # suggested construct does not work with Python 2
|
||||||
tests/unit/plugins/modules/test_gio_mime.yaml no-smart-quotes
|
tests/unit/plugins/modules/test_gio_mime.yaml no-smart-quotes
|
||||||
|
|
|
@ -14,7 +14,7 @@ __metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.modules import cpanm
|
from ansible_collections.community.general.plugins.modules import cpanm
|
||||||
from .helper import Helper, RunCommandMock
|
from .uthelper import UTHelper, RunCommandMock
|
||||||
|
|
||||||
|
|
||||||
Helper.from_module(cpanm, __name__, mocks=[RunCommandMock])
|
UTHelper.from_module(cpanm, __name__, mocks=[RunCommandMock])
|
||||||
|
|
|
@ -7,7 +7,7 @@ __metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.modules import django_check
|
from ansible_collections.community.general.plugins.modules import django_check
|
||||||
from .helper import Helper, RunCommandMock
|
from .uthelper import UTHelper, RunCommandMock
|
||||||
|
|
||||||
|
|
||||||
Helper.from_module(django_check, __name__, mocks=[RunCommandMock])
|
UTHelper.from_module(django_check, __name__, mocks=[RunCommandMock])
|
||||||
|
|
|
@ -7,7 +7,7 @@ __metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.modules import django_command
|
from ansible_collections.community.general.plugins.modules import django_command
|
||||||
from .helper import Helper, RunCommandMock
|
from .uthelper import UTHelper, RunCommandMock
|
||||||
|
|
||||||
|
|
||||||
Helper.from_module(django_command, __name__, mocks=[RunCommandMock])
|
UTHelper.from_module(django_command, __name__, mocks=[RunCommandMock])
|
||||||
|
|
|
@ -7,7 +7,7 @@ __metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.modules import django_createcachetable
|
from ansible_collections.community.general.plugins.modules import django_createcachetable
|
||||||
from .helper import Helper, RunCommandMock
|
from .uthelper import UTHelper, RunCommandMock
|
||||||
|
|
||||||
|
|
||||||
Helper.from_module(django_createcachetable, __name__, mocks=[RunCommandMock])
|
UTHelper.from_module(django_createcachetable, __name__, mocks=[RunCommandMock])
|
||||||
|
|
|
@ -8,7 +8,7 @@ __metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.modules import facter_facts
|
from ansible_collections.community.general.plugins.modules import facter_facts
|
||||||
from .helper import Helper, RunCommandMock
|
from .uthelper import UTHelper, RunCommandMock
|
||||||
|
|
||||||
|
|
||||||
Helper.from_module(facter_facts, __name__, mocks=[RunCommandMock])
|
UTHelper.from_module(facter_facts, __name__, mocks=[RunCommandMock])
|
||||||
|
|
|
@ -8,7 +8,7 @@ __metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.modules import gconftool2
|
from ansible_collections.community.general.plugins.modules import gconftool2
|
||||||
from .helper import Helper, RunCommandMock
|
from .uthelper import UTHelper, RunCommandMock
|
||||||
|
|
||||||
|
|
||||||
Helper.from_module(gconftool2, __name__, mocks=[RunCommandMock])
|
UTHelper.from_module(gconftool2, __name__, mocks=[RunCommandMock])
|
||||||
|
|
|
@ -8,7 +8,7 @@ __metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.modules import gconftool2_info
|
from ansible_collections.community.general.plugins.modules import gconftool2_info
|
||||||
from .helper import Helper, RunCommandMock
|
from .uthelper import UTHelper, RunCommandMock
|
||||||
|
|
||||||
|
|
||||||
Helper.from_module(gconftool2_info, __name__, mocks=[RunCommandMock])
|
UTHelper.from_module(gconftool2_info, __name__, mocks=[RunCommandMock])
|
||||||
|
|
|
@ -8,7 +8,7 @@ __metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.modules import gio_mime
|
from ansible_collections.community.general.plugins.modules import gio_mime
|
||||||
from .helper import Helper, RunCommandMock
|
from .uthelper import UTHelper, RunCommandMock
|
||||||
|
|
||||||
|
|
||||||
Helper.from_module(gio_mime, __name__, mocks=[RunCommandMock])
|
UTHelper.from_module(gio_mime, __name__, mocks=[RunCommandMock])
|
||||||
|
|
|
@ -8,7 +8,7 @@ __metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.modules import krb_ticket
|
from ansible_collections.community.general.plugins.modules import krb_ticket
|
||||||
from .helper import Helper, RunCommandMock
|
from .uthelper import UTHelper, RunCommandMock
|
||||||
|
|
||||||
|
|
||||||
Helper.from_module(krb_ticket, __name__, mocks=[RunCommandMock])
|
UTHelper.from_module(krb_ticket, __name__, mocks=[RunCommandMock])
|
||||||
|
|
|
@ -8,7 +8,7 @@ __metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.modules import opkg
|
from ansible_collections.community.general.plugins.modules import opkg
|
||||||
from .helper import Helper, RunCommandMock
|
from .uthelper import UTHelper, RunCommandMock
|
||||||
|
|
||||||
|
|
||||||
Helper.from_module(opkg, __name__, mocks=[RunCommandMock])
|
UTHelper.from_module(opkg, __name__, mocks=[RunCommandMock])
|
||||||
|
|
|
@ -14,7 +14,7 @@ __metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.modules import puppet
|
from ansible_collections.community.general.plugins.modules import puppet
|
||||||
from .helper import Helper, RunCommandMock
|
from .uthelper import UTHelper, RunCommandMock
|
||||||
|
|
||||||
|
|
||||||
Helper.from_module(puppet, __name__, mocks=[RunCommandMock])
|
UTHelper.from_module(puppet, __name__, mocks=[RunCommandMock])
|
||||||
|
|
|
@ -9,7 +9,7 @@ __metaclass__ = type
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.modules import snap
|
from ansible_collections.community.general.plugins.modules import snap
|
||||||
from .helper import Helper, RunCommandMock
|
from .uthelper import UTHelper, RunCommandMock
|
||||||
|
|
||||||
|
|
||||||
issue_6803_status_out = """Name Version Rev Tracking Publisher Notes
|
issue_6803_status_out = """Name Version Rev Tracking Publisher Notes
|
||||||
|
@ -501,4 +501,4 @@ TEST_SPEC = dict(
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
Helper.from_spec(snap, sys.modules[__name__], TEST_SPEC, mocks=[RunCommandMock])
|
UTHelper.from_spec(snap, sys.modules[__name__], TEST_SPEC, mocks=[RunCommandMock])
|
||||||
|
|
|
@ -14,7 +14,7 @@ __metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.modules import xfconf
|
from ansible_collections.community.general.plugins.modules import xfconf
|
||||||
from .helper import Helper, RunCommandMock
|
from .uthelper import UTHelper, RunCommandMock
|
||||||
|
|
||||||
|
|
||||||
Helper.from_module(xfconf, __name__, mocks=[RunCommandMock])
|
UTHelper.from_module(xfconf, __name__, mocks=[RunCommandMock])
|
||||||
|
|
|
@ -7,7 +7,7 @@ __metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.modules import xfconf_info
|
from ansible_collections.community.general.plugins.modules import xfconf_info
|
||||||
from .helper import Helper, RunCommandMock
|
from .uthelper import UTHelper, RunCommandMock
|
||||||
|
|
||||||
|
|
||||||
Helper.from_module(xfconf_info, __name__, mocks=[RunCommandMock])
|
UTHelper.from_module(xfconf_info, __name__, mocks=[RunCommandMock])
|
||||||
|
|
|
@ -14,18 +14,18 @@ import yaml
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
class Helper(object):
|
class UTHelper(object):
|
||||||
TEST_SPEC_VALID_SECTIONS = ["anchors", "test_cases"]
|
TEST_SPEC_VALID_SECTIONS = ["anchors", "test_cases"]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_spec(ansible_module, test_module, test_spec, mocks=None):
|
def from_spec(ansible_module, test_module, test_spec, mocks=None):
|
||||||
helper = Helper(ansible_module, test_module, test_spec=test_spec, mocks=mocks)
|
helper = UTHelper(ansible_module, test_module, test_spec=test_spec, mocks=mocks)
|
||||||
return helper
|
return helper
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_file(ansible_module, test_module, test_spec_filehandle, mocks=None):
|
def from_file(ansible_module, test_module, test_spec_filehandle, mocks=None):
|
||||||
test_spec = yaml.safe_load(test_spec_filehandle)
|
test_spec = yaml.safe_load(test_spec_filehandle)
|
||||||
return Helper.from_spec(ansible_module, test_module, test_spec, mocks)
|
return UTHelper.from_spec(ansible_module, test_module, test_spec, mocks)
|
||||||
|
|
||||||
# @TODO: calculate the test_module_name automatically, remove one more parameter
|
# @TODO: calculate the test_module_name automatically, remove one more parameter
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -36,7 +36,7 @@ class Helper(object):
|
||||||
test_spec_filename = test_module.__file__.replace('.py', ext)
|
test_spec_filename = test_module.__file__.replace('.py', ext)
|
||||||
if os.path.exists(test_spec_filename):
|
if os.path.exists(test_spec_filename):
|
||||||
with open(test_spec_filename, "r") as test_spec_filehandle:
|
with open(test_spec_filename, "r") as test_spec_filehandle:
|
||||||
return Helper.from_file(ansible_module, test_module, test_spec_filehandle, mocks=mocks)
|
return UTHelper.from_file(ansible_module, test_module, test_spec_filehandle, mocks=mocks)
|
||||||
|
|
||||||
raise Exception("Cannot find test case file for {0} with one of the extensions: {1}".format(test_module.__file__, extensions))
|
raise Exception("Cannot find test case file for {0} with one of the extensions: {1}".format(test_module.__file__, extensions))
|
||||||
|
|
Loading…
Reference in New Issue