1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-03-24 22:27:24 +00:00
community.general/tests/unit/plugins/modules/test_open_iscsi.py
Alexei Znamensky d48e767e1e
open_iscsi: support IPv6 portals (#11657)
* fix(modules/open_iscsi): support IPv6 portals

* add changelog frag
2026-03-23 06:47:40 +01:00

51 lines
1.4 KiB
Python

# Copyright (c) 2026 Alexei Znamensky (russoz@gmail.com)
# 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 annotations
from ansible_collections.community.general.plugins.modules import open_iscsi
from .uthelper import RunCommandMock, UTHelper
from .uthelper import TestCaseMock as MockBase
_MODULE = "ansible_collections.community.general.plugins.modules.open_iscsi"
class SocketMock(MockBase):
name = "socket_getaddrinfo"
def setup(self, mocker):
ip = self.mock_specs["return"]
mocker.patch(
f"{_MODULE}.socket.getaddrinfo",
return_value=[(None, None, None, None, (ip, None))],
)
def check(self, test_case, results):
pass
class GlobMock(MockBase):
name = "glob_glob"
def setup(self, mocker):
paths = self.mock_specs.get("return", [])
mocker.patch(f"{_MODULE}.glob.glob", return_value=paths)
mocker.patch(f"{_MODULE}.os.path.realpath", side_effect=lambda x: x)
def check(self, test_case, results):
pass
class TimeSleepMock(MockBase):
name = "time_sleep"
def setup(self, mocker):
mocker.patch(f"{_MODULE}.time.sleep")
def check(self, test_case, results):
pass
UTHelper.from_module(open_iscsi, __name__, mocks=[RunCommandMock, SocketMock, GlobMock, TimeSleepMock])