From 4935a025ce7c86d43663dbebc82020440694be7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Wed, 11 Oct 2023 11:29:46 +0200 Subject: [PATCH] Add a few more tests for duration conversions --- tests/test_schemas_utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_schemas_utils.py b/tests/test_schemas_utils.py index 0732b3a..120ca88 100644 --- a/tests/test_schemas_utils.py +++ b/tests/test_schemas_utils.py @@ -9,9 +9,13 @@ def test_string_to_duration_days(): assert string_to_duration("3w", target="days") == 21 assert string_to_duration("3m", target="days") == 90 assert string_to_duration("1y", target="days") == 365 + with pytest.raises(ValueError): string_to_duration("3h", target="days") + with pytest.raises(ValueError): + string_to_duration("1", target="days") + def test_string_to_duration_hours(): assert string_to_duration("1h", target="hours") == 1 @@ -19,3 +23,6 @@ def test_string_to_duration_hours(): assert string_to_duration("1w", target="hours") == 7 * 24 assert string_to_duration("3w", target="hours") == 21 * 24 assert string_to_duration("3m", target="hours") == 3 * 30 * 24 + + with pytest.raises(ValueError): + string_to_duration("1", target="hours")