From 1bcac36d414db37e9eb86334c74cb2460e7361b5 Mon Sep 17 00:00:00 2001 From: Pavel Tisnovsky Date: Wed, 3 Jun 2026 08:31:13 +0200 Subject: [PATCH 1/2] Tests for positive case --- .../config/test_quota_scheduler_config.py | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/unit/models/config/test_quota_scheduler_config.py b/tests/unit/models/config/test_quota_scheduler_config.py index 098b7140f..6e8249fd3 100644 --- a/tests/unit/models/config/test_quota_scheduler_config.py +++ b/tests/unit/models/config/test_quota_scheduler_config.py @@ -1,5 +1,7 @@ """Unit tests for QuotaSchedulerConfig model.""" +from typing import Any + import pytest from pydantic import ValidationError @@ -77,3 +79,35 @@ def test_quota_scheduler_custom_configuration_negative_reconnection_delay() -> N QuotaSchedulerConfiguration( database_reconnection_delay=-10 ) # pyright: ignore[reportCallIssue] + + +correct_configurations = [ + { + "period": 959, + "database_reconnection_count": 125, + "database_reconnection_delay": 94, + }, + { + "period": 1, + "database_reconnection_count": 125, + "database_reconnection_delay": 94, + }, + { + "period": 959, + "database_reconnection_count": 1, + "database_reconnection_delay": 94, + }, + { + "period": 959, + "database_reconnection_count": 125, + "database_reconnection_delay": 1, + }, +] + + +@pytest.mark.parametrize("config_dict", correct_configurations) +def test_configure_quota_scheduler_from_dict( + config_dict: dict[str, Any], +) -> None: + """Test the configuration initialization from dictionary with config values.""" + QuotaSchedulerConfiguration(**config_dict) From c6fe801c40001e7092eeaee9f7b750344826c2c0 Mon Sep 17 00:00:00 2001 From: Pavel Tisnovsky Date: Wed, 3 Jun 2026 08:31:29 +0200 Subject: [PATCH 2/2] Tests for negative case --- .../config/test_quota_scheduler_config.py | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tests/unit/models/config/test_quota_scheduler_config.py b/tests/unit/models/config/test_quota_scheduler_config.py index 6e8249fd3..f81b20d37 100644 --- a/tests/unit/models/config/test_quota_scheduler_config.py +++ b/tests/unit/models/config/test_quota_scheduler_config.py @@ -111,3 +111,63 @@ def test_configure_quota_scheduler_from_dict( ) -> None: """Test the configuration initialization from dictionary with config values.""" QuotaSchedulerConfiguration(**config_dict) + + +incorrect_configurations = [ + { + "period": -1, + "database_reconnection_count": 125, + "database_reconnection_delay": 94, + }, + { + "period": 1, + "database_reconnection_count": -1, + "database_reconnection_delay": 94, + }, + { + "period": 959, + "database_reconnection_count": 1, + "database_reconnection_delay": -1, + }, + { + "period": None, + "database_reconnection_count": 125, + "database_reconnection_delay": 94, + }, + { + "period": 1, + "database_reconnection_count": None, + "database_reconnection_delay": 94, + }, + { + "period": 959, + "database_reconnection_count": 1, + "database_reconnection_delay": None, + }, + { + "period": "not a number", + "database_reconnection_count": 125, + "database_reconnection_delay": 94, + }, + { + "period": 1, + "database_reconnection_count": "not a number", + "database_reconnection_delay": 94, + }, + { + "period": 959, + "database_reconnection_count": 1, + "database_reconnection_delay": "not a number", + }, +] + + +@pytest.mark.parametrize("config_dict", incorrect_configurations) +def test_configure_quota_scheduler_from_dict_negative_cases( + config_dict: dict[str, Any], +) -> None: + """Test the configuration initialization from dictionary with config values.""" + with pytest.raises(ValueError, match="validation error"): + # try to initialize the app config and load configuration from a Python + # dictionary + QuotaSchedulerConfiguration(**config_dict)