diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:04:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:04:41 +0000 |
commit | 975f66f2eebe9dadba04f275774d4ab83f74cf25 (patch) | |
tree | 89bd26a93aaae6a25749145b7e4bca4a1e75b2be /ansible_collections/containers/podman/tests/unit/plugins | |
parent | Initial commit. (diff) | |
download | ansible-975f66f2eebe9dadba04f275774d4ab83f74cf25.tar.xz ansible-975f66f2eebe9dadba04f275774d4ab83f74cf25.zip |
Adding upstream version 7.7.0+dfsg.upstream/7.7.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/containers/podman/tests/unit/plugins')
-rw-r--r-- | ansible_collections/containers/podman/tests/unit/plugins/modules/test_common.py | 19 | ||||
-rw-r--r-- | ansible_collections/containers/podman/tests/unit/plugins/modules/test_container_lib.py | 89 |
2 files changed, 108 insertions, 0 deletions
diff --git a/ansible_collections/containers/podman/tests/unit/plugins/modules/test_common.py b/ansible_collections/containers/podman/tests/unit/plugins/modules/test_common.py new file mode 100644 index 000000000..583e26dee --- /dev/null +++ b/ansible_collections/containers/podman/tests/unit/plugins/modules/test_common.py @@ -0,0 +1,19 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import pytest + +from ansible_collections.containers.podman.plugins.module_utils.podman.common import ( + lower_keys, +) + + +@pytest.mark.parametrize('test_input, expected', [ + (["AAA", "BBB"], ["AAA", "BBB"]), + ("AAQQ", "AAQQ"), + ({"AAA": "AaaAa", "11": 22, "AbCdEf": None, "bbb": "aaaAA"}, + {"aaa": "AaaAa", "11": 22, "abcdef": None, "bbb": "aaaAA"}) +]) +def test_lower_keys(test_input, expected): + print(lower_keys.__code__.co_filename) + assert lower_keys(test_input) == expected diff --git a/ansible_collections/containers/podman/tests/unit/plugins/modules/test_container_lib.py b/ansible_collections/containers/podman/tests/unit/plugins/modules/test_container_lib.py new file mode 100644 index 000000000..20dd4e66c --- /dev/null +++ b/ansible_collections/containers/podman/tests/unit/plugins/modules/test_container_lib.py @@ -0,0 +1,89 @@ +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +import pytest + +from ansible_collections.containers.podman.plugins.module_utils.podman.podman_container_lib import ( + PodmanModuleParams, + PodmanContainerDiff, +) + + +@pytest.mark.parametrize( + "test_input, expected", + [ + ( + { + "cap_add": ["SYS_ADMIN"], + "name": "testcont", + "image": "testimage", + "command": None, + }, + [ + b"create", + b"--name", + b"testcont", + b"--cap-add", + b"SYS_ADMIN", + b"testimage", + ], + ), + ( + { + "stop_signal": 9, + "name": "testcont", + "image": "testimage", + "command": None, + "sig_proxy": True, + }, + [ + b"create", + b"--name", + b"testcont", + b"--stop-signal", + b"9", + b"--sig-proxy=True", + b"testimage", + ], + ), + ], +) +def test_container_add_params(test_input, expected): + podm = PodmanModuleParams( + "create", + test_input, + "4.0.0", + None, + ) + assert podm.construct_command_from_params() == expected + + +@pytest.mark.parametrize( + "test_input, expected", + [ + ( + [ + None, # module + {"conmon_pidfile": "bbb"}, # module params + {"conmonpidfile": "ccc"}, # container info + {}, # image info + "4.1.1", # podman version + ], + True, + ), + ( + [ + None, # module + {"conmon_pidfile": None}, # module params + {"conmonpidfile": "ccc"}, # container info + {}, # image info + "4.1.1", # podman version + ], + False, + ), + ], +) +def test_container_diff(test_input, expected): + diff = PodmanContainerDiff(*test_input) + assert diff.diffparam_conmon_pidfile() == expected |