Skip to content

Commit c6fe801

Browse files
committed
Tests for negative case
1 parent 1bcac36 commit c6fe801

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

tests/unit/models/config/test_quota_scheduler_config.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,63 @@ def test_configure_quota_scheduler_from_dict(
111111
) -> None:
112112
"""Test the configuration initialization from dictionary with config values."""
113113
QuotaSchedulerConfiguration(**config_dict)
114+
115+
116+
incorrect_configurations = [
117+
{
118+
"period": -1,
119+
"database_reconnection_count": 125,
120+
"database_reconnection_delay": 94,
121+
},
122+
{
123+
"period": 1,
124+
"database_reconnection_count": -1,
125+
"database_reconnection_delay": 94,
126+
},
127+
{
128+
"period": 959,
129+
"database_reconnection_count": 1,
130+
"database_reconnection_delay": -1,
131+
},
132+
{
133+
"period": None,
134+
"database_reconnection_count": 125,
135+
"database_reconnection_delay": 94,
136+
},
137+
{
138+
"period": 1,
139+
"database_reconnection_count": None,
140+
"database_reconnection_delay": 94,
141+
},
142+
{
143+
"period": 959,
144+
"database_reconnection_count": 1,
145+
"database_reconnection_delay": None,
146+
},
147+
{
148+
"period": "not a number",
149+
"database_reconnection_count": 125,
150+
"database_reconnection_delay": 94,
151+
},
152+
{
153+
"period": 1,
154+
"database_reconnection_count": "not a number",
155+
"database_reconnection_delay": 94,
156+
},
157+
{
158+
"period": 959,
159+
"database_reconnection_count": 1,
160+
"database_reconnection_delay": "not a number",
161+
},
162+
]
163+
164+
165+
@pytest.mark.parametrize("config_dict", incorrect_configurations)
166+
def test_configure_quota_scheduler_from_dict_negative_cases(
167+
config_dict: dict[str, Any],
168+
) -> None:
169+
"""Test the configuration initialization from dictionary with config values."""
170+
with pytest.raises(ValueError, match="validation error"):
171+
# try to initialize the app config and load configuration from a Python
172+
# dictionary
173+
QuotaSchedulerConfiguration(**config_dict)

0 commit comments

Comments
 (0)