mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-02-04 07:51:50 +00:00
CI: add type checking (#10997)
* Set up type checking with mypy. * Make mypy pass. * Use list() instead of sorted().
This commit is contained in:
parent
831787619a
commit
6088b0cff5
73 changed files with 442 additions and 175 deletions
2
tests/unit/plugins/cache/test_redis.py
vendored
2
tests/unit/plugins/cache/test_redis.py
vendored
|
|
@ -19,7 +19,7 @@ def test_redis_cachemodule():
|
|||
assert isinstance(cache_loader.get('community.general.redis', **{'_uri': connection}), RedisCache)
|
||||
|
||||
|
||||
def test_redis_cachemodule():
|
||||
def test_redis_cachemodule_2():
|
||||
# The _uri option is required for the redis plugin
|
||||
connection = '[::1]:6379:1'
|
||||
assert isinstance(cache_loader.get('community.general.redis', **{'_uri': connection}), RedisCache)
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class SecretVariablesTestCase(unittest.TestCase):
|
|||
|
||||
self.assertEqual(SecretVariables.list_to_dict(source, hashed=True), expect)
|
||||
|
||||
def test_list_to_dict(self):
|
||||
def test_list_to_dict_2(self):
|
||||
source = [
|
||||
dict(key="secret1", value="value1"),
|
||||
dict(key="secret2", value="value2")
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
import typing as t
|
||||
|
||||
import pytest
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils import csv
|
||||
|
|
@ -112,7 +114,7 @@ INVALID_CSV = [
|
|||
),
|
||||
]
|
||||
|
||||
INVALID_DIALECT = [
|
||||
INVALID_DIALECT: list[tuple[str, t.Any, t.Any, str]] = [
|
||||
(
|
||||
'invalid',
|
||||
{},
|
||||
|
|
@ -153,7 +155,7 @@ def test_invalid_csv(data, dialect, dialect_params, fieldnames):
|
|||
|
||||
|
||||
@pytest.mark.parametrize("dialect,dialect_params,fieldnames,data", INVALID_DIALECT)
|
||||
def test_invalid_dialect(data, dialect, dialect_params, fieldnames):
|
||||
def test_invalid_dialect(data: str, dialect: t.Any, dialect_params: t.Any, fieldnames: str) -> None:
|
||||
result = False
|
||||
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ testcase_gather_vm_params_and_facts = {
|
|||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('vm_ref', testcase_bad_xenapi_refs['params'], ids=testcase_bad_xenapi_refs['ids'])
|
||||
@pytest.mark.parametrize('vm_ref', testcase_bad_xenapi_refs['params'], ids=testcase_bad_xenapi_refs['ids']) # type: ignore
|
||||
def test_gather_vm_params_bad_vm_ref(fake_ansible_module, xenserver, vm_ref):
|
||||
"""Tests return of empty dict on bad vm_ref."""
|
||||
assert xenserver.gather_vm_params(fake_ansible_module, vm_ref) == {}
|
||||
|
|
@ -38,8 +38,8 @@ def test_gather_vm_facts_no_vm_params(fake_ansible_module, xenserver):
|
|||
|
||||
|
||||
@pytest.mark.parametrize('fixture_data_from_file',
|
||||
testcase_gather_vm_params_and_facts['params'],
|
||||
ids=testcase_gather_vm_params_and_facts['ids'],
|
||||
testcase_gather_vm_params_and_facts['params'], # type: ignore
|
||||
ids=testcase_gather_vm_params_and_facts['ids'], # type: ignore
|
||||
indirect=True)
|
||||
def test_gather_vm_params_and_facts(mocker, fake_ansible_module, XenAPI, xenserver, fixture_data_from_file):
|
||||
"""Tests proper parsing of VM parameters and facts."""
|
||||
|
|
|
|||
|
|
@ -157,13 +157,13 @@ def test_is_valid_ip_prefix(xenserver, ip_prefix, result):
|
|||
assert xenserver.is_valid_ip_prefix(ip_prefix) is result
|
||||
|
||||
|
||||
@pytest.mark.parametrize('ip_prefix, ip_netmask', testcase_ip_prefix_to_netmask['params'], ids=testcase_ip_prefix_to_netmask['ids'])
|
||||
@pytest.mark.parametrize('ip_prefix, ip_netmask', testcase_ip_prefix_to_netmask['params'], ids=testcase_ip_prefix_to_netmask['ids']) # type: ignore
|
||||
def test_ip_prefix_to_netmask(xenserver, ip_prefix, ip_netmask):
|
||||
"""Tests ip prefix to netmask conversion."""
|
||||
assert xenserver.ip_prefix_to_netmask(ip_prefix) == ip_netmask
|
||||
|
||||
|
||||
@pytest.mark.parametrize('ip_netmask, ip_prefix', testcase_ip_netmask_to_prefix['params'], ids=testcase_ip_netmask_to_prefix['ids'])
|
||||
@pytest.mark.parametrize('ip_netmask, ip_prefix', testcase_ip_netmask_to_prefix['params'], ids=testcase_ip_netmask_to_prefix['ids']) # type: ignore
|
||||
def test_ip_netmask_to_prefix(xenserver, ip_netmask, ip_prefix):
|
||||
"""Tests ip netmask to prefix conversion."""
|
||||
assert xenserver.ip_netmask_to_prefix(ip_netmask) == ip_prefix
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ testcase_set_vm_power_state_transitions_async = {
|
|||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('vm_ref', testcase_bad_xenapi_refs['params'], ids=testcase_bad_xenapi_refs['ids'])
|
||||
@pytest.mark.parametrize('vm_ref', testcase_bad_xenapi_refs['params'], ids=testcase_bad_xenapi_refs['ids']) # type: ignore
|
||||
def test_set_vm_power_state_bad_vm_ref(fake_ansible_module, xenserver, vm_ref):
|
||||
"""Tests failure on bad vm_ref."""
|
||||
with pytest.raises(FailJsonException) as exc_info:
|
||||
|
|
@ -222,8 +222,8 @@ def test_set_vm_power_state_bad_power_state(mocker, fake_ansible_module, XenAPI,
|
|||
|
||||
|
||||
@pytest.mark.parametrize('power_state_desired, power_state_current, error_msg',
|
||||
testcase_set_vm_power_state_bad_transitions['params'],
|
||||
ids=testcase_set_vm_power_state_bad_transitions['ids'])
|
||||
testcase_set_vm_power_state_bad_transitions['params'], # type: ignore
|
||||
ids=testcase_set_vm_power_state_bad_transitions['ids']) # type: ignore
|
||||
def test_set_vm_power_state_bad_transition(mocker, fake_ansible_module, XenAPI, xenserver, power_state_desired, power_state_current, error_msg):
|
||||
"""Tests failure on bad power state transition."""
|
||||
mocked_xenapi = mocker.patch.object(XenAPI.Session, 'xenapi', create=True)
|
||||
|
|
@ -245,8 +245,8 @@ def test_set_vm_power_state_bad_transition(mocker, fake_ansible_module, XenAPI,
|
|||
|
||||
|
||||
@pytest.mark.parametrize('power_state, error_msg',
|
||||
testcase_set_vm_power_state_task_timeout['params'],
|
||||
ids=testcase_set_vm_power_state_task_timeout['ids'])
|
||||
testcase_set_vm_power_state_task_timeout['params'], # type: ignore
|
||||
ids=testcase_set_vm_power_state_task_timeout['ids']) # type: ignore
|
||||
def test_set_vm_power_state_task_timeout(mocker, fake_ansible_module, XenAPI, xenserver, power_state, error_msg):
|
||||
"""Tests failure on async task timeout."""
|
||||
mocked_xenapi = mocker.patch.object(XenAPI.Session, 'xenapi', create=True)
|
||||
|
|
@ -272,8 +272,8 @@ def test_set_vm_power_state_task_timeout(mocker, fake_ansible_module, XenAPI, xe
|
|||
|
||||
|
||||
@pytest.mark.parametrize('power_state_desired, power_state_current',
|
||||
testcase_set_vm_power_state_no_transitions['params'],
|
||||
ids=testcase_set_vm_power_state_no_transitions['ids'])
|
||||
testcase_set_vm_power_state_no_transitions['params'], # type: ignore
|
||||
ids=testcase_set_vm_power_state_no_transitions['ids']) # type: ignore
|
||||
def test_set_vm_power_state_no_transition(mocker, fake_ansible_module, XenAPI, xenserver, power_state_desired, power_state_current):
|
||||
"""Tests regular invocation without power state transition."""
|
||||
mocked_xenapi = mocker.patch.object(XenAPI.Session, 'xenapi', create=True)
|
||||
|
|
@ -295,8 +295,8 @@ def test_set_vm_power_state_no_transition(mocker, fake_ansible_module, XenAPI, x
|
|||
|
||||
|
||||
@pytest.mark.parametrize('power_state_desired, power_state_current, power_state_resulting, activated_xenapi_method',
|
||||
testcase_set_vm_power_state_transitions['params'],
|
||||
ids=testcase_set_vm_power_state_transitions['ids'])
|
||||
testcase_set_vm_power_state_transitions['params'], # type: ignore
|
||||
ids=testcase_set_vm_power_state_transitions['ids']) # type: ignore
|
||||
def test_set_vm_power_state_transition(mocker,
|
||||
fake_ansible_module,
|
||||
XenAPI,
|
||||
|
|
@ -332,8 +332,8 @@ def test_set_vm_power_state_transition(mocker,
|
|||
|
||||
|
||||
@pytest.mark.parametrize('power_state_desired, power_state_current, power_state_resulting, activated_xenapi_method',
|
||||
testcase_set_vm_power_state_transitions_async['params'],
|
||||
ids=testcase_set_vm_power_state_transitions_async['ids'])
|
||||
testcase_set_vm_power_state_transitions_async['params'], # type: ignore
|
||||
ids=testcase_set_vm_power_state_transitions_async['ids']) # type: ignore
|
||||
def test_set_vm_power_state_transition_async(mocker,
|
||||
fake_ansible_module,
|
||||
XenAPI,
|
||||
|
|
@ -375,8 +375,8 @@ def test_set_vm_power_state_transition_async(mocker,
|
|||
|
||||
|
||||
@pytest.mark.parametrize('power_state_desired, power_state_current, power_state_resulting, activated_xenapi_method',
|
||||
testcase_set_vm_power_state_transitions['params'],
|
||||
ids=testcase_set_vm_power_state_transitions['ids'])
|
||||
testcase_set_vm_power_state_transitions['params'], # type: ignore
|
||||
ids=testcase_set_vm_power_state_transitions['ids']) # type: ignore
|
||||
def test_set_vm_power_state_transition_check_mode(mocker,
|
||||
fake_ansible_module,
|
||||
XenAPI,
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ testcase_wait_for_task_all_statuses = {
|
|||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('vm_ref', testcase_bad_xenapi_refs['params'], ids=testcase_bad_xenapi_refs['ids'])
|
||||
@pytest.mark.parametrize('vm_ref', testcase_bad_xenapi_refs['params'], ids=testcase_bad_xenapi_refs['ids']) # type: ignore
|
||||
def test_wait_for_vm_ip_address_bad_vm_ref(fake_ansible_module, xenserver, vm_ref):
|
||||
"""Tests failure on bad vm_ref."""
|
||||
with pytest.raises(FailJsonException) as exc_info:
|
||||
|
|
@ -94,8 +94,8 @@ def test_wait_for_vm_ip_address_bad_power_state(mocker, fake_ansible_module, Xen
|
|||
|
||||
|
||||
@pytest.mark.parametrize('bad_guest_metrics_ref, bad_guest_metrics',
|
||||
testcase_wait_for_vm_ip_address_bad_guest_metrics['params'],
|
||||
ids=testcase_wait_for_vm_ip_address_bad_guest_metrics['ids'])
|
||||
testcase_wait_for_vm_ip_address_bad_guest_metrics['params'], # type: ignore
|
||||
ids=testcase_wait_for_vm_ip_address_bad_guest_metrics['ids']) # type: ignore
|
||||
def test_wait_for_vm_ip_address_timeout(mocker, fake_ansible_module, XenAPI, xenserver, bad_guest_metrics_ref, bad_guest_metrics):
|
||||
"""Tests timeout."""
|
||||
mocked_xenapi = mocker.patch.object(XenAPI.Session, 'xenapi', create=True)
|
||||
|
|
@ -156,7 +156,7 @@ def test_wait_for_vm_ip_address(mocker, fake_ansible_module, XenAPI, xenserver):
|
|||
assert fake_guest_metrics == mocked_returns['VM_guest_metrics.get_record.side_effect'][1]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('task_ref', testcase_bad_xenapi_refs['params'], ids=testcase_bad_xenapi_refs['ids'])
|
||||
@pytest.mark.parametrize('task_ref', testcase_bad_xenapi_refs['params'], ids=testcase_bad_xenapi_refs['ids']) # type: ignore
|
||||
def test_wait_for_task_bad_task_ref(fake_ansible_module, xenserver, task_ref):
|
||||
"""Tests failure on bad task_ref."""
|
||||
with pytest.raises(FailJsonException) as exc_info:
|
||||
|
|
@ -193,8 +193,8 @@ def test_wait_for_task_timeout(mocker, fake_ansible_module, XenAPI, xenserver):
|
|||
|
||||
|
||||
@pytest.mark.parametrize('task_status, result',
|
||||
testcase_wait_for_task_all_statuses['params'],
|
||||
ids=testcase_wait_for_task_all_statuses['ids'])
|
||||
testcase_wait_for_task_all_statuses['params'], # type: ignore
|
||||
ids=testcase_wait_for_task_all_statuses['ids']) # type: ignore
|
||||
def test_wait_for_task(mocker, fake_ansible_module, XenAPI, xenserver, task_status, result):
|
||||
"""Tests regular invocation."""
|
||||
mocked_xenapi = mocker.patch.object(XenAPI.Session, 'xenapi', create=True)
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ testcase_module_remote_conn_scheme = {
|
|||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('fake_ansible_module', testcase_module_local_conn['params'], ids=testcase_module_local_conn['ids'], indirect=True)
|
||||
@pytest.mark.parametrize('fake_ansible_module', testcase_module_local_conn['params'], ids=testcase_module_local_conn['ids'], indirect=True) # type: ignore
|
||||
def test_xapi_connect_local_session(mocker, fake_ansible_module, XenAPI, xenserver):
|
||||
"""Tests that connection to localhost uses XenAPI.xapi_local() function."""
|
||||
mocker.patch('XenAPI.xapi_local')
|
||||
|
|
@ -73,7 +73,7 @@ def test_xapi_connect_local_session(mocker, fake_ansible_module, XenAPI, xenserv
|
|||
XenAPI.xapi_local.assert_called_once()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('fake_ansible_module', testcase_module_local_conn['params'], ids=testcase_module_local_conn['ids'], indirect=True)
|
||||
@pytest.mark.parametrize('fake_ansible_module', testcase_module_local_conn['params'], ids=testcase_module_local_conn['ids'], indirect=True) # type: ignore
|
||||
def test_xapi_connect_local_login(mocker, fake_ansible_module, XenAPI, xenserver):
|
||||
"""Tests that connection to localhost uses empty username and password."""
|
||||
mocker.patch.object(XenAPI.Session, 'login_with_password', create=True)
|
||||
|
|
@ -114,7 +114,12 @@ def test_xapi_connect_login_failure(mocker, fake_ansible_module, XenAPI, xenserv
|
|||
assert exc_info.value.kwargs['msg'] == f"Unable to log on to XenServer at http://{hostname} as {username}: {fake_error_msg}"
|
||||
|
||||
|
||||
@pytest.mark.parametrize('fake_ansible_module', testcase_module_remote_conn_scheme['params'], ids=testcase_module_remote_conn_scheme['ids'], indirect=True)
|
||||
@pytest.mark.parametrize(
|
||||
'fake_ansible_module',
|
||||
testcase_module_remote_conn_scheme['params'], # type: ignore
|
||||
ids=testcase_module_remote_conn_scheme['ids'], # type: ignore
|
||||
indirect=True,
|
||||
)
|
||||
def test_xapi_connect_remote_scheme(mocker, fake_ansible_module, XenAPI, xenserver):
|
||||
"""Tests that explicit scheme in hostname param is preserved."""
|
||||
mocker.patch('XenAPI.Session')
|
||||
|
|
@ -127,7 +132,7 @@ def test_xapi_connect_remote_scheme(mocker, fake_ansible_module, XenAPI, xenserv
|
|||
XenAPI.Session.assert_called_once_with(hostname, ignore_ssl=ignore_ssl)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('fake_ansible_module', testcase_module_remote_conn['params'], ids=testcase_module_remote_conn['ids'], indirect=True)
|
||||
@pytest.mark.parametrize('fake_ansible_module', testcase_module_remote_conn['params'], ids=testcase_module_remote_conn['ids'], indirect=True) # type: ignore
|
||||
def test_xapi_connect_remote_no_scheme(mocker, fake_ansible_module, XenAPI, xenserver):
|
||||
"""Tests that proper scheme is prepended to hostname without scheme."""
|
||||
mocker.patch('XenAPI.Session')
|
||||
|
|
|
|||
|
|
@ -373,7 +373,7 @@ class TestInterfacesFileModule(unittest.TestCase):
|
|||
iface_options = interfaces_file.get_interface_options(testcases[testname]["iface_lines"])
|
||||
self.assertEqual(testcases[testname]["iface_options"], iface_options)
|
||||
|
||||
def test_get_interface_options(self):
|
||||
def test_get_interface_options_2(self):
|
||||
testcases = {
|
||||
"select address": {
|
||||
"iface_options": [
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class TestArchive(ModuleTestCase):
|
|||
)
|
||||
|
||||
|
||||
PATHS = (
|
||||
PATHS: tuple[tuple[list[str | bytes], str | bytes], ...] = (
|
||||
([], ''),
|
||||
(['/'], '/'),
|
||||
([b'/'], b'/'),
|
||||
|
|
@ -68,5 +68,5 @@ PATHS = (
|
|||
|
||||
|
||||
@pytest.mark.parametrize("paths,root", PATHS)
|
||||
def test_common_path(paths, root):
|
||||
def test_common_path(paths: list[str | bytes], root: str | bytes) -> None:
|
||||
assert common_path(paths) == root
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ try:
|
|||
except ImportError:
|
||||
pytestmark.append(pytest.mark.skip("Could not load gitlab module required for testing"))
|
||||
# Need to set these to something so that we don't fail when parsing
|
||||
GitlabModuleTestCase = object
|
||||
GitlabModuleTestCase = object # type: ignore
|
||||
resp_get_project = _dummy
|
||||
resp_find_project_deploy_key = _dummy
|
||||
resp_create_project_deploy_key = _dummy
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ try:
|
|||
except ImportError:
|
||||
pytestmark.append(pytest.mark.skip("Could not load gitlab module required for testing"))
|
||||
# Need to set these to something so that we don't fail when parsing
|
||||
GitlabModuleTestCase = object
|
||||
GitlabModuleTestCase = object # type: ignore
|
||||
resp_get_group = _dummy
|
||||
resp_get_missing_group = _dummy
|
||||
resp_create_group = _dummy
|
||||
|
|
@ -58,7 +58,7 @@ class TestGitlabGroup(GitlabModuleTestCase):
|
|||
self.assertEqual(rvalue, True)
|
||||
|
||||
@with_httmock(resp_get_missing_group)
|
||||
def test_exist_group(self):
|
||||
def test_exist_group_2(self):
|
||||
rvalue = self.moduleUtil.exists_group(1)
|
||||
|
||||
self.assertEqual(rvalue, False)
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ try:
|
|||
except ImportError:
|
||||
pytestmark.append(pytest.mark.skip("Could not load gitlab module required for testing"))
|
||||
# Need to set these to something so that we don't fail when parsing
|
||||
GitlabModuleTestCase = object
|
||||
GitlabModuleTestCase = object # type: ignore
|
||||
resp_list_group_access_tokens = _dummy
|
||||
resp_create_group_access_tokens = _dummy
|
||||
resp_revoke_group_access_tokens = _dummy
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ try:
|
|||
except ImportError:
|
||||
pytestmark.append(pytest.mark.skip("Could not load gitlab module required for testing"))
|
||||
# Need to set these to something so that we don't fail when parsing
|
||||
GitlabModuleTestCase = object
|
||||
GitlabModuleTestCase = object # type: ignore
|
||||
resp_get_project = _dummy
|
||||
resp_find_project_hook = _dummy
|
||||
resp_create_project_hook = _dummy
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ try:
|
|||
except ImportError:
|
||||
pytestmark.append(pytest.mark.skip("Could not load gitlab module required for testing"))
|
||||
# Need to set these to something so that we don't fail when parsing
|
||||
GitlabModuleTestCase = object
|
||||
GitlabModuleTestCase = object # type: ignore
|
||||
resp_get_group = _dummy
|
||||
resp_get_project_by_name = _dummy
|
||||
resp_create_project = _dummy
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ try:
|
|||
except ImportError:
|
||||
pytestmark.append(pytest.mark.skip("Could not load gitlab module required for testing"))
|
||||
# Need to set these to something so that we don't fail when parsing
|
||||
GitlabModuleTestCase = object
|
||||
GitlabModuleTestCase = object # type: ignore
|
||||
resp_list_project_access_tokens = _dummy
|
||||
resp_create_project_access_tokens = _dummy
|
||||
resp_revoke_project_access_tokens = _dummy
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ try:
|
|||
except ImportError:
|
||||
pytestmark.append(pytest.mark.skip("Could not load gitlab module required for testing"))
|
||||
# Need to set these to something so that we don't fail when parsing
|
||||
GitlabModuleTestCase = object
|
||||
GitlabModuleTestCase = object # type: ignore
|
||||
resp_find_runners_list = _dummy
|
||||
resp_get_runner = _dummy
|
||||
resp_create_runner = _dummy
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ try:
|
|||
except ImportError:
|
||||
pytestmark.append(pytest.mark.skip("Could not load gitlab module required for testing"))
|
||||
# Need to set these to something so that we don't fail when parsing
|
||||
GitlabModuleTestCase = object
|
||||
GitlabModuleTestCase = object # type: ignore
|
||||
resp_find_user = _dummy
|
||||
resp_get_user = _dummy
|
||||
resp_get_user_keys = _dummy
|
||||
|
|
|
|||
|
|
@ -1640,11 +1640,12 @@ def mocked_generic_connection_modify(mocker):
|
|||
changed_return=(True, dict()))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mocked_generic_connection_unchanged(mocker):
|
||||
mocker_set(mocker,
|
||||
connection_exists=True,
|
||||
execute_return=(0, TESTCASE_GENERIC_SHOW_OUTPUT, ""))
|
||||
# TODO: overridden below!
|
||||
# @pytest.fixture
|
||||
# def mocked_generic_connection_unchanged(mocker):
|
||||
# mocker_set(mocker,
|
||||
# connection_exists=True,
|
||||
# execute_return=(0, TESTCASE_GENERIC_SHOW_OUTPUT, ""))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
@ -2104,6 +2105,7 @@ def test_bond_connection_create(mocked_generic_connection_create, capfd):
|
|||
assert results['changed']
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="Currently broken") # TODO: fix me!
|
||||
@pytest.mark.parametrize('patch_ansible_module', TESTCASE_BOND, indirect=['patch_ansible_module'])
|
||||
def test_bond_connection_unchanged(mocked_bond_connection_unchanged, capfd):
|
||||
"""
|
||||
|
|
@ -3450,7 +3452,7 @@ def test_ethernet_connection_static_ipv6_address_static_route_with_metric_create
|
|||
|
||||
|
||||
@pytest.mark.parametrize('patch_ansible_module', TESTCASE_ETHERNET_ADD_IPV6_INT_WITH_MULTIPLE_ROUTES_AND_METRIC, indirect=['patch_ansible_module'])
|
||||
def test_ethernet_connection_static_ipv6_address_static_route_create(mocked_ethernet_connection_with_ipv6_static_address_static_route_create, capfd):
|
||||
def test_ethernet_connection_static_ipv6_address_static_route_create_2(mocked_ethernet_connection_with_ipv6_static_address_static_route_create, capfd):
|
||||
"""
|
||||
Test : Create ethernet connection with static IPv6 address and multiple static routes with metric
|
||||
"""
|
||||
|
|
@ -4097,7 +4099,7 @@ def test_create_ethernet_addr_gen_mode_and_ip6_privacy_static(mocked_generic_con
|
|||
|
||||
|
||||
@pytest.mark.parametrize('patch_ansible_module', TESTCASE_ETHERNET_STATIC_IP6_PRIVACY_AND_ADDR_GEN_MODE, indirect=['patch_ansible_module'])
|
||||
def test_ethernet_connection_static_with_multiple_ip4_addresses_unchanged(mocked_ethernet_connection_static_ip6_privacy_and_addr_gen_mode_unchange, capfd):
|
||||
def test_ethernet_connection_static_with_multiple_ip4_addresses_unchanged_2(mocked_ethernet_connection_static_ip6_privacy_and_addr_gen_mode_unchange, capfd):
|
||||
"""
|
||||
Test : Ethernet connection with static IP configuration unchanged
|
||||
"""
|
||||
|
|
@ -4340,7 +4342,7 @@ def test_infiniband_connection_static_transport_mode_connected(
|
|||
|
||||
|
||||
@pytest.mark.parametrize('patch_ansible_module', TESTCASE_GENERIC_DIFF_CHECK, indirect=['patch_ansible_module'])
|
||||
def test_bond_connection_unchanged(mocked_generic_connection_diff_check, capfd):
|
||||
def test_bond_connection_unchanged_2(mocked_generic_connection_diff_check, capfd):
|
||||
"""
|
||||
Test : Bond connection unchanged
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
import typing as t
|
||||
from unittest import mock
|
||||
from ansible.module_utils import basic
|
||||
from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import (
|
||||
|
|
@ -110,7 +111,7 @@ valid_inventory = {
|
|||
},
|
||||
}
|
||||
|
||||
empty_inventory = {
|
||||
empty_inventory: dict[str, dict[str, t.Any]] = {
|
||||
"installed_pkgs": {},
|
||||
"available_pkgs": {},
|
||||
"installed_groups": {},
|
||||
|
|
|
|||
|
|
@ -682,7 +682,7 @@ def patch_get_bin_path(mocker):
|
|||
@pytest.mark.parametrize(
|
||||
'patch_ansible_module, expected',
|
||||
TESTCASES,
|
||||
ids=[item[1]['id'] for item in TESTCASES],
|
||||
ids=[item[1]['id'] for item in TESTCASES], # type: ignore
|
||||
indirect=['patch_ansible_module']
|
||||
)
|
||||
@pytest.mark.usefixtures('patch_ansible_module')
|
||||
|
|
|
|||
|
|
@ -856,7 +856,7 @@ Entitlement Type: Physical
|
|||
]
|
||||
|
||||
|
||||
TEST_CASES_IDS = [item[1]['id'] for item in TEST_CASES]
|
||||
TEST_CASES_IDS: list[str] = [item[1]['id'] for item in TEST_CASES] # type: ignore
|
||||
|
||||
|
||||
@pytest.mark.parametrize('patch_ansible_module, testcase', TEST_CASES, ids=TEST_CASES_IDS, indirect=['patch_ansible_module'])
|
||||
|
|
@ -1212,7 +1212,7 @@ System Purpose Status: Matched
|
|||
]
|
||||
|
||||
|
||||
SYSPURPOSE_TEST_CASES_IDS = [item[1]['id'] for item in SYSPURPOSE_TEST_CASES]
|
||||
SYSPURPOSE_TEST_CASES_IDS: list[str] = [item[1]['id'] for item in SYSPURPOSE_TEST_CASES] # type: ignore
|
||||
|
||||
|
||||
@pytest.mark.parametrize('patch_ansible_module, testcase', SYSPURPOSE_TEST_CASES, ids=SYSPURPOSE_TEST_CASES_IDS, indirect=['patch_ansible_module'])
|
||||
|
|
|
|||
|
|
@ -759,7 +759,7 @@ TEST_CASES = [
|
|||
]
|
||||
|
||||
|
||||
TEST_CASES_IDS = [item[1]['id'] for item in TEST_CASES]
|
||||
TEST_CASES_IDS: list[str] = [item[1]['id'] for item in TEST_CASES] # type: ignore
|
||||
|
||||
|
||||
@pytest.mark.parametrize('patch_ansible_module, testcase', TEST_CASES, ids=TEST_CASES_IDS, indirect=['patch_ansible_module'])
|
||||
|
|
|
|||
|
|
@ -436,7 +436,7 @@ class TestXCCRedfishCommand(unittest.TestCase):
|
|||
with self.assertRaises(AnsibleFailJson) as result:
|
||||
module.main()
|
||||
|
||||
def test_module_command_PostResource_fail_when_no_requestbody(self):
|
||||
def test_module_command_PostResource_fail_when_no_requestbody_2(self):
|
||||
with set_module_args({
|
||||
'category': 'Raw',
|
||||
'command': 'PostResource',
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ testcase_module_params = {
|
|||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('patch_ansible_module', testcase_module_params['params'], ids=testcase_module_params['ids'], indirect=True)
|
||||
@pytest.mark.parametrize('patch_ansible_module', testcase_module_params['params'], ids=testcase_module_params['ids'], indirect=True) # type: ignore
|
||||
def test_xenserver_guest_info(mocker, capfd, XenAPI, xenserver_guest_info):
|
||||
"""
|
||||
Tests regular module invocation including parsing and propagation of
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ testcase_module_params_wait = {
|
|||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('power_state', testcase_set_powerstate['params'], ids=testcase_set_powerstate['ids'])
|
||||
@pytest.mark.parametrize('power_state', testcase_set_powerstate['params'], ids=testcase_set_powerstate['ids']) # type: ignore
|
||||
def test_xenserver_guest_powerstate_set_power_state(mocker, fake_ansible_module, XenAPI, xenserver_guest_powerstate, power_state):
|
||||
"""Tests power state change handling."""
|
||||
mocker.patch('ansible_collections.community.general.plugins.modules.xenserver_guest_powerstate.get_object_ref',
|
||||
|
|
@ -163,8 +163,8 @@ def test_xenserver_guest_powerstate_set_power_state(mocker, fake_ansible_module,
|
|||
|
||||
|
||||
@pytest.mark.parametrize('patch_ansible_module',
|
||||
testcase_module_params_state_present['params'],
|
||||
ids=testcase_module_params_state_present['ids'],
|
||||
testcase_module_params_state_present['params'], # type: ignore
|
||||
ids=testcase_module_params_state_present['ids'], # type: ignore
|
||||
indirect=True)
|
||||
def test_xenserver_guest_powerstate_present(mocker, patch_ansible_module, capfd, XenAPI, xenserver_guest_powerstate):
|
||||
"""
|
||||
|
|
@ -209,8 +209,8 @@ def test_xenserver_guest_powerstate_present(mocker, patch_ansible_module, capfd,
|
|||
|
||||
|
||||
@pytest.mark.parametrize('patch_ansible_module',
|
||||
testcase_module_params_state_other['params'],
|
||||
ids=testcase_module_params_state_other['ids'],
|
||||
testcase_module_params_state_other['params'], # type: ignore
|
||||
ids=testcase_module_params_state_other['ids'], # type: ignore
|
||||
indirect=True)
|
||||
def test_xenserver_guest_powerstate_other(mocker, patch_ansible_module, capfd, XenAPI, xenserver_guest_powerstate):
|
||||
"""
|
||||
|
|
@ -255,8 +255,8 @@ def test_xenserver_guest_powerstate_other(mocker, patch_ansible_module, capfd, X
|
|||
|
||||
|
||||
@pytest.mark.parametrize('patch_ansible_module',
|
||||
testcase_module_params_wait['params'],
|
||||
ids=testcase_module_params_wait['ids'],
|
||||
testcase_module_params_wait['params'], # type: ignore
|
||||
ids=testcase_module_params_wait['ids'], # type: ignore
|
||||
indirect=True)
|
||||
def test_xenserver_guest_powerstate_wait(mocker, patch_ansible_module, capfd, XenAPI, xenserver_guest_powerstate):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue