Skip to content

Commit fed5766

Browse files
committed
Loading proper config
1 parent f1c6cec commit fed5766

1 file changed

Lines changed: 301 additions & 0 deletions

File tree

tests/unit/models/config/test_quota_handlers_config.py

Lines changed: 301 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""Unit tests for QuotaHandlersConfiguration model."""
22

33
# pylint: disable=no-member
4+
from typing import Any
5+
46
import pytest
57
from pydantic import ValidationError
68
from pytest_subtests import SubTests
@@ -223,3 +225,302 @@ def test_quota_handlers_configuration_improper_values(subtests: SubTests) -> Non
223225
scheduler="scheduler", # pyright: ignore[reportArgumentType]
224226
enable_token_history=False,
225227
)
228+
229+
230+
correct_configurations = [
231+
{
232+
"sqlite": None,
233+
"postgres": None,
234+
"limiters": [
235+
{
236+
"type": "user_limiter",
237+
"name": "Brittany Perez",
238+
"initial_quota": 533,
239+
"quota_increase": 921,
240+
"period": "All instead purpose pull be spend use.",
241+
}
242+
],
243+
"scheduler": {
244+
"period": 279,
245+
"database_reconnection_count": 766,
246+
"database_reconnection_delay": 809,
247+
},
248+
"enable_token_history": False,
249+
},
250+
{
251+
"sqlite": {"db_path": "/tmp/foo/bar/baz"},
252+
"postgres": {
253+
"host": "Only himself prevent walk.",
254+
"port": 362,
255+
"db": "Present ever art central. Work smile six.",
256+
"user": "Later spring song.",
257+
"password": "&8wr@Mt@lMZG",
258+
"namespace": "Seem own offer deal energy.",
259+
"ssl_mode": "disable",
260+
"gss_encmode": "disable",
261+
},
262+
"limiters": [
263+
{
264+
"type": "user_limiter",
265+
"name": "Christina Hall",
266+
"initial_quota": 723,
267+
"quota_increase": 112,
268+
"period": "Media pretty recently push gas.",
269+
}
270+
],
271+
"scheduler": {
272+
"period": 479,
273+
"database_reconnection_count": 808,
274+
"database_reconnection_delay": 836,
275+
},
276+
"enable_token_history": True,
277+
},
278+
{
279+
"sqlite": {"db_path": "Between room attorney weight dream."},
280+
"postgres": None,
281+
"limiters": [
282+
{
283+
"type": "user_limiter",
284+
"name": "Xavier Anthony",
285+
"initial_quota": 536,
286+
"quota_increase": 80,
287+
"period": "Wrong class strategy.",
288+
},
289+
{
290+
"type": "user_limiter",
291+
"name": "Caroline Weaver",
292+
"initial_quota": 31,
293+
"quota_increase": 57,
294+
"period": "Lead boy least base.",
295+
},
296+
],
297+
"scheduler": {
298+
"period": 960,
299+
"database_reconnection_count": 5,
300+
"database_reconnection_delay": 336,
301+
},
302+
"enable_token_history": False,
303+
},
304+
{
305+
"sqlite": None,
306+
"postgres": None,
307+
"limiters": [
308+
{
309+
"type": "user_limiter",
310+
"name": "Kyle Whitehead",
311+
"initial_quota": 998,
312+
"quota_increase": 506,
313+
"period": "Pm recently character deal person.",
314+
},
315+
{
316+
"type": "user_limiter",
317+
"name": "Gary Ward",
318+
"initial_quota": 948,
319+
"quota_increase": 349,
320+
"period": "We physical seven follow turn front establish reme",
321+
},
322+
],
323+
"scheduler": {
324+
"period": 83,
325+
"database_reconnection_count": 88,
326+
"database_reconnection_delay": 428,
327+
},
328+
"enable_token_history": True,
329+
},
330+
{
331+
"sqlite": None,
332+
"postgres": None,
333+
"limiters": [
334+
{
335+
"type": "user_limiter",
336+
"name": "Christopher Flores",
337+
"initial_quota": 589,
338+
"quota_increase": 815,
339+
"period": "Page power would end he stage.",
340+
}
341+
],
342+
"scheduler": {
343+
"period": 217,
344+
"database_reconnection_count": 374,
345+
"database_reconnection_delay": 70,
346+
},
347+
"enable_token_history": False,
348+
},
349+
{
350+
"sqlite": None,
351+
"postgres": None,
352+
"limiters": [
353+
{
354+
"type": "user_limiter",
355+
"name": "Shannon Martin",
356+
"initial_quota": 110,
357+
"quota_increase": 755,
358+
"period": "Case material system career ever these short.",
359+
},
360+
{
361+
"type": "user_limiter",
362+
"name": "Gabrielle Meadows",
363+
"initial_quota": 760,
364+
"quota_increase": 55,
365+
"period": "Page serve civil question series purpose.",
366+
},
367+
{
368+
"type": "user_limiter",
369+
"name": "Kelly Velasquez",
370+
"initial_quota": 419,
371+
"quota_increase": 633,
372+
"period": "Behavior half loss during pay.",
373+
},
374+
],
375+
"scheduler": {
376+
"period": 387,
377+
"database_reconnection_count": 216,
378+
"database_reconnection_delay": 894,
379+
},
380+
"enable_token_history": False,
381+
},
382+
{
383+
"sqlite": {"db_path": "Camera agent general always like."},
384+
"postgres": None,
385+
"limiters": [
386+
{
387+
"type": "user_limiter",
388+
"name": "Bill Boyd",
389+
"initial_quota": 582,
390+
"quota_increase": 84,
391+
"period": "Side no born set. Different weight speak why daugh",
392+
}
393+
],
394+
"scheduler": {
395+
"period": 414,
396+
"database_reconnection_count": 407,
397+
"database_reconnection_delay": 109,
398+
},
399+
"enable_token_history": True,
400+
},
401+
{
402+
"sqlite": {"db_path": "Begin remain inside practice ability Mrs."},
403+
"postgres": {
404+
"host": "Police stuff black.",
405+
"port": 589,
406+
"db": "Decide history worker can stand.",
407+
"user": "Type away organization debate stand.",
408+
"password": "@alvNH%qK%47",
409+
"namespace": "Compare gun trip establish key.",
410+
"ssl_mode": "disable",
411+
"gss_encmode": "disable",
412+
},
413+
"limiters": [
414+
{
415+
"type": "user_limiter",
416+
"name": "William Armstrong",
417+
"initial_quota": 305,
418+
"quota_increase": 648,
419+
"period": "Relate couple song way wind rule model.",
420+
},
421+
{
422+
"type": "user_limiter",
423+
"name": "Terry Mitchell",
424+
"initial_quota": 206,
425+
"quota_increase": 316,
426+
"period": "Onto within arrive type group. Black none human re",
427+
},
428+
{
429+
"type": "user_limiter",
430+
"name": "Deborah Vazquez",
431+
"initial_quota": 24,
432+
"quota_increase": 24,
433+
"period": "Call close table.",
434+
},
435+
],
436+
"scheduler": {
437+
"period": 959,
438+
"database_reconnection_count": 125,
439+
"database_reconnection_delay": 94,
440+
},
441+
"enable_token_history": False,
442+
},
443+
{
444+
"sqlite": {"db_path": "Than draw security away."},
445+
"postgres": {
446+
"host": "Beat decade start performance without summer.",
447+
"port": 554,
448+
"db": "Election wall us notice.",
449+
"user": "Each go improve happy.",
450+
"password": "UXR&Zm4$W*8^",
451+
"namespace": None,
452+
"ssl_mode": "allow",
453+
"gss_encmode": "prefer",
454+
},
455+
"limiters": [
456+
{
457+
"type": "user_limiter",
458+
"name": "James Burgess",
459+
"initial_quota": 698,
460+
"quota_increase": 945,
461+
"period": "Employee stage activity total.",
462+
},
463+
{
464+
"type": "user_limiter",
465+
"name": "Brenda Richard",
466+
"initial_quota": 583,
467+
"quota_increase": 582,
468+
"period": "Among or only nearly.",
469+
},
470+
{
471+
"type": "user_limiter",
472+
"name": "Carol Colon",
473+
"initial_quota": 26,
474+
"quota_increase": 527,
475+
"period": "Machine pull finally stock without us him.",
476+
},
477+
],
478+
"scheduler": {
479+
"period": 609,
480+
"database_reconnection_count": 225,
481+
"database_reconnection_delay": 316,
482+
},
483+
"enable_token_history": True,
484+
},
485+
{
486+
"sqlite": None,
487+
"postgres": None,
488+
"limiters": [
489+
{
490+
"type": "user_limiter",
491+
"name": "Katherine Gibson",
492+
"initial_quota": 971,
493+
"quota_increase": 482,
494+
"period": "Many debate myself.",
495+
},
496+
{
497+
"type": "user_limiter",
498+
"name": "David Mcclure",
499+
"initial_quota": 883,
500+
"quota_increase": 55,
501+
"period": "Under from often.",
502+
},
503+
{
504+
"type": "user_limiter",
505+
"name": "Nicholas Jones",
506+
"initial_quota": 622,
507+
"quota_increase": 333,
508+
"period": "Research situation apply positive.",
509+
},
510+
],
511+
"scheduler": {
512+
"period": 278,
513+
"database_reconnection_count": 173,
514+
"database_reconnection_delay": 666,
515+
},
516+
"enable_token_history": True,
517+
},
518+
]
519+
520+
521+
@pytest.mark.parametrize("config_dict", correct_configurations)
522+
def test_quota_handlers_from_dict(config_dict: dict[str, Any]) -> None:
523+
"""Test the configuration initialization from dictionary with config values."""
524+
# try to initialize the app config and load configuration from a Python
525+
# dictionary
526+
QuotaHandlersConfiguration(**config_dict)

0 commit comments

Comments
 (0)