summaryrefslogtreecommitdiffstats
path: root/test/units
diff options
context:
space:
mode:
authorAbhijeet Kasurde <akasurde@redhat.com>2024-03-07 20:04:58 +0100
committerGitHub <noreply@github.com>2024-03-07 20:04:58 +0100
commit2cf52daa035bd3c58e753a6299a4a95595d8cb02 (patch)
tree87551e4a76f3940ae184e5bb3111fab3a3b754f5 /test/units
parentRe-enable psrp tests that were disabled (#82785) (diff)
downloadansible-2cf52daa035bd3c58e753a6299a4a95595d8cb02.tar.xz
ansible-2cf52daa035bd3c58e753a6299a4a95595d8cb02.zip
Handle error raised when argument validation (#82783)
* Handle error raised when argument validation with elements=int and value is not within choices Fixes: #82776 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Diffstat (limited to 'test/units')
-rw-r--r--test/units/module_utils/common/parameters/test_check_arguments.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/test/units/module_utils/common/parameters/test_check_arguments.py b/test/units/module_utils/common/parameters/test_check_arguments.py
index d7b72172c0..855eb6775d 100644
--- a/test/units/module_utils/common/parameters/test_check_arguments.py
+++ b/test/units/module_utils/common/parameters/test_check_arguments.py
@@ -7,7 +7,11 @@ from __future__ import annotations
import pytest
-from ansible.module_utils.common.parameters import _get_unsupported_parameters
+from ansible.module_utils.common.parameters import (
+ _get_unsupported_parameters,
+ _validate_argument_values,
+)
+from ansible.module_utils.errors import AnsibleValidationErrorMultiple
@pytest.fixture
@@ -35,3 +39,13 @@ def test_check_arguments(argument_spec, module_parameters, legal_inputs, expecte
result = _get_unsupported_parameters(argument_spec, module_parameters, legal_inputs)
assert result == expected
+
+
+def test_validate_argument_values(mocker):
+ argument_spec = {
+ "foo": {"type": "list", "elements": "int", "choices": [1]},
+ }
+ module_parameters = {"foo": [2]}
+ errors = AnsibleValidationErrorMultiple()
+ result = _validate_argument_values(argument_spec, module_parameters, errors=errors)
+ assert "value of foo must be one" in errors[0].msg