diff options
-rw-r--r-- | kvmd/validators/kvm.py | 2 | ||||
-rw-r--r-- | testenv/tests/validators/test_kvm.py | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/kvmd/validators/kvm.py b/kvmd/validators/kvm.py index b06edf95..5a1fe1ae 100644 --- a/kvmd/validators/kvm.py +++ b/kvmd/validators/kvm.py @@ -107,7 +107,7 @@ def valid_ugpio_driver(arg: Any, variants: Optional[Set[str]]=None) -> str: name = "GPIO driver" arg = check_len(check_re_match(arg, name, r"^[a-zA-Z_][a-zA-Z0-9_-]*$"), name, 255) if variants is not None: - arg = check_string_in_list(arg, f"configured {name}", variants) + arg = check_string_in_list(arg, f"configured {name}", variants, False) return arg diff --git a/testenv/tests/validators/test_kvm.py b/testenv/tests/validators/test_kvm.py index 27bc1d67..8e9029ab 100644 --- a/testenv/tests/validators/test_kvm.py +++ b/testenv/tests/validators/test_kvm.py @@ -238,6 +238,20 @@ def test_fail__valid_ugpio_item(validator: Callable[[Any], str], arg: Any) -> No # ===== [email protected]("arg", ["foo", " bar", " baz "]) +def test_ok__valid_ugpio_driver_variants(arg: Any) -> None: + value = valid_ugpio_driver(arg, set(["foo", "bar", "baz"])) + assert type(value) == str # pylint: disable=unidiomatic-typecheck + assert value == str(arg).strip() + + [email protected]("arg", ["BAR", " ", "", None]) +def test_fail__valid_ugpio_driver_variants(arg: Any) -> None: + with pytest.raises(ValidatorError): + print(valid_ugpio_driver(arg, set(["foo", "bar", "baz"]))) + + +# ===== @pytest.mark.parametrize("arg", ["Input ", " OUTPUT "]) def test_ok__valid_ugpio_mode(arg: Any) -> None: assert valid_ugpio_mode(arg) == arg.strip().lower() |