From 8ab8010b6d2dfcc68736e9730eb506cef59857fe Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 22 Mar 2025 13:12:31 +0100 Subject: [PATCH] Use more unit test utils from community.internal_test_tools (#9918) * Make conftest's patch_ansible_module use the context manager from .utils. * Fix test dependencies. * Use module mock utils from community.internal_test_tools. * Use DataDictLoader from community.internal_test_tools. * Use trust util from community.internal_test_tools. --- .github/workflows/ansible-test.yml | 4 + tests/unit/mock/loader.py | 103 ------------------ tests/unit/plugins/inventory/test_iocage.py | 3 +- .../unit/plugins/inventory/test_opennebula.py | 2 +- tests/unit/plugins/lookup/test_dependent.py | 7 +- .../plugins/lookup/test_merge_variables.py | 2 +- tests/unit/plugins/modules/conftest.py | 41 ++++--- .../plugins/modules/test_alerta_customer.py | 2 +- tests/unit/plugins/modules/test_archive.py | 2 +- .../modules/test_bitbucket_access_key.py | 2 +- .../test_bitbucket_pipeline_key_pair.py | 2 +- .../test_bitbucket_pipeline_known_host.py | 2 +- .../test_bitbucket_pipeline_variable.py | 2 +- .../unit/plugins/modules/test_bootc_manage.py | 2 +- tests/unit/plugins/modules/test_campfire.py | 2 +- .../modules/test_circonus_annotation.py | 2 +- .../plugins/modules/test_datadog_downtime.py | 2 +- tests/unit/plugins/modules/test_discord.py | 2 +- .../modules/test_dnf_config_manager.py | 2 +- tests/unit/plugins/modules/test_dnsimple.py | 2 +- .../plugins/modules/test_dnsimple_info.py | 2 +- tests/unit/plugins/modules/test_gem.py | 2 +- .../plugins/modules/test_icinga2_feature.py | 2 +- .../plugins/modules/test_ipa_getkeytab.py | 2 +- .../plugins/modules/test_ipa_otpconfig.py | 2 +- .../unit/plugins/modules/test_ipa_otptoken.py | 2 +- .../unit/plugins/modules/test_ipa_pwpolicy.py | 2 +- .../plugins/modules/test_java_keystore.py | 2 +- .../plugins/modules/test_jenkins_build.py | 8 +- .../modules/test_jenkins_build_info.py | 8 +- .../unit/plugins/modules/test_jenkins_node.py | 8 +- .../modules/test_keycloak_authentication.py | 2 +- ...eycloak_authentication_required_actions.py | 2 +- .../plugins/modules/test_keycloak_client.py | 2 +- .../test_keycloak_client_rolemapping.py | 2 +- .../modules/test_keycloak_clientscope.py | 2 +- .../modules/test_keycloak_component.py | 2 +- .../test_keycloak_identity_provider.py | 2 +- .../plugins/modules/test_keycloak_realm.py | 2 +- .../modules/test_keycloak_realm_info.py | 2 +- .../modules/test_keycloak_realm_keys.py | 2 +- .../test_keycloak_realm_keys_metadata_info.py | 2 +- .../plugins/modules/test_keycloak_role.py | 2 +- .../plugins/modules/test_keycloak_user.py | 2 +- .../modules/test_keycloak_user_federation.py | 2 +- .../modules/test_keycloak_userprofile.py | 2 +- tests/unit/plugins/modules/test_linode.py | 2 +- tests/unit/plugins/modules/test_linode_v4.py | 2 +- tests/unit/plugins/modules/test_lvg_rename.py | 2 +- tests/unit/plugins/modules/test_modprobe.py | 2 +- tests/unit/plugins/modules/test_monit.py | 2 +- .../unit/plugins/modules/test_nomad_token.py | 2 +- tests/unit/plugins/modules/test_npm.py | 2 +- .../plugins/modules/test_ocapi_command.py | 4 +- tests/unit/plugins/modules/test_ocapi_info.py | 4 +- tests/unit/plugins/modules/test_pacman.py | 2 +- .../plugins/modules/test_pagerduty_alert.py | 2 +- .../plugins/modules/test_pagerduty_change.py | 2 +- tests/unit/plugins/modules/test_parted.py | 2 +- tests/unit/plugins/modules/test_pmem.py | 2 +- .../unit/plugins/modules/test_pritunl_org.py | 2 +- .../plugins/modules/test_pritunl_org_info.py | 2 +- .../unit/plugins/modules/test_pritunl_user.py | 2 +- .../plugins/modules/test_pritunl_user_info.py | 2 +- .../plugins/modules/test_proxmox_backup.py | 2 +- .../modules/test_proxmox_backup_info.py | 2 +- .../unit/plugins/modules/test_proxmox_kvm.py | 2 +- .../unit/plugins/modules/test_proxmox_snap.py | 2 +- .../test_proxmox_storage_contents_info.py | 2 +- .../modules/test_proxmox_tasks_info.py | 2 +- .../plugins/modules/test_proxmox_template.py | 2 +- .../plugins/modules/test_proxmox_vm_info.py | 2 +- tests/unit/plugins/modules/test_redis_data.py | 2 +- .../plugins/modules/test_redis_data_incr.py | 2 +- .../plugins/modules/test_redis_data_info.py | 2 +- tests/unit/plugins/modules/test_redis_info.py | 2 +- .../unit/plugins/modules/test_rhsm_release.py | 2 +- .../plugins/modules/test_rpm_ostree_pkg.py | 2 +- .../test_scaleway_compute_private_network.py | 2 +- .../modules/test_scaleway_private_network.py | 2 +- .../plugins/modules/test_simpleinit_msb.py | 2 +- tests/unit/plugins/modules/test_slack.py | 2 +- .../unit/plugins/modules/test_solaris_zone.py | 2 +- tests/unit/plugins/modules/test_statsd.py | 2 +- tests/unit/plugins/modules/test_sysupgrade.py | 2 +- tests/unit/plugins/modules/test_terraform.py | 2 +- tests/unit/plugins/modules/test_ufw.py | 8 +- tests/unit/plugins/modules/test_usb_facts.py | 2 +- .../modules/test_wdc_redfish_command.py | 4 +- .../plugins/modules/test_wdc_redfish_info.py | 4 +- .../modules/test_xcc_redfish_command.py | 4 +- tests/unit/plugins/modules/uthelper.py | 6 +- .../unit/plugins/plugin_utils/test_unsafe.py | 97 +++++++++++------ tests/utils/shippable/shippable.sh | 17 ++- 94 files changed, 217 insertions(+), 267 deletions(-) delete mode 100644 tests/unit/mock/loader.py diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index 0f0dd132dc..c8d2cb6184 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -40,6 +40,8 @@ jobs: coverage: ${{ github.event_name == 'schedule' && 'always' || 'never' }} pull-request-change-detection: 'true' testing-type: sanity + pre-test-cmd: >- + git clone --depth=1 --single-branch https://github.com/ansible-collections/community.internal_test_tools.git ../../community/internal_test_tools units: runs-on: ubuntu-latest @@ -156,6 +158,8 @@ jobs: ; git clone --depth=1 --single-branch https://github.com/ansible-collections/community.crypto.git ../../community/crypto ; + git clone --depth=1 --single-branch https://github.com/ansible-collections/community.docker.git ../../community/docker + ; git clone --depth=1 --single-branch https://github.com/ansible-collections/community.internal_test_tools.git ../../community/internal_test_tools pull-request-change-detection: 'true' target: ${{ matrix.target }} diff --git a/tests/unit/mock/loader.py b/tests/unit/mock/loader.py deleted file mode 100644 index f7aff17c32..0000000000 --- a/tests/unit/mock/loader.py +++ /dev/null @@ -1,103 +0,0 @@ -# Copyright (c) 2012-2014, Michael DeHaan -# -# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) -# SPDX-License-Identifier: GPL-3.0-or-later - -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -import os - -from ansible.errors import AnsibleParserError -from ansible.parsing.dataloader import DataLoader -from ansible.module_utils.common.text.converters import to_bytes, to_text - - -class DictDataLoader(DataLoader): - - def __init__(self, file_mapping=None): - file_mapping = {} if file_mapping is None else file_mapping - assert isinstance(file_mapping, dict) - - super(DictDataLoader, self).__init__() - - self._file_mapping = file_mapping - self._build_known_directories() - self._vault_secrets = None - - def load_from_file(self, path, cache=True, unsafe=False): - path = to_text(path) - if path in self._file_mapping: - return self.load(self._file_mapping[path], path) - return None - - # TODO: the real _get_file_contents returns a bytestring, so we actually convert the - # unicode/text it's created with to utf-8 - def _get_file_contents(self, file_name): - path = to_text(file_name) - if path in self._file_mapping: - return (to_bytes(self._file_mapping[path]), False) - else: - raise AnsibleParserError("file not found: %s" % path) - - def path_exists(self, path): - path = to_text(path) - return path in self._file_mapping or path in self._known_directories - - def is_file(self, path): - path = to_text(path) - return path in self._file_mapping - - def is_directory(self, path): - path = to_text(path) - return path in self._known_directories - - def list_directory(self, path): - ret = [] - path = to_text(path) - for x in (list(self._file_mapping.keys()) + self._known_directories): - if x.startswith(path): - if os.path.dirname(x) == path: - ret.append(os.path.basename(x)) - return ret - - def is_executable(self, path): - # FIXME: figure out a way to make paths return true for this - return False - - def _add_known_directory(self, directory): - if directory not in self._known_directories: - self._known_directories.append(directory) - - def _build_known_directories(self): - self._known_directories = [] - for path in self._file_mapping: - dirname = os.path.dirname(path) - while dirname not in ('/', ''): - self._add_known_directory(dirname) - dirname = os.path.dirname(dirname) - - def push(self, path, content): - rebuild_dirs = False - if path not in self._file_mapping: - rebuild_dirs = True - - self._file_mapping[path] = content - - if rebuild_dirs: - self._build_known_directories() - - def pop(self, path): - if path in self._file_mapping: - del self._file_mapping[path] - self._build_known_directories() - - def clear(self): - self._file_mapping = dict() - self._known_directories = [] - - def get_basedir(self): - return os.getcwd() - - def set_vault_secrets(self, vault_secrets): - self._vault_secrets = vault_secrets diff --git a/tests/unit/plugins/inventory/test_iocage.py b/tests/unit/plugins/inventory/test_iocage.py index 98492ff9aa..4bd56aeb92 100644 --- a/tests/unit/plugins/inventory/test_iocage.py +++ b/tests/unit/plugins/inventory/test_iocage.py @@ -13,6 +13,7 @@ import yaml from ansible.inventory.data import InventoryData from ansible.template import Templar from ansible_collections.community.general.plugins.inventory.iocage import InventoryModule +from ansible_collections.community.internal_test_tools.tests.unit.utils.trust import make_trusted @pytest.fixture @@ -49,7 +50,7 @@ def load_yml_data(path): def get_option(option): groups = {} - groups['test'] = "inventory_hostname.startswith('test')" + groups['test'] = make_trusted("inventory_hostname.startswith('test')") if option == 'groups': return groups diff --git a/tests/unit/plugins/inventory/test_opennebula.py b/tests/unit/plugins/inventory/test_opennebula.py index 21d485e4bb..d30e3eb84c 100644 --- a/tests/unit/plugins/inventory/test_opennebula.py +++ b/tests/unit/plugins/inventory/test_opennebula.py @@ -19,9 +19,9 @@ from ansible import constants as C from ansible.inventory.data import InventoryData from ansible.inventory.manager import InventoryManager from ansible.module_utils.common.text.converters import to_native +from ansible_collections.community.internal_test_tools.tests.unit.mock.loader import DictDataLoader from ansible_collections.community.general.plugins.inventory.opennebula import InventoryModule -from ansible_collections.community.general.tests.unit.mock.loader import DictDataLoader from ansible_collections.community.general.tests.unit.mock.path import mock_unfrackpath_noop diff --git a/tests/unit/plugins/lookup/test_dependent.py b/tests/unit/plugins/lookup/test_dependent.py index 74d7c41239..ad02cecf19 100644 --- a/tests/unit/plugins/lookup/test_dependent.py +++ b/tests/unit/plugins/lookup/test_dependent.py @@ -13,6 +13,7 @@ from ansible_collections.community.internal_test_tools.tests.unit.compat.unittes from ansible_collections.community.internal_test_tools.tests.unit.compat.mock import ( MagicMock, ) +from ansible_collections.community.internal_test_tools.tests.unit.utils.trust import make_trusted from ansible.plugins.loader import lookup_loader @@ -30,9 +31,9 @@ class TestLookupModule(TestCase): self.assertListEqual( self.lookup.run( [ - {'a': '[1, 2]'}, - {'b': '[item.a + 3, item.a + 6]'}, - {'c': '[item.a + item.b * 10]'}, + {'a': make_trusted('[1, 2]')}, + {'b': make_trusted('[item.a + 3, item.a + 6]')}, + {'c': make_trusted('[item.a + item.b * 10]')}, ], {}, ), diff --git a/tests/unit/plugins/lookup/test_merge_variables.py b/tests/unit/plugins/lookup/test_merge_variables.py index ba8209439a..8c4fb169cf 100644 --- a/tests/unit/plugins/lookup/test_merge_variables.py +++ b/tests/unit/plugins/lookup/test_merge_variables.py @@ -8,7 +8,7 @@ __metaclass__ = type from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.mock.loader import DictDataLoader +from ansible_collections.community.internal_test_tools.tests.unit.mock.loader import DictDataLoader from ansible.plugins import AnsiblePlugin from ansible.template import Templar diff --git a/tests/unit/plugins/modules/conftest.py b/tests/unit/plugins/modules/conftest.py index d357137651..7eaba767a3 100644 --- a/tests/unit/plugins/modules/conftest.py +++ b/tests/unit/plugins/modules/conftest.py @@ -5,45 +5,44 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type +import contextlib as _contextlib import json import pytest from ansible.module_utils.six import string_types -from ansible.module_utils.common.text.converters import to_bytes from ansible.module_utils.common._collections_compat import MutableMapping from ansible_collections.community.general.plugins.module_utils import deps +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args as _set_module_args -def fix_ansible_args(args): +def _fix_ansible_args(args): if isinstance(args, string_types): - return args + # This should be deprecated! + return json.loads(args) if isinstance(args, MutableMapping): - if 'ANSIBLE_MODULE_ARGS' not in args: - args = {'ANSIBLE_MODULE_ARGS': args} - if '_ansible_remote_tmp' not in args['ANSIBLE_MODULE_ARGS']: - args['ANSIBLE_MODULE_ARGS']['_ansible_remote_tmp'] = '/tmp' - if '_ansible_keep_remote_files' not in args['ANSIBLE_MODULE_ARGS']: - args['ANSIBLE_MODULE_ARGS']['_ansible_keep_remote_files'] = False - args = json.dumps(args) return args - else: - raise Exception('Malformed data to the patch_ansible_module pytest fixture') + raise Exception('Malformed data to the patch_ansible_module pytest fixture') @pytest.fixture -def patch_ansible_module(request, mocker): - if hasattr(request, "param"): - args = fix_ansible_args(request.param) - mocker.patch('ansible.module_utils.basic._ANSIBLE_ARGS', to_bytes(args)) - else: - def _patch(args): - args = fix_ansible_args(args) - mocker.patch('ansible.module_utils.basic._ANSIBLE_ARGS', to_bytes(args)) - return _patch +def patch_ansible_module(request): + args = _fix_ansible_args(request.param) + with _set_module_args(args): + yield + + +@pytest.fixture +def patch_ansible_module_uthelper(request): + @_contextlib.contextmanager + def _patch(args): + args = _fix_ansible_args(args) + with _set_module_args(args): + yield + return _patch @pytest.fixture(autouse=True) diff --git a/tests/unit/plugins/modules/test_alerta_customer.py b/tests/unit/plugins/modules/test_alerta_customer.py index 2bdf6c72b5..8cf7e05826 100644 --- a/tests/unit/plugins/modules/test_alerta_customer.py +++ b/tests/unit/plugins/modules/test_alerta_customer.py @@ -9,7 +9,7 @@ import json import pytest from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible_collections.community.general.plugins.modules import alerta_customer -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args class MockedReponse(object): diff --git a/tests/unit/plugins/modules/test_archive.py b/tests/unit/plugins/modules/test_archive.py index becbc41f87..48e13c6a57 100644 --- a/tests/unit/plugins/modules/test_archive.py +++ b/tests/unit/plugins/modules/test_archive.py @@ -10,7 +10,7 @@ import pytest from ansible.module_utils.basic import AnsibleModule from ansible_collections.community.general.tests.unit.compat.mock import Mock, patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules.archive import get_archive, common_path diff --git a/tests/unit/plugins/modules/test_bitbucket_access_key.py b/tests/unit/plugins/modules/test_bitbucket_access_key.py index 34b53ed776..1fdd7cef33 100644 --- a/tests/unit/plugins/modules/test_bitbucket_access_key.py +++ b/tests/unit/plugins/modules/test_bitbucket_access_key.py @@ -9,7 +9,7 @@ from ansible_collections.community.general.plugins.module_utils.source_control.b from ansible_collections.community.general.plugins.modules import bitbucket_access_key from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleFailJson, AnsibleExitJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleFailJson, AnsibleExitJson, ModuleTestCase, set_module_args class TestBucketAccessKeyModule(ModuleTestCase): diff --git a/tests/unit/plugins/modules/test_bitbucket_pipeline_key_pair.py b/tests/unit/plugins/modules/test_bitbucket_pipeline_key_pair.py index 9cbb8b8b8f..c81d2970aa 100644 --- a/tests/unit/plugins/modules/test_bitbucket_pipeline_key_pair.py +++ b/tests/unit/plugins/modules/test_bitbucket_pipeline_key_pair.py @@ -9,7 +9,7 @@ from ansible_collections.community.general.plugins.module_utils.source_control.b from ansible_collections.community.general.plugins.modules import bitbucket_pipeline_key_pair from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleFailJson, AnsibleExitJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleFailJson, AnsibleExitJson, ModuleTestCase, set_module_args class TestBucketPipelineKeyPairModule(ModuleTestCase): diff --git a/tests/unit/plugins/modules/test_bitbucket_pipeline_known_host.py b/tests/unit/plugins/modules/test_bitbucket_pipeline_known_host.py index 6b8536442e..4a24431f94 100644 --- a/tests/unit/plugins/modules/test_bitbucket_pipeline_known_host.py +++ b/tests/unit/plugins/modules/test_bitbucket_pipeline_known_host.py @@ -12,7 +12,7 @@ from ansible_collections.community.general.plugins.modules import bitbucket_pipe from ansible_collections.community.general.plugins.modules.bitbucket_pipeline_known_host import HAS_PARAMIKO from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args class TestBucketPipelineKnownHostModule(ModuleTestCase): diff --git a/tests/unit/plugins/modules/test_bitbucket_pipeline_variable.py b/tests/unit/plugins/modules/test_bitbucket_pipeline_variable.py index aebf3bb62a..ea73246917 100644 --- a/tests/unit/plugins/modules/test_bitbucket_pipeline_variable.py +++ b/tests/unit/plugins/modules/test_bitbucket_pipeline_variable.py @@ -9,7 +9,7 @@ from ansible_collections.community.general.plugins.module_utils.source_control.b from ansible_collections.community.general.plugins.modules import bitbucket_pipeline_variable from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleFailJson, AnsibleExitJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleFailJson, AnsibleExitJson, ModuleTestCase, set_module_args class TestBucketPipelineVariableModule(ModuleTestCase): diff --git a/tests/unit/plugins/modules/test_bootc_manage.py b/tests/unit/plugins/modules/test_bootc_manage.py index 3e5ab7bea2..b0fed302c7 100644 --- a/tests/unit/plugins/modules/test_bootc_manage.py +++ b/tests/unit/plugins/modules/test_bootc_manage.py @@ -7,7 +7,7 @@ __metaclass__ = type from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible_collections.community.general.plugins.modules import bootc_manage -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args class TestBootcManageModule(ModuleTestCase): diff --git a/tests/unit/plugins/modules/test_campfire.py b/tests/unit/plugins/modules/test_campfire.py index 8eb30f920c..afe0f5284c 100644 --- a/tests/unit/plugins/modules/test_campfire.py +++ b/tests/unit/plugins/modules/test_campfire.py @@ -8,7 +8,7 @@ __metaclass__ = type import pytest from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible_collections.community.general.plugins.modules import campfire -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args class TestCampfireModule(ModuleTestCase): diff --git a/tests/unit/plugins/modules/test_circonus_annotation.py b/tests/unit/plugins/modules/test_circonus_annotation.py index 8efcb76ff4..ffdd5f38c2 100644 --- a/tests/unit/plugins/modules/test_circonus_annotation.py +++ b/tests/unit/plugins/modules/test_circonus_annotation.py @@ -15,7 +15,7 @@ from urllib3.response import HTTPResponse from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible.module_utils.common.text.converters import to_bytes from ansible_collections.community.general.plugins.modules import circonus_annotation -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args class TestCirconusAnnotation(ModuleTestCase): diff --git a/tests/unit/plugins/modules/test_datadog_downtime.py b/tests/unit/plugins/modules/test_datadog_downtime.py index 1a09563196..0f2ad16b7b 100644 --- a/tests/unit/plugins/modules/test_datadog_downtime.py +++ b/tests/unit/plugins/modules/test_datadog_downtime.py @@ -9,7 +9,7 @@ __metaclass__ = type from ansible_collections.community.general.plugins.modules import datadog_downtime from ansible_collections.community.general.tests.unit.compat.mock import MagicMock, patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ( +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ( AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args ) diff --git a/tests/unit/plugins/modules/test_discord.py b/tests/unit/plugins/modules/test_discord.py index 3d4763857d..9375c123cb 100644 --- a/tests/unit/plugins/modules/test_discord.py +++ b/tests/unit/plugins/modules/test_discord.py @@ -9,7 +9,7 @@ import json import pytest from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible_collections.community.general.plugins.modules import discord -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args class TestDiscordModule(ModuleTestCase): diff --git a/tests/unit/plugins/modules/test_dnf_config_manager.py b/tests/unit/plugins/modules/test_dnf_config_manager.py index 2f07030874..790e5e96c9 100644 --- a/tests/unit/plugins/modules/test_dnf_config_manager.py +++ b/tests/unit/plugins/modules/test_dnf_config_manager.py @@ -9,7 +9,7 @@ __metaclass__ = type from ansible_collections.community.general.tests.unit.compat.mock import patch, call from ansible_collections.community.general.plugins.modules import dnf_config_manager as dnf_config_manager_module -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, \ +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, \ ModuleTestCase, set_module_args # Return value on all-default arguments diff --git a/tests/unit/plugins/modules/test_dnsimple.py b/tests/unit/plugins/modules/test_dnsimple.py index 3a56412aee..baff04f61d 100644 --- a/tests/unit/plugins/modules/test_dnsimple.py +++ b/tests/unit/plugins/modules/test_dnsimple.py @@ -9,7 +9,7 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible_collections.community.general.plugins.modules import dnsimple as dnsimple_module -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleFailJson, ModuleTestCase, set_module_args from ansible_collections.community.general.tests.unit.compat.mock import patch import pytest import sys diff --git a/tests/unit/plugins/modules/test_dnsimple_info.py b/tests/unit/plugins/modules/test_dnsimple_info.py index 25ac439734..b97039b9bd 100644 --- a/tests/unit/plugins/modules/test_dnsimple_info.py +++ b/tests/unit/plugins/modules/test_dnsimple_info.py @@ -9,7 +9,7 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible_collections.community.general.plugins.modules import dnsimple_info -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleFailJson, ModuleTestCase, set_module_args, AnsibleExitJson +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleFailJson, ModuleTestCase, set_module_args, AnsibleExitJson from httmock import response from httmock import with_httmock from httmock import urlmatch diff --git a/tests/unit/plugins/modules/test_gem.py b/tests/unit/plugins/modules/test_gem.py index eee6a96d60..78c73be5a6 100644 --- a/tests/unit/plugins/modules/test_gem.py +++ b/tests/unit/plugins/modules/test_gem.py @@ -9,7 +9,7 @@ import copy import pytest from ansible_collections.community.general.plugins.modules import gem -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args def get_command(run_command): diff --git a/tests/unit/plugins/modules/test_icinga2_feature.py b/tests/unit/plugins/modules/test_icinga2_feature.py index 7a28705dc0..18b6181445 100644 --- a/tests/unit/plugins/modules/test_icinga2_feature.py +++ b/tests/unit/plugins/modules/test_icinga2_feature.py @@ -10,7 +10,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type from ansible_collections.community.general.plugins.modules import icinga2_feature -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible.module_utils import basic diff --git a/tests/unit/plugins/modules/test_ipa_getkeytab.py b/tests/unit/plugins/modules/test_ipa_getkeytab.py index 246531ed4f..d7f87c5a1b 100644 --- a/tests/unit/plugins/modules/test_ipa_getkeytab.py +++ b/tests/unit/plugins/modules/test_ipa_getkeytab.py @@ -8,7 +8,7 @@ __metaclass__ = type from ansible_collections.community.general.tests.unit.compat.mock import call, patch from ansible_collections.community.general.plugins.modules import ipa_getkeytab -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args class IPAKeytabModuleTestCase(ModuleTestCase): diff --git a/tests/unit/plugins/modules/test_ipa_otpconfig.py b/tests/unit/plugins/modules/test_ipa_otpconfig.py index 160142732d..c20bc0ecbb 100644 --- a/tests/unit/plugins/modules/test_ipa_otpconfig.py +++ b/tests/unit/plugins/modules/test_ipa_otpconfig.py @@ -11,7 +11,7 @@ from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import call, patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import ipa_otpconfig diff --git a/tests/unit/plugins/modules/test_ipa_otptoken.py b/tests/unit/plugins/modules/test_ipa_otptoken.py index c87e9a1514..ed70869fd2 100644 --- a/tests/unit/plugins/modules/test_ipa_otptoken.py +++ b/tests/unit/plugins/modules/test_ipa_otptoken.py @@ -11,7 +11,7 @@ from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import call, patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import ipa_otptoken diff --git a/tests/unit/plugins/modules/test_ipa_pwpolicy.py b/tests/unit/plugins/modules/test_ipa_pwpolicy.py index aeb750fbc6..5d77fcfac1 100644 --- a/tests/unit/plugins/modules/test_ipa_pwpolicy.py +++ b/tests/unit/plugins/modules/test_ipa_pwpolicy.py @@ -11,7 +11,7 @@ from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import call, patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import ipa_pwpolicy diff --git a/tests/unit/plugins/modules/test_java_keystore.py b/tests/unit/plugins/modules/test_java_keystore.py index 8dd763067e..d2a2710093 100644 --- a/tests/unit/plugins/modules/test_java_keystore.py +++ b/tests/unit/plugins/modules/test_java_keystore.py @@ -11,7 +11,7 @@ __metaclass__ = type import os -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ModuleTestCase, set_module_args from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible_collections.community.general.tests.unit.compat.mock import Mock from ansible.module_utils.basic import AnsibleModule diff --git a/tests/unit/plugins/modules/test_jenkins_build.py b/tests/unit/plugins/modules/test_jenkins_build.py index 78bcfa7c7b..e188754df3 100644 --- a/tests/unit/plugins/modules/test_jenkins_build.py +++ b/tests/unit/plugins/modules/test_jenkins_build.py @@ -9,7 +9,13 @@ from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible.module_utils import basic from ansible_collections.community.general.plugins.modules import jenkins_build -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, set_module_args, exit_json, fail_json +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ( + AnsibleExitJson, + AnsibleFailJson, + set_module_args, + exit_json, + fail_json, +) class jenkins: diff --git a/tests/unit/plugins/modules/test_jenkins_build_info.py b/tests/unit/plugins/modules/test_jenkins_build_info.py index a0efd63a59..02412e68fd 100644 --- a/tests/unit/plugins/modules/test_jenkins_build_info.py +++ b/tests/unit/plugins/modules/test_jenkins_build_info.py @@ -9,7 +9,13 @@ from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible.module_utils import basic from ansible_collections.community.general.plugins.modules import jenkins_build_info -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, set_module_args, exit_json, fail_json +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ( + AnsibleExitJson, + AnsibleFailJson, + set_module_args, + exit_json, + fail_json, +) class jenkins: diff --git a/tests/unit/plugins/modules/test_jenkins_node.py b/tests/unit/plugins/modules/test_jenkins_node.py index 068861407c..49bc616437 100644 --- a/tests/unit/plugins/modules/test_jenkins_node.py +++ b/tests/unit/plugins/modules/test_jenkins_node.py @@ -13,7 +13,13 @@ import pytest from ansible_collections.community.general.tests.unit.compat.mock import patch, call from ansible_collections.community.general.plugins.modules import jenkins_node -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, set_module_args, exit_json, fail_json +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ( + AnsibleExitJson, + AnsibleFailJson, + set_module_args, + exit_json, + fail_json, +) from pytest import fixture, raises, mark, param diff --git a/tests/unit/plugins/modules/test_keycloak_authentication.py b/tests/unit/plugins/modules/test_keycloak_authentication.py index 1b7d722f27..c5459a12e3 100644 --- a/tests/unit/plugins/modules/test_keycloak_authentication.py +++ b/tests/unit/plugins/modules/test_keycloak_authentication.py @@ -11,7 +11,7 @@ from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import keycloak_authentication diff --git a/tests/unit/plugins/modules/test_keycloak_authentication_required_actions.py b/tests/unit/plugins/modules/test_keycloak_authentication_required_actions.py index 5713737a66..aabf939597 100644 --- a/tests/unit/plugins/modules/test_keycloak_authentication_required_actions.py +++ b/tests/unit/plugins/modules/test_keycloak_authentication_required_actions.py @@ -11,7 +11,7 @@ from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import keycloak_authentication_required_actions diff --git a/tests/unit/plugins/modules/test_keycloak_client.py b/tests/unit/plugins/modules/test_keycloak_client.py index e2fd3b4c73..1c10cdb635 100644 --- a/tests/unit/plugins/modules/test_keycloak_client.py +++ b/tests/unit/plugins/modules/test_keycloak_client.py @@ -12,7 +12,7 @@ from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import keycloak_client diff --git a/tests/unit/plugins/modules/test_keycloak_client_rolemapping.py b/tests/unit/plugins/modules/test_keycloak_client_rolemapping.py index 3cf6983d33..cdadb92204 100644 --- a/tests/unit/plugins/modules/test_keycloak_client_rolemapping.py +++ b/tests/unit/plugins/modules/test_keycloak_client_rolemapping.py @@ -11,7 +11,7 @@ from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import keycloak_client_rolemapping diff --git a/tests/unit/plugins/modules/test_keycloak_clientscope.py b/tests/unit/plugins/modules/test_keycloak_clientscope.py index 03eb0e615f..f8486f91db 100644 --- a/tests/unit/plugins/modules/test_keycloak_clientscope.py +++ b/tests/unit/plugins/modules/test_keycloak_clientscope.py @@ -12,7 +12,7 @@ from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import keycloak_clientscope diff --git a/tests/unit/plugins/modules/test_keycloak_component.py b/tests/unit/plugins/modules/test_keycloak_component.py index 5d0886899f..c376942379 100644 --- a/tests/unit/plugins/modules/test_keycloak_component.py +++ b/tests/unit/plugins/modules/test_keycloak_component.py @@ -15,7 +15,7 @@ from ansible.module_utils.six import StringIO from ansible_collections.community.general.plugins.modules import keycloak_realm_key from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import keycloak_component diff --git a/tests/unit/plugins/modules/test_keycloak_identity_provider.py b/tests/unit/plugins/modules/test_keycloak_identity_provider.py index 901a41dd4f..7253d18c68 100644 --- a/tests/unit/plugins/modules/test_keycloak_identity_provider.py +++ b/tests/unit/plugins/modules/test_keycloak_identity_provider.py @@ -11,7 +11,7 @@ from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import keycloak_identity_provider diff --git a/tests/unit/plugins/modules/test_keycloak_realm.py b/tests/unit/plugins/modules/test_keycloak_realm.py index 7cf2ba48ae..65cedfd0f7 100644 --- a/tests/unit/plugins/modules/test_keycloak_realm.py +++ b/tests/unit/plugins/modules/test_keycloak_realm.py @@ -11,7 +11,7 @@ from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import keycloak_realm diff --git a/tests/unit/plugins/modules/test_keycloak_realm_info.py b/tests/unit/plugins/modules/test_keycloak_realm_info.py index 8b20203433..723071d6e2 100644 --- a/tests/unit/plugins/modules/test_keycloak_realm_info.py +++ b/tests/unit/plugins/modules/test_keycloak_realm_info.py @@ -11,7 +11,7 @@ from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import keycloak_realm_info diff --git a/tests/unit/plugins/modules/test_keycloak_realm_keys.py b/tests/unit/plugins/modules/test_keycloak_realm_keys.py index 06fe8c44ae..e1bfbe41a1 100644 --- a/tests/unit/plugins/modules/test_keycloak_realm_keys.py +++ b/tests/unit/plugins/modules/test_keycloak_realm_keys.py @@ -11,7 +11,7 @@ from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import keycloak_realm_key diff --git a/tests/unit/plugins/modules/test_keycloak_realm_keys_metadata_info.py b/tests/unit/plugins/modules/test_keycloak_realm_keys_metadata_info.py index b520ea2a85..76d329939e 100644 --- a/tests/unit/plugins/modules/test_keycloak_realm_keys_metadata_info.py +++ b/tests/unit/plugins/modules/test_keycloak_realm_keys_metadata_info.py @@ -16,7 +16,7 @@ from ansible_collections.community.general.plugins.modules import \ keycloak_realm_keys_metadata_info from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ( +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ( AnsibleExitJson, ModuleTestCase, set_module_args) diff --git a/tests/unit/plugins/modules/test_keycloak_role.py b/tests/unit/plugins/modules/test_keycloak_role.py index 528bb1f500..3721b3622f 100644 --- a/tests/unit/plugins/modules/test_keycloak_role.py +++ b/tests/unit/plugins/modules/test_keycloak_role.py @@ -11,7 +11,7 @@ from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import keycloak_role diff --git a/tests/unit/plugins/modules/test_keycloak_user.py b/tests/unit/plugins/modules/test_keycloak_user.py index f0446c5b9c..8b4c1faa1f 100644 --- a/tests/unit/plugins/modules/test_keycloak_user.py +++ b/tests/unit/plugins/modules/test_keycloak_user.py @@ -12,7 +12,7 @@ from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import keycloak_user diff --git a/tests/unit/plugins/modules/test_keycloak_user_federation.py b/tests/unit/plugins/modules/test_keycloak_user_federation.py index 0929868147..dd77ab6855 100644 --- a/tests/unit/plugins/modules/test_keycloak_user_federation.py +++ b/tests/unit/plugins/modules/test_keycloak_user_federation.py @@ -11,7 +11,7 @@ from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import keycloak_user_federation diff --git a/tests/unit/plugins/modules/test_keycloak_userprofile.py b/tests/unit/plugins/modules/test_keycloak_userprofile.py index 816dc6cea5..fce77795b1 100644 --- a/tests/unit/plugins/modules/test_keycloak_userprofile.py +++ b/tests/unit/plugins/modules/test_keycloak_userprofile.py @@ -11,7 +11,7 @@ from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import keycloak_userprofile diff --git a/tests/unit/plugins/modules/test_linode.py b/tests/unit/plugins/modules/test_linode.py index 737a179ba1..e54c656816 100644 --- a/tests/unit/plugins/modules/test_linode.py +++ b/tests/unit/plugins/modules/test_linode.py @@ -8,7 +8,7 @@ __metaclass__ = type import pytest from ansible_collections.community.general.plugins.modules import linode -from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args from .linode_conftest import api_key, auth # noqa: F401, pylint: disable=unused-import diff --git a/tests/unit/plugins/modules/test_linode_v4.py b/tests/unit/plugins/modules/test_linode_v4.py index 62143aa461..9ef182b5ab 100644 --- a/tests/unit/plugins/modules/test_linode_v4.py +++ b/tests/unit/plugins/modules/test_linode_v4.py @@ -22,7 +22,7 @@ from linode_api4 import LinodeClient from ansible_collections.community.general.plugins.modules import linode_v4 from ansible_collections.community.general.plugins.module_utils.linode import get_user_agent -from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args from ansible_collections.community.general.tests.unit.compat import mock from .linode_conftest import access_token, no_access_token_in_env, default_args, mock_linode # noqa: F401, pylint: disable=unused-import diff --git a/tests/unit/plugins/modules/test_lvg_rename.py b/tests/unit/plugins/modules/test_lvg_rename.py index 5b758e9d7e..00ba1c7f21 100644 --- a/tests/unit/plugins/modules/test_lvg_rename.py +++ b/tests/unit/plugins/modules/test_lvg_rename.py @@ -8,7 +8,7 @@ __metaclass__ = type from ansible_collections.community.general.plugins.modules import lvg_rename from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ( +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ( AnsibleFailJson, AnsibleExitJson, ModuleTestCase, set_module_args) diff --git a/tests/unit/plugins/modules/test_modprobe.py b/tests/unit/plugins/modules/test_modprobe.py index eb51f0211b..f4c618241a 100644 --- a/tests/unit/plugins/modules/test_modprobe.py +++ b/tests/unit/plugins/modules/test_modprobe.py @@ -7,7 +7,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type import sys -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ModuleTestCase, set_module_args from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible_collections.community.general.tests.unit.compat.mock import Mock from ansible_collections.community.general.tests.unit.compat.mock import mock_open diff --git a/tests/unit/plugins/modules/test_monit.py b/tests/unit/plugins/modules/test_monit.py index 7f8f15dd9e..f3a3a5685d 100644 --- a/tests/unit/plugins/modules/test_monit.py +++ b/tests/unit/plugins/modules/test_monit.py @@ -10,7 +10,7 @@ import pytest from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.plugins.modules import monit -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson TEST_OUTPUT = """ diff --git a/tests/unit/plugins/modules/test_nomad_token.py b/tests/unit/plugins/modules/test_nomad_token.py index 7f9b5db96e..b312201166 100644 --- a/tests/unit/plugins/modules/test_nomad_token.py +++ b/tests/unit/plugins/modules/test_nomad_token.py @@ -11,7 +11,7 @@ __metaclass__ = type import nomad from ansible_collections.community.general.plugins.modules import nomad_token from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args def mock_acl_get_tokens(empty_list=False): diff --git a/tests/unit/plugins/modules/test_npm.py b/tests/unit/plugins/modules/test_npm.py index df9bb5034a..2647e9eeab 100644 --- a/tests/unit/plugins/modules/test_npm.py +++ b/tests/unit/plugins/modules/test_npm.py @@ -8,7 +8,7 @@ __metaclass__ = type from ansible_collections.community.general.tests.unit.compat.mock import call, patch from ansible_collections.community.general.plugins.modules import npm -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args class NPMModuleTestCase(ModuleTestCase): diff --git a/tests/unit/plugins/modules/test_ocapi_command.py b/tests/unit/plugins/modules/test_ocapi_command.py index 35fd928614..96c2127b99 100644 --- a/tests/unit/plugins/modules/test_ocapi_command.py +++ b/tests/unit/plugins/modules/test_ocapi_command.py @@ -14,8 +14,8 @@ from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible_collections.community.general.tests.unit.compat import unittest from ansible.module_utils import basic import ansible_collections.community.general.plugins.modules.ocapi_command as module -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson -from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args, exit_json, fail_json +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args, exit_json, fail_json from ansible.module_utils.six.moves.urllib.parse import urljoin diff --git a/tests/unit/plugins/modules/test_ocapi_info.py b/tests/unit/plugins/modules/test_ocapi_info.py index 01864570c6..f2570b6baf 100644 --- a/tests/unit/plugins/modules/test_ocapi_info.py +++ b/tests/unit/plugins/modules/test_ocapi_info.py @@ -10,8 +10,8 @@ from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible_collections.community.general.tests.unit.compat import unittest from ansible.module_utils import basic import ansible_collections.community.general.plugins.modules.ocapi_info as module -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson -from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args, exit_json, fail_json +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args, exit_json, fail_json MOCK_BASE_URI = "mockBaseUri" MOCK_JOB_NAME_IN_PROGRESS = "MockJobInProgress" diff --git a/tests/unit/plugins/modules/test_pacman.py b/tests/unit/plugins/modules/test_pacman.py index 4533700e05..feab8fc542 100644 --- a/tests/unit/plugins/modules/test_pacman.py +++ b/tests/unit/plugins/modules/test_pacman.py @@ -9,7 +9,7 @@ __metaclass__ = type from ansible.module_utils import basic from ansible_collections.community.general.tests.unit.compat import mock -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ( +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ( AnsibleExitJson, AnsibleFailJson, set_module_args, diff --git a/tests/unit/plugins/modules/test_pagerduty_alert.py b/tests/unit/plugins/modules/test_pagerduty_alert.py index 612c134dc7..1010d23b64 100644 --- a/tests/unit/plugins/modules/test_pagerduty_alert.py +++ b/tests/unit/plugins/modules/test_pagerduty_alert.py @@ -10,7 +10,7 @@ from ansible_collections.community.general.plugins.modules import pagerduty_aler import json import pytest from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args class PagerDutyAlertsTest(unittest.TestCase): diff --git a/tests/unit/plugins/modules/test_pagerduty_change.py b/tests/unit/plugins/modules/test_pagerduty_change.py index b4632da7ff..81e7b90902 100644 --- a/tests/unit/plugins/modules/test_pagerduty_change.py +++ b/tests/unit/plugins/modules/test_pagerduty_change.py @@ -9,7 +9,7 @@ import json import pytest from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible_collections.community.general.plugins.modules import pagerduty_change -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args class TestPagerDutyChangeModule(ModuleTestCase): diff --git a/tests/unit/plugins/modules/test_parted.py b/tests/unit/plugins/modules/test_parted.py index 46c08bd1e7..b0285c7ccc 100644 --- a/tests/unit/plugins/modules/test_parted.py +++ b/tests/unit/plugins/modules/test_parted.py @@ -9,7 +9,7 @@ from ansible_collections.community.general.tests.unit.compat.mock import patch, from ansible_collections.community.general.plugins.modules import parted as parted_module from ansible_collections.community.general.plugins.modules.parted import parse_parted_version from ansible_collections.community.general.plugins.modules.parted import parse_partition_info -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args # Example of output : parted -s -m /dev/sdb -- unit 'MB' print parted_output1 = """ diff --git a/tests/unit/plugins/modules/test_pmem.py b/tests/unit/plugins/modules/test_pmem.py index 0ce3ec555b..c2f920c4c6 100644 --- a/tests/unit/plugins/modules/test_pmem.py +++ b/tests/unit/plugins/modules/test_pmem.py @@ -11,7 +11,7 @@ import json pytest.importorskip('xmltodict') -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ModuleTestCase, set_module_args, AnsibleFailJson, AnsibleExitJson +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ModuleTestCase, set_module_args, AnsibleFailJson, AnsibleExitJson from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible_collections.community.general.plugins.modules import pmem as pmem_module diff --git a/tests/unit/plugins/modules/test_pritunl_org.py b/tests/unit/plugins/modules/test_pritunl_org.py index 9836fd32c8..4ebb27e9fa 100644 --- a/tests/unit/plugins/modules/test_pritunl_org.py +++ b/tests/unit/plugins/modules/test_pritunl_org.py @@ -19,7 +19,7 @@ from ansible_collections.community.general.tests.unit.plugins.module_utils.net_t PritunlListOrganizationAfterPostMock, PritunlPostOrganizationMock, ) -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ( +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ( AnsibleExitJson, AnsibleFailJson, ModuleTestCase, diff --git a/tests/unit/plugins/modules/test_pritunl_org_info.py b/tests/unit/plugins/modules/test_pritunl_org_info.py index 3f25b38d2e..92ffa8c0cf 100644 --- a/tests/unit/plugins/modules/test_pritunl_org_info.py +++ b/tests/unit/plugins/modules/test_pritunl_org_info.py @@ -15,7 +15,7 @@ from ansible_collections.community.general.tests.unit.plugins.module_utils.net_t PritunlListOrganizationMock, PritunlEmptyOrganizationMock, ) -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ( +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ( AnsibleExitJson, AnsibleFailJson, ModuleTestCase, diff --git a/tests/unit/plugins/modules/test_pritunl_user.py b/tests/unit/plugins/modules/test_pritunl_user.py index cade205e04..74826553d0 100644 --- a/tests/unit/plugins/modules/test_pritunl_user.py +++ b/tests/unit/plugins/modules/test_pritunl_user.py @@ -20,7 +20,7 @@ from ansible_collections.community.general.tests.unit.plugins.module_utils.net_t PritunlPostUserMock, PritunlPutUserMock, ) -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ( +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ( AnsibleExitJson, AnsibleFailJson, ModuleTestCase, diff --git a/tests/unit/plugins/modules/test_pritunl_user_info.py b/tests/unit/plugins/modules/test_pritunl_user_info.py index 79823769c7..09bd22b535 100644 --- a/tests/unit/plugins/modules/test_pritunl_user_info.py +++ b/tests/unit/plugins/modules/test_pritunl_user_info.py @@ -15,7 +15,7 @@ from ansible_collections.community.general.tests.unit.plugins.module_utils.net_t PritunlListOrganizationMock, PritunlListUserMock, ) -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ( +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ( AnsibleExitJson, AnsibleFailJson, ModuleTestCase, diff --git a/tests/unit/plugins/modules/test_proxmox_backup.py b/tests/unit/plugins/modules/test_proxmox_backup.py index ca899c442a..52841ec8ed 100644 --- a/tests/unit/plugins/modules/test_proxmox_backup.py +++ b/tests/unit/plugins/modules/test_proxmox_backup.py @@ -7,7 +7,7 @@ from __future__ import (absolute_import, division, print_function) import \ ansible_collections.community.general.plugins.module_utils.proxmox as proxmox_utils from ansible_collections.community.general.plugins.modules import proxmox_backup -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ( +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ( AnsibleExitJson, AnsibleFailJson, set_module_args, ModuleTestCase) from ansible_collections.community.general.tests.unit.compat.mock import patch diff --git a/tests/unit/plugins/modules/test_proxmox_backup_info.py b/tests/unit/plugins/modules/test_proxmox_backup_info.py index a6d17c51f2..91219d7e2a 100644 --- a/tests/unit/plugins/modules/test_proxmox_backup_info.py +++ b/tests/unit/plugins/modules/test_proxmox_backup_info.py @@ -15,7 +15,7 @@ proxmoxer = pytest.importorskip("proxmoxer") from ansible_collections.community.general.plugins.modules import proxmox_backup_info from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ( +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ( AnsibleExitJson, AnsibleFailJson, ModuleTestCase, diff --git a/tests/unit/plugins/modules/test_proxmox_kvm.py b/tests/unit/plugins/modules/test_proxmox_kvm.py index 4a13cbe260..1134e1ff11 100644 --- a/tests/unit/plugins/modules/test_proxmox_kvm.py +++ b/tests/unit/plugins/modules/test_proxmox_kvm.py @@ -23,7 +23,7 @@ from ansible_collections.community.general.tests.unit.compat.mock import ( patch, DEFAULT, ) -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ( +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ( AnsibleExitJson, AnsibleFailJson, ModuleTestCase, diff --git a/tests/unit/plugins/modules/test_proxmox_snap.py b/tests/unit/plugins/modules/test_proxmox_snap.py index 1ac711bf13..67c1b0e323 100644 --- a/tests/unit/plugins/modules/test_proxmox_snap.py +++ b/tests/unit/plugins/modules/test_proxmox_snap.py @@ -20,7 +20,7 @@ mandatory_py_version = pytest.mark.skipif( from ansible_collections.community.general.tests.unit.compat.mock import MagicMock, patch from ansible_collections.community.general.plugins.modules import proxmox_snap import ansible_collections.community.general.plugins.module_utils.proxmox as proxmox_utils -from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args def get_resources(type): diff --git a/tests/unit/plugins/modules/test_proxmox_storage_contents_info.py b/tests/unit/plugins/modules/test_proxmox_storage_contents_info.py index 19544d4281..917831792e 100644 --- a/tests/unit/plugins/modules/test_proxmox_storage_contents_info.py +++ b/tests/unit/plugins/modules/test_proxmox_storage_contents_info.py @@ -14,7 +14,7 @@ proxmoxer = pytest.importorskip("proxmoxer") from ansible_collections.community.general.plugins.modules import proxmox_storage_contents_info from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ( +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ( AnsibleExitJson, AnsibleFailJson, ModuleTestCase, diff --git a/tests/unit/plugins/modules/test_proxmox_tasks_info.py b/tests/unit/plugins/modules/test_proxmox_tasks_info.py index f8377ddb16..46abde863a 100644 --- a/tests/unit/plugins/modules/test_proxmox_tasks_info.py +++ b/tests/unit/plugins/modules/test_proxmox_tasks_info.py @@ -24,7 +24,7 @@ mandatory_py_version = pytest.mark.skipif( from ansible_collections.community.general.plugins.modules import proxmox_tasks_info import ansible_collections.community.general.plugins.module_utils.proxmox as proxmox_utils from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args NODE = 'node01' TASK_UPID = 'UPID:iaclab-01-01:000029DD:1599528B:6108F068:srvreload:networking:root@pam:' diff --git a/tests/unit/plugins/modules/test_proxmox_template.py b/tests/unit/plugins/modules/test_proxmox_template.py index 4cd40bfe1f..673a0a631e 100644 --- a/tests/unit/plugins/modules/test_proxmox_template.py +++ b/tests/unit/plugins/modules/test_proxmox_template.py @@ -21,7 +21,7 @@ mandatory_py_version = pytest.mark.skipif( from ansible_collections.community.general.plugins.modules import proxmox_template from ansible_collections.community.general.tests.unit.compat.mock import patch, Mock -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ( +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ( AnsibleFailJson, ModuleTestCase, set_module_args, diff --git a/tests/unit/plugins/modules/test_proxmox_vm_info.py b/tests/unit/plugins/modules/test_proxmox_vm_info.py index f59ba9bd1e..45006ff59a 100644 --- a/tests/unit/plugins/modules/test_proxmox_vm_info.py +++ b/tests/unit/plugins/modules/test_proxmox_vm_info.py @@ -20,7 +20,7 @@ mandatory_py_version = pytest.mark.skipif( from ansible_collections.community.general.plugins.modules import proxmox_vm_info from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ( +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ( AnsibleExitJson, AnsibleFailJson, ModuleTestCase, diff --git a/tests/unit/plugins/modules/test_redis_data.py b/tests/unit/plugins/modules/test_redis_data.py index 598c8bfd18..ef1af3d2e0 100644 --- a/tests/unit/plugins/modules/test_redis_data.py +++ b/tests/unit/plugins/modules/test_redis_data.py @@ -13,7 +13,7 @@ import json from redis import __version__ from ansible_collections.community.general.plugins.modules import redis_data -from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args HAS_REDIS_USERNAME_OPTION = True if tuple(map(int, __version__.split('.'))) < (3, 4, 0): diff --git a/tests/unit/plugins/modules/test_redis_data_incr.py b/tests/unit/plugins/modules/test_redis_data_incr.py index d5dc1ad733..9ae0631f03 100644 --- a/tests/unit/plugins/modules/test_redis_data_incr.py +++ b/tests/unit/plugins/modules/test_redis_data_incr.py @@ -14,7 +14,7 @@ import redis from redis import __version__ from ansible_collections.community.general.plugins.modules import redis_data_incr -from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args HAS_REDIS_USERNAME_OPTION = True diff --git a/tests/unit/plugins/modules/test_redis_data_info.py b/tests/unit/plugins/modules/test_redis_data_info.py index bd6bba4ca3..af09f09823 100644 --- a/tests/unit/plugins/modules/test_redis_data_info.py +++ b/tests/unit/plugins/modules/test_redis_data_info.py @@ -14,7 +14,7 @@ from redis import __version__ from ansible_collections.community.general.plugins.modules import ( redis_data_info) -from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args HAS_REDIS_USERNAME_OPTION = True diff --git a/tests/unit/plugins/modules/test_redis_info.py b/tests/unit/plugins/modules/test_redis_info.py index 6c50e094d2..b0f2b7b07f 100644 --- a/tests/unit/plugins/modules/test_redis_info.py +++ b/tests/unit/plugins/modules/test_redis_info.py @@ -9,7 +9,7 @@ __metaclass__ = type from ansible_collections.community.general.tests.unit.compat.mock import patch, MagicMock from ansible_collections.community.general.plugins.modules import redis_info -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args class FakeRedisClient(MagicMock): diff --git a/tests/unit/plugins/modules/test_rhsm_release.py b/tests/unit/plugins/modules/test_rhsm_release.py index a986cc054a..db2ccc90fb 100644 --- a/tests/unit/plugins/modules/test_rhsm_release.py +++ b/tests/unit/plugins/modules/test_rhsm_release.py @@ -7,7 +7,7 @@ __metaclass__ = type from ansible_collections.community.general.tests.unit.compat.mock import call, patch from ansible_collections.community.general.plugins.modules import rhsm_release -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ( +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ( AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args) diff --git a/tests/unit/plugins/modules/test_rpm_ostree_pkg.py b/tests/unit/plugins/modules/test_rpm_ostree_pkg.py index 1c09eb3a16..0490ff0194 100644 --- a/tests/unit/plugins/modules/test_rpm_ostree_pkg.py +++ b/tests/unit/plugins/modules/test_rpm_ostree_pkg.py @@ -8,7 +8,7 @@ __metaclass__ = type from ansible_collections.community.general.tests.unit.compat.mock import call, patch from ansible_collections.community.general.plugins.modules import rpm_ostree_pkg -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ( +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ( AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args) diff --git a/tests/unit/plugins/modules/test_scaleway_compute_private_network.py b/tests/unit/plugins/modules/test_scaleway_compute_private_network.py index 834688be9f..3d51218781 100644 --- a/tests/unit/plugins/modules/test_scaleway_compute_private_network.py +++ b/tests/unit/plugins/modules/test_scaleway_compute_private_network.py @@ -11,7 +11,7 @@ import pytest from ansible_collections.community.general.plugins.modules import scaleway_compute_private_network from ansible_collections.community.general.plugins.module_utils.scaleway import Scaleway, Response -from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args from ansible_collections.community.general.tests.unit.compat.mock import patch diff --git a/tests/unit/plugins/modules/test_scaleway_private_network.py b/tests/unit/plugins/modules/test_scaleway_private_network.py index 4c0e9ca30a..763ab31bcb 100644 --- a/tests/unit/plugins/modules/test_scaleway_private_network.py +++ b/tests/unit/plugins/modules/test_scaleway_private_network.py @@ -12,7 +12,7 @@ import pytest from ansible_collections.community.general.plugins.modules import scaleway_private_network from ansible_collections.community.general.plugins.module_utils.scaleway import Scaleway, Response -from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args from ansible_collections.community.general.tests.unit.compat.mock import patch diff --git a/tests/unit/plugins/modules/test_simpleinit_msb.py b/tests/unit/plugins/modules/test_simpleinit_msb.py index 69e56cd15c..f6f5c17504 100644 --- a/tests/unit/plugins/modules/test_simpleinit_msb.py +++ b/tests/unit/plugins/modules/test_simpleinit_msb.py @@ -7,7 +7,7 @@ __metaclass__ = type from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleFailJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules.simpleinit_msb import SimpleinitMSB, build_module diff --git a/tests/unit/plugins/modules/test_slack.py b/tests/unit/plugins/modules/test_slack.py index f8c6594262..a1f95fd037 100644 --- a/tests/unit/plugins/modules/test_slack.py +++ b/tests/unit/plugins/modules/test_slack.py @@ -9,7 +9,7 @@ import json import pytest from ansible_collections.community.general.tests.unit.compat.mock import Mock, patch from ansible_collections.community.general.plugins.modules import slack -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args class TestSlackModule(ModuleTestCase): diff --git a/tests/unit/plugins/modules/test_solaris_zone.py b/tests/unit/plugins/modules/test_solaris_zone.py index eea66b3060..a797d4c9c1 100644 --- a/tests/unit/plugins/modules/test_solaris_zone.py +++ b/tests/unit/plugins/modules/test_solaris_zone.py @@ -13,7 +13,7 @@ from ansible.module_utils.basic import AnsibleModule from ansible_collections.community.general.plugins.modules import ( solaris_zone ) -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ( +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ( set_module_args, ) diff --git a/tests/unit/plugins/modules/test_statsd.py b/tests/unit/plugins/modules/test_statsd.py index d0f1f3e115..bccae34f44 100644 --- a/tests/unit/plugins/modules/test_statsd.py +++ b/tests/unit/plugins/modules/test_statsd.py @@ -7,7 +7,7 @@ __metaclass__ = type from ansible_collections.community.general.plugins.modules import statsd from ansible_collections.community.general.tests.unit.compat.mock import patch, MagicMock -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args class FakeStatsD(MagicMock): diff --git a/tests/unit/plugins/modules/test_sysupgrade.py b/tests/unit/plugins/modules/test_sysupgrade.py index d711fe0ed0..c21186d607 100644 --- a/tests/unit/plugins/modules/test_sysupgrade.py +++ b/tests/unit/plugins/modules/test_sysupgrade.py @@ -7,7 +7,7 @@ __metaclass__ = type from ansible.module_utils import basic from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args, AnsibleExitJson, AnsibleFailJson, ModuleTestCase +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args, AnsibleExitJson, AnsibleFailJson, ModuleTestCase from ansible_collections.community.general.plugins.modules import sysupgrade diff --git a/tests/unit/plugins/modules/test_terraform.py b/tests/unit/plugins/modules/test_terraform.py index deae3ccfb9..09fd60dd9c 100644 --- a/tests/unit/plugins/modules/test_terraform.py +++ b/tests/unit/plugins/modules/test_terraform.py @@ -9,7 +9,7 @@ import json import pytest from ansible_collections.community.general.plugins.modules import terraform -from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args def test_terraform_without_argument(capfd): diff --git a/tests/unit/plugins/modules/test_ufw.py b/tests/unit/plugins/modules/test_ufw.py index 96eba0f286..eadc548bbd 100644 --- a/tests/unit/plugins/modules/test_ufw.py +++ b/tests/unit/plugins/modules/test_ufw.py @@ -8,7 +8,13 @@ from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible.module_utils import basic import ansible_collections.community.general.plugins.modules.ufw as module -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, set_module_args, exit_json, fail_json +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import ( + AnsibleExitJson, + AnsibleFailJson, + set_module_args, + exit_json, + fail_json, +) # mock ufw messages diff --git a/tests/unit/plugins/modules/test_usb_facts.py b/tests/unit/plugins/modules/test_usb_facts.py index 286a619067..e794dea81d 100644 --- a/tests/unit/plugins/modules/test_usb_facts.py +++ b/tests/unit/plugins/modules/test_usb_facts.py @@ -9,7 +9,7 @@ from ansible_collections.community.general.tests.unit.compat import mock from ansible_collections.community.general.tests.unit.compat import unittest from ansible.module_utils import basic from ansible_collections.community.general.plugins.modules import usb_facts -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, set_module_args, exit_json, fail_json +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, set_module_args, exit_json, fail_json def get_bin_path(self, arg, required=False): diff --git a/tests/unit/plugins/modules/test_wdc_redfish_command.py b/tests/unit/plugins/modules/test_wdc_redfish_command.py index 9e4d373f42..2349edf156 100644 --- a/tests/unit/plugins/modules/test_wdc_redfish_command.py +++ b/tests/unit/plugins/modules/test_wdc_redfish_command.py @@ -16,8 +16,8 @@ from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible_collections.community.general.tests.unit.compat import unittest from ansible.module_utils import basic import ansible_collections.community.general.plugins.modules.wdc_redfish_command as module -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson -from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args, exit_json, fail_json +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args, exit_json, fail_json MOCK_SUCCESSFUL_HTTP_EMPTY_RESPONSE = { "ret": True, diff --git a/tests/unit/plugins/modules/test_wdc_redfish_info.py b/tests/unit/plugins/modules/test_wdc_redfish_info.py index b8952f8427..d0b13953ca 100644 --- a/tests/unit/plugins/modules/test_wdc_redfish_info.py +++ b/tests/unit/plugins/modules/test_wdc_redfish_info.py @@ -10,8 +10,8 @@ from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible_collections.community.general.tests.unit.compat import unittest from ansible.module_utils import basic import ansible_collections.community.general.plugins.modules.wdc_redfish_info as module -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson -from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args, exit_json, fail_json +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args, exit_json, fail_json MOCK_SUCCESSFUL_RESPONSE_WITH_ACTIONS = { "ret": True, diff --git a/tests/unit/plugins/modules/test_xcc_redfish_command.py b/tests/unit/plugins/modules/test_xcc_redfish_command.py index eda93f3186..7f3dcf40f9 100644 --- a/tests/unit/plugins/modules/test_xcc_redfish_command.py +++ b/tests/unit/plugins/modules/test_xcc_redfish_command.py @@ -9,8 +9,8 @@ from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible_collections.community.general.tests.unit.compat import unittest from ansible.module_utils import basic import ansible_collections.community.general.plugins.modules.xcc_redfish_command as module -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson -from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args, exit_json, fail_json +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson +from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args, exit_json, fail_json def get_bin_path(self, arg, required=False): diff --git a/tests/unit/plugins/modules/uthelper.py b/tests/unit/plugins/modules/uthelper.py index ceb1d5f620..7aea76581b 100644 --- a/tests/unit/plugins/modules/uthelper.py +++ b/tests/unit/plugins/modules/uthelper.py @@ -69,7 +69,7 @@ class UTHelper(object): def set_test_func(self): @pytest.mark.parametrize('test_case', self.test_cases, ids=[tc.id for tc in self.test_cases]) @pytest.mark.usefixtures(*self.fixtures) - def _test_module(mocker, capfd, patch_ansible_module, test_case): + def _test_module(mocker, capfd, patch_ansible_module_uthelper, test_case): """ Run unit tests for each test case in self.test_cases """ @@ -79,8 +79,8 @@ class UTHelper(object): args["_ansible_check_mode"] = test_case.flags.get("check") if test_case.flags.get("diff"): args["_ansible_diff"] = test_case.flags.get("diff") - patch_ansible_module(args) - self.runner.run(mocker, capfd, test_case) + with patch_ansible_module_uthelper(args): + self.runner.run(mocker, capfd, test_case) self.add_func_to_test_module("test_module", _test_module) diff --git a/tests/unit/plugins/plugin_utils/test_unsafe.py b/tests/unit/plugins/plugin_utils/test_unsafe.py index 3f35ee9337..32d4d1f30f 100644 --- a/tests/unit/plugins/plugin_utils/test_unsafe.py +++ b/tests/unit/plugins/plugin_utils/test_unsafe.py @@ -11,7 +11,12 @@ __metaclass__ = type import pytest -from ansible.utils.unsafe_proxy import AnsibleUnsafe +from ansible_collections.community.internal_test_tools.tests.unit.utils.trust import ( + make_untrusted as _make_untrusted, + make_trusted as _make_trusted, + is_trusted as _is_trusted, + SUPPORTS_DATA_TAGGING, +) from ansible_collections.community.general.plugins.plugin_utils.unsafe import ( make_unsafe, @@ -20,28 +25,14 @@ from ansible_collections.community.general.plugins.plugin_utils.unsafe import ( TEST_MAKE_UNSAFE = [ ( - u'text', + _make_trusted(u'text'), [], [ (), ], ), ( - u'{{text}}', - [ - (), - ], - [], - ), - ( - b'text', - [], - [ - (), - ], - ), - ( - b'{{text}}', + _make_trusted(u'{{text}}'), [ (), ], @@ -49,14 +40,14 @@ TEST_MAKE_UNSAFE = [ ), ( { - 'skey': 'value', - 'ukey': '{{value}}', + _make_trusted('skey'): _make_trusted('value'), + _make_trusted('ukey'): _make_trusted('{{value}}'), 1: [ - 'value', - '{{value}}', + _make_trusted('value'), + _make_trusted('{{value}}'), { - 1.0: '{{value}}', - 2.0: 'value', + 1.0: _make_trusted('{{value}}'), + 2.0: _make_trusted('value'), }, ], }, @@ -72,7 +63,7 @@ TEST_MAKE_UNSAFE = [ ], ), ( - ['value', '{{value}}'], + [_make_trusted('value'), _make_trusted('{{value}}')], [ (1, ), ], @@ -82,6 +73,24 @@ TEST_MAKE_UNSAFE = [ ), ] +if not SUPPORTS_DATA_TAGGING: + TEST_MAKE_UNSAFE.extend([ + ( + _make_trusted(b"text"), + [], + [ + (), + ], + ), + ( + _make_trusted(b"{{text}}"), + [ + (), + ], + [], + ), + ]) + @pytest.mark.parametrize("value, check_unsafe_paths, check_safe_paths", TEST_MAKE_UNSAFE) def test_make_unsafe(value, check_unsafe_paths, check_safe_paths): @@ -91,43 +100,59 @@ def test_make_unsafe(value, check_unsafe_paths, check_safe_paths): obj = unsafe_value for elt in check_path: obj = obj[elt] - assert isinstance(obj, AnsibleUnsafe) + assert not _is_trusted(obj) for check_path in check_safe_paths: obj = unsafe_value for elt in check_path: obj = obj[elt] - assert not isinstance(obj, AnsibleUnsafe) + assert _is_trusted(obj) + + +def test_make_unsafe_idempotence(): + assert make_unsafe(None) is None + + unsafe_str = _make_untrusted('{{test}}') + assert id(make_unsafe(unsafe_str)) == id(unsafe_str) + + safe_str = _make_trusted('{{test}}') + assert id(make_unsafe(safe_str)) != id(safe_str) def test_make_unsafe_dict_key(): value = { - b'test': 1, - u'test': 2, + _make_trusted(u'test'): 2, } + if not SUPPORTS_DATA_TAGGING: + value[_make_trusted(b"test")] = 1 unsafe_value = make_unsafe(value) assert unsafe_value == value for obj in unsafe_value: - assert not isinstance(obj, AnsibleUnsafe) + assert _is_trusted(obj) value = { - b'{{test}}': 1, - u'{{test}}': 2, + _make_trusted(u'{{test}}'): 2, } + if not SUPPORTS_DATA_TAGGING: + value[_make_trusted(b"{{test}}")] = 1 unsafe_value = make_unsafe(value) assert unsafe_value == value for obj in unsafe_value: - assert isinstance(obj, AnsibleUnsafe) + assert not _is_trusted(obj) def test_make_unsafe_set(): - value = set([b'test', u'test']) + value = set([_make_trusted(u'test')]) + if not SUPPORTS_DATA_TAGGING: + value.add(_make_trusted(b"test")) unsafe_value = make_unsafe(value) assert unsafe_value == value for obj in unsafe_value: - assert not isinstance(obj, AnsibleUnsafe) + assert _is_trusted(obj) - value = set([b'{{test}}', u'{{test}}']) + value = set([_make_trusted(u'{{test}}')]) + if not SUPPORTS_DATA_TAGGING: + value.add(_make_trusted(b"{{test}}")) unsafe_value = make_unsafe(value) assert unsafe_value == value for obj in unsafe_value: - assert isinstance(obj, AnsibleUnsafe) + assert not _is_trusted(obj) diff --git a/tests/utils/shippable/shippable.sh b/tests/utils/shippable/shippable.sh index e288cca1cf..6c46c14b34 100755 --- a/tests/utils/shippable/shippable.sh +++ b/tests/utils/shippable/shippable.sh @@ -72,24 +72,23 @@ if [ "${test}" == "sanity/extra" ]; then fi # START: HACK install dependencies -if [ "${script}" != "sanity" ] || [ "${test}" == "sanity/extra" ]; then - # Nothing further should be added to this list. - # This is to prevent modules or plugins in this collection having a runtime dependency on other collections. - retry git clone --depth=1 --single-branch https://github.com/ansible-collections/community.internal_test_tools.git "${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/community/internal_test_tools" - retry git clone --depth=1 --single-branch https://github.com/ansible-collections/community.docker.git "${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/community/docker" - # NOTE: we're installing with git to work around Galaxy being a huge PITA (https://github.com/ansible/galaxy/issues/2429) - # retry ansible-galaxy -vvv collection install community.internal_test_tools -fi + +# Nothing further should be added to this list. +# This is to prevent modules or plugins in this collection having a runtime dependency on other collections. +retry git clone --depth=1 --single-branch https://github.com/ansible-collections/community.internal_test_tools.git "${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/community/internal_test_tools" +# NOTE: we're installing with git to work around Galaxy being a huge PITA (https://github.com/ansible/galaxy/issues/2429) +# retry ansible-galaxy -vvv collection install community.internal_test_tools if [ "${script}" != "sanity" ] && [ "${script}" != "units" ] && [ "${test}" != "sanity/extra" ]; then # To prevent Python dependencies on other collections only install other collections for integration tests retry git clone --depth=1 --single-branch https://github.com/ansible-collections/ansible.posix.git "${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/ansible/posix" retry git clone --depth=1 --single-branch https://github.com/ansible-collections/community.crypto.git "${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/community/crypto" + retry git clone --depth=1 --single-branch https://github.com/ansible-collections/community.docker.git "${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/community/docker" # NOTE: we're installing with git to work around Galaxy being a huge PITA (https://github.com/ansible/galaxy/issues/2429) # retry ansible-galaxy -vvv collection install ansible.posix # retry ansible-galaxy -vvv collection install community.crypto + # retry ansible-galaxy -vvv collection install community.docker fi - # END: HACK export PYTHONIOENCODING='utf-8'