Skip to content

Commit fee0f77

Browse files
authored
Merge pull request #1839 from tisnik/lcore-2295-quota-limiter-configuration-unit-tests
LCORE-2295: Quota limiter configuration unit tests
2 parents 6738771 + 746b638 commit fee0f77

1 file changed

Lines changed: 92 additions & 0 deletions

File tree

tests/unit/models/config/test_quota_limiter_config.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,95 @@ def test_configure_quota_handlers_from_dict(config_dict: dict[str, Any]) -> None
314314
# try to initialize the app config and load configuration from a Python
315315
# dictionary
316316
QuotaLimiterConfiguration(**config_dict)
317+
318+
319+
incorrect_configurations = [
320+
{
321+
"type": "cluster_limiter",
322+
"name": "John Williams",
323+
"initial_quota": "foo",
324+
"quota_increase": 583,
325+
"period": "Series trouble fund skill.",
326+
},
327+
{
328+
"type": "cluster_limiter",
329+
"name": "Frank Levine",
330+
"initial_quota": 616,
331+
"quota_increase": "bar",
332+
"period": "Eye idea western skill able although happy. Positi",
333+
},
334+
{
335+
"type": "cluster_limiter",
336+
"name": "Susan Walters",
337+
"initial_quota": "foo",
338+
"quota_increase": "bar",
339+
"period": "One stock pressure. Save worker benefit blue speak",
340+
},
341+
{
342+
"type": "foo",
343+
"name": "Pamela Farmer",
344+
"initial_quota": 223,
345+
"quota_increase": 62,
346+
"period": "Expect chance or stop hard southern particularly.",
347+
},
348+
{
349+
"type": "bar",
350+
"name": "Bobby Chandler",
351+
"initial_quota": 496,
352+
"quota_increase": 217,
353+
"period": "Where animal outside.",
354+
},
355+
{
356+
"type": None,
357+
"name": "Jeffrey Butler",
358+
"initial_quota": 445,
359+
"quota_increase": 78,
360+
"period": "Song child mind. Sit win miss gas as.",
361+
},
362+
{
363+
"type": "cluster_limiter",
364+
"name": None,
365+
"initial_quota": 375,
366+
"quota_increase": 953,
367+
"period": "Feel husband phone together summer.",
368+
},
369+
{
370+
"type": "cluster_limiter",
371+
"name": "Jacqueline Allen",
372+
"initial_quota": None,
373+
"quota_increase": 277,
374+
"period": "Whose environmental life food bit young.",
375+
},
376+
{
377+
"type": "cluster_limiter",
378+
"name": "Matthew Williams",
379+
"initial_quota": 696,
380+
"quota_increase": None,
381+
"period": "Perhaps girl organization ok continue.",
382+
},
383+
{
384+
"type": "cluster_limiter",
385+
"name": "Shawn Stone",
386+
"initial_quota": 126,
387+
"quota_increase": 547,
388+
"period": None,
389+
},
390+
{
391+
"type": None,
392+
"name": None,
393+
"initial_quota": None,
394+
"quota_increase": None,
395+
"period": None,
396+
},
397+
]
398+
399+
400+
@pytest.mark.parametrize("config_dict", incorrect_configurations)
401+
def test_configure_quota_handlers_from_dict_negative_cases(
402+
config_dict: dict[str, Any],
403+
) -> None:
404+
"""Test the configuration initialization from dictionary with config values."""
405+
with pytest.raises(ValueError, match="validation error"):
406+
# try to initialize the app config and load configuration from a Python
407+
# dictionary
408+
QuotaLimiterConfiguration(**config_dict)

0 commit comments

Comments
 (0)