mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-24 12:49:03 +00:00
Make all doc fragments, module utils, and plugin utils private (#11896)
* Make all doc fragments private. * Make all plugin utils private. * Make all module utils private. * Reformat. * Changelog fragment. * Update configs and ignores. * Adjust unit test names.
This commit is contained in:
parent
9ef1dbb6d5
commit
4fa82b9617
807 changed files with 2041 additions and 1702 deletions
75
tests/unit/plugins/module_utils/test__opennebula.py
Normal file
75
tests/unit/plugins/module_utils/test__opennebula.py
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
# Copyright (c) 2023, Michal Opala <mopala@opennebula.io>
|
||||
# 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
|
||||
|
||||
import textwrap
|
||||
|
||||
import pytest
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils._opennebula import flatten, render
|
||||
|
||||
FLATTEN_VALID = [
|
||||
([[[1]], [2], 3], False, [1, 2, 3]),
|
||||
([[[1]], [2], 3], True, [1, 2, 3]),
|
||||
([[1]], False, [1]),
|
||||
([[1]], True, 1),
|
||||
(1, False, [1]),
|
||||
(1, True, 1),
|
||||
]
|
||||
|
||||
RENDER_VALID = [
|
||||
(
|
||||
{
|
||||
"NIC": {"NAME": "NIC0", "NETWORK_ID": 0},
|
||||
"CPU": 1,
|
||||
"MEMORY": 1024,
|
||||
},
|
||||
textwrap.dedent("""
|
||||
CPU="1"
|
||||
MEMORY="1024"
|
||||
NIC=[NAME="NIC0",NETWORK_ID="0"]
|
||||
""").strip(),
|
||||
),
|
||||
(
|
||||
{
|
||||
"NIC": [
|
||||
{"NAME": "NIC0", "NETWORK_ID": 0},
|
||||
{"NAME": "NIC1", "NETWORK_ID": 1},
|
||||
],
|
||||
"CPU": 1,
|
||||
"MEMORY": 1024,
|
||||
},
|
||||
textwrap.dedent("""
|
||||
CPU="1"
|
||||
MEMORY="1024"
|
||||
NIC=[NAME="NIC0",NETWORK_ID="0"]
|
||||
NIC=[NAME="NIC1",NETWORK_ID="1"]
|
||||
""").strip(),
|
||||
),
|
||||
(
|
||||
{
|
||||
"EMPTY_VALUE": None,
|
||||
"SCHED_REQUIREMENTS": 'CLUSTER_ID="100"',
|
||||
"BACKSLASH_ESCAPED": "this is escaped: \\n; this isn't: \"\nend",
|
||||
},
|
||||
textwrap.dedent("""
|
||||
BACKSLASH_ESCAPED="this is escaped: \\\\n; this isn't: \\"
|
||||
end"
|
||||
SCHED_REQUIREMENTS="CLUSTER_ID=\\"100\\""
|
||||
""").strip(),
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("to_flatten,extract,expected_result", FLATTEN_VALID)
|
||||
def test_flatten(to_flatten, extract, expected_result):
|
||||
result = flatten(to_flatten, extract)
|
||||
assert result == expected_result, repr(result)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("to_render,expected_result", RENDER_VALID)
|
||||
def test_render(to_render, expected_result):
|
||||
result = render(to_render)
|
||||
assert result == expected_result, repr(result)
|
||||
Loading…
Add table
Add a link
Reference in a new issue