Debian Codegraph @

ansible_collections/community/general/tests/unit/plugins/modules/oneview_conftest.py

raw
1 # Copyright (c) 2016-2017 Hewlett Packard Enterprise Development LP
2 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
3 # SPDX-License-Identifier: GPL-3.0-or-later
4
5 from __future__ import annotations
6
7 from unittest.mock import Mock, patch
8
9 import pytest
10
11 from .oneview_module_loader import ONEVIEW_MODULE_UTILS_PATH
12
13 # This import must come *after* the oneview_module_loader import!
14 from hpOneView.oneview_client import OneViewClient # isort: skip
15
16
17 @pytest.fixture
18 def mock_ov_client():
19 patcher_json_file = patch.object(OneViewClient, "from_json_file")
20 client = patcher_json_file.start()
21 return client.return_value
22
23
24 @pytest.fixture
25 def mock_ansible_module():
26 patcher_ansible = patch(f"{ONEVIEW_MODULE_UTILS_PATH}.AnsibleModule")
27 patcher_ansible = patcher_ansible.start()
28 ansible_module = Mock()
29 patcher_ansible.return_value = ansible_module
30 return ansible_module