Debian Codegraph @

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

raw
1 # Copyright (c) 2023, Michal Opala <[email protected]>
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 import pytest
8
9 from ansible_collections.community.general.plugins.modules.one_vm import parse_updateconf
10
11 PARSE_UPDATECONF_VALID = [
12 (
13 {
14 "CPU": 1,
15 "OS": {"ARCH": 2},
16 },
17 {
18 "OS": {"ARCH": 2},
19 },
20 ),
21 (
22 {
23 "OS": {"ARCH": 1, "ASD": 2}, # "ASD" is an invalid attribute, we ignore it
24 },
25 {
26 "OS": {"ARCH": 1},
27 },
28 ),
29 (
30 {
31 "OS": {"ASD": 1}, # "ASD" is an invalid attribute, we ignore it
32 },
33 {},
34 ),
35 (
36 {
37 "MEMORY": 1,
38 "CONTEXT": {
39 "PASSWORD": 2,
40 "SSH_PUBLIC_KEY": 3,
41 },
42 },
43 {
44 "CONTEXT": {
45 "PASSWORD": 2,
46 "SSH_PUBLIC_KEY": 3,
47 },
48 },
49 ),
50 ]
51
52
53 @pytest.mark.parametrize("vm_template,expected_result", PARSE_UPDATECONF_VALID)
54 def test_parse_updateconf(vm_template, expected_result):
55 result = parse_updateconf(vm_template)
56 assert result == expected_result, repr(result)