From a9371eec81fc9478646752fd0d0f678b3d73a77a Mon Sep 17 00:00:00 2001 From: Noa Levi <275430404+lphuc2250gma@users.noreply.github.com> Date: Fri, 5 Jun 2026 12:37:17 +0000 Subject: [PATCH] chore: improve OpenSandbox maintenance path --- cli/tests/test_utils.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/cli/tests/test_utils.py b/cli/tests/test_utils.py index bf48129ba..e6301d6ff 100644 --- a/cli/tests/test_utils.py +++ b/cli/tests/test_utils.py @@ -21,7 +21,7 @@ import click import pytest -from opensandbox_cli.utils import DURATION, KEY_VALUE, parse_duration +from opensandbox_cli.utils import DURATION, KEY_VALUE, parse_duration, parse_nullable_duration # --------------------------------------------------------------------------- # parse_duration @@ -68,6 +68,25 @@ def test_strips_whitespace(self) -> None: # --------------------------------------------------------------------------- +class TestParseNullableDuration: + def test_none_literal_returns_none(self) -> None: + assert parse_nullable_duration("none") is None + + def test_none_case_insensitive(self) -> None: + assert parse_nullable_duration("NONE") is None + assert parse_nullable_duration("None") is None + + def test_none_strips_whitespace(self) -> None: + assert parse_nullable_duration(" none ") is None + + def test_valid_duration_parsed(self) -> None: + assert parse_nullable_duration("10m") == timedelta(minutes=10) + + def test_invalid_duration_raises(self) -> None: + with pytest.raises(click.BadParameter): + parse_nullable_duration("invalid") + + class TestDurationType: def test_converts_string(self) -> None: result = DURATION.convert("5m", None, None)