mirror of
https://github.com/kubevirt/kubevirt.core.git
synced 2026-05-07 05:42:38 +00:00
Update Ansible GitHub workflows
The workflows committed in the first commit were missing the installation of required dependencies and other fixes. Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
This commit is contained in:
51
tests/unit/utils/ansible_module_mock.py
Normal file
51
tests/unit/utils/ansible_module_mock.py
Normal file
@@ -0,0 +1,51 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright: (c) 2021, Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# This module maock the AnsibleModule class for more information please visite
|
||||
# https://docs.ansible.com/ansible/latest/dev_guide/testing_units_modules.html#module-argument-processing
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
import json
|
||||
|
||||
from ansible.module_utils import basic
|
||||
from ansible.module_utils.common.text.converters import to_bytes
|
||||
|
||||
|
||||
def set_module_args(args):
|
||||
"""prepare arguments so that they will be picked up during module creation"""
|
||||
args = json.dumps({"ANSIBLE_MODULE_ARGS": args})
|
||||
basic._ANSIBLE_ARGS = to_bytes(args)
|
||||
|
||||
|
||||
class AnsibleExitJson(Exception):
|
||||
"""Exception class to be raised by module.exit_json and caught by the test case"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class AnsibleFailJson(Exception):
|
||||
"""Exception class to be raised by module.fail_json and caught by the test case"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
def exit_json(*args, **kwargs):
|
||||
"""function to patch over exit_json; package return data into an exception"""
|
||||
if "changed" not in kwargs:
|
||||
kwargs["changed"] = False
|
||||
raise AnsibleExitJson(kwargs)
|
||||
|
||||
|
||||
def fail_json(*args, **kwargs):
|
||||
"""function to patch over fail_json; package return data into an exception"""
|
||||
kwargs["failed"] = True
|
||||
raise AnsibleFailJson(kwargs)
|
||||
|
||||
|
||||
def get_api_client(*args, **kwargs):
|
||||
"""function to patch over get_api_client """
|
||||
pass
|
||||
Reference in New Issue
Block a user