Reformat everything.

This commit is contained in:
Felix Fontein
2025-11-01 12:08:41 +01:00
parent 3f2213791a
commit 340ff8586d
1008 changed files with 61301 additions and 58309 deletions

View File

@@ -12,7 +12,7 @@ import pytest
from .xenserver_common import fake_xenapi_ref
from .xenserver_conftest import XenAPI, xenserver_guest_info # noqa: F401, pylint: disable=unused-import
pytestmark = pytest.mark.usefixtures('patch_ansible_module')
pytestmark = pytest.mark.usefixtures("patch_ansible_module")
testcase_module_params = {
@@ -45,7 +45,12 @@ testcase_module_params = {
}
@pytest.mark.parametrize('patch_ansible_module', testcase_module_params['params'], ids=testcase_module_params['ids'], indirect=True) # type: ignore
@pytest.mark.parametrize(
"patch_ansible_module",
testcase_module_params["params"], # type: ignore
ids=testcase_module_params["ids"], # type: ignore
indirect=True,
)
def test_xenserver_guest_info(mocker, capfd, XenAPI, xenserver_guest_info):
"""
Tests regular module invocation including parsing and propagation of
@@ -53,20 +58,30 @@ def test_xenserver_guest_info(mocker, capfd, XenAPI, xenserver_guest_info):
"""
fake_vm_facts = {"fake-vm-fact": True}
mocker.patch('ansible_collections.community.general.plugins.modules.xenserver_guest_info.get_object_ref', return_value=None)
mocker.patch('ansible_collections.community.general.plugins.modules.xenserver_guest_info.gather_vm_params', return_value=None)
mocker.patch('ansible_collections.community.general.plugins.modules.xenserver_guest_info.gather_vm_facts', return_value=fake_vm_facts)
mocker.patch(
"ansible_collections.community.general.plugins.modules.xenserver_guest_info.get_object_ref", return_value=None
)
mocker.patch(
"ansible_collections.community.general.plugins.modules.xenserver_guest_info.gather_vm_params", return_value=None
)
mocker.patch(
"ansible_collections.community.general.plugins.modules.xenserver_guest_info.gather_vm_facts",
return_value=fake_vm_facts,
)
mocked_xenapi = mocker.patch.object(XenAPI.Session, 'xenapi', create=True)
mocked_xenapi = mocker.patch.object(XenAPI.Session, "xenapi", create=True)
mocked_returns = {
"pool.get_all.return_value": [fake_xenapi_ref('pool')],
"pool.get_default_SR.return_value": fake_xenapi_ref('SR'),
"pool.get_all.return_value": [fake_xenapi_ref("pool")],
"pool.get_default_SR.return_value": fake_xenapi_ref("SR"),
}
mocked_xenapi.configure_mock(**mocked_returns)
mocker.patch('ansible_collections.community.general.plugins.module_utils.xenserver.get_xenserver_version', return_value=[7, 2, 0])
mocker.patch(
"ansible_collections.community.general.plugins.module_utils.xenserver.get_xenserver_version",
return_value=[7, 2, 0],
)
with pytest.raises(SystemExit):
xenserver_guest_info.main()
@@ -74,4 +89,4 @@ def test_xenserver_guest_info(mocker, capfd, XenAPI, xenserver_guest_info):
out, err = capfd.readouterr()
result = json.loads(out)
assert result['instance'] == fake_vm_facts
assert result["instance"] == fake_vm_facts