Debian Codegraph @

ansible_collections/community/general/tests/unit/plugins/module_utils/_xenserver/FakeAnsibleModule.py

raw
1 #
2 # Copyright (c) 2019, Bojan Vitnik <[email protected]>
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 from __future__ import annotations
7
8
9 class AnsibleModuleException(Exception):
10 def __init__(self, *args, **kwargs):
11 self.args = args
12 self.kwargs = kwargs
13
14
15 class ExitJsonException(AnsibleModuleException):
16 pass
17
18
19 class FailJsonException(AnsibleModuleException):
20 pass
21
22
23 class FakeAnsibleModule:
24 def __init__(self, params=None, check_mode=False):
25 self.params = params
26 self.check_mode = check_mode
27
28 def exit_json(self, *args, **kwargs):
29 raise ExitJsonException(*args, **kwargs)
30
31 def fail_json(self, *args, **kwargs):
32 raise FailJsonException(*args, **kwargs)