@@ -524,3 +524,227 @@ def test_quota_handlers_from_dict(config_dict: dict[str, Any]) -> None:
524524 # try to initialize the app config and load configuration from a Python
525525 # dictionary
526526 QuotaHandlersConfiguration (** config_dict )
527+
528+
529+ incorrect_configurations = [
530+ {
531+ "sqlite" : None ,
532+ "postgres" : None ,
533+ "limiters" : [
534+ {
535+ "type" : "user_limiter" ,
536+ "name" : "Brittany Perez" ,
537+ "initial_quota" : None ,
538+ "quota_increase" : 921 ,
539+ "period" : "All instead purpose pull be spend use." ,
540+ }
541+ ],
542+ "scheduler" : {
543+ "period" : 279 ,
544+ "database_reconnection_count" : 766 ,
545+ "database_reconnection_delay" : 809 ,
546+ },
547+ "enable_token_history" : False ,
548+ },
549+ {
550+ "sqlite" : {"db_path" : "/tmp/foo/bar/baz" },
551+ "postgres" : {
552+ "host" : "Only himself prevent walk." ,
553+ "port" : 362 ,
554+ "db" : "Present ever art central. Work smile six." ,
555+ "user" : "Later spring song." ,
556+ "password" : "&8wr@Mt@lMZG" ,
557+ "namespace" : "Seem own offer deal energy." ,
558+ "ssl_mode" : "disable" ,
559+ "gss_encmode" : "disable" ,
560+ },
561+ "limiters" : [
562+ {
563+ "type" : "user_limiter" ,
564+ "name" : "Christina Hall" ,
565+ "initial_quota" : 723 ,
566+ "quota_increase" : None ,
567+ "period" : "Media pretty recently push gas." ,
568+ }
569+ ],
570+ "scheduler" : {
571+ "period" : 479 ,
572+ "database_reconnection_count" : 808 ,
573+ "database_reconnection_delay" : 836 ,
574+ },
575+ "enable_token_history" : True ,
576+ },
577+ {
578+ "sqlite" : {"db_path" : "Between room attorney weight dream." },
579+ "postgres" : None ,
580+ "limiters" : [
581+ {
582+ "type" : "user_limiter" ,
583+ "name" : "Xavier Anthony" ,
584+ "initial_quota" : 536 ,
585+ "quota_increase" : 80 ,
586+ "period" : "Wrong class strategy." ,
587+ },
588+ {
589+ "type" : "user_limiter" ,
590+ "name" : "Caroline Weaver" ,
591+ "initial_quota" : 31 ,
592+ "quota_increase" : 57 ,
593+ "period" : "Lead boy least base." ,
594+ },
595+ ],
596+ "scheduler" : {
597+ "period" : 960 ,
598+ "database_reconnection_count" : None ,
599+ "database_reconnection_delay" : 336 ,
600+ },
601+ "enable_token_history" : False ,
602+ },
603+ {
604+ "sqlite" : None ,
605+ "postgres" : None ,
606+ "limiters" : [
607+ {
608+ "type" : "user_limiter" ,
609+ "name" : "Kyle Whitehead" ,
610+ "initial_quota" : 998 ,
611+ "quota_increase" : 506 ,
612+ "period" : "Pm recently character deal person." ,
613+ },
614+ {
615+ "type" : "user_limiter" ,
616+ "name" : "Gary Ward" ,
617+ "initial_quota" : 948 ,
618+ "quota_increase" : 349 ,
619+ "period" : "We physical seven follow turn front establish reme" ,
620+ },
621+ ],
622+ "scheduler" : {
623+ "period" : 83 ,
624+ "database_reconnection_count" : 88 ,
625+ "database_reconnection_delay" : None ,
626+ },
627+ "enable_token_history" : True ,
628+ },
629+ {
630+ "sqlite" : None ,
631+ "postgres" : None ,
632+ "limiters" : [
633+ {
634+ "type" : "user_limiter" ,
635+ "name" : "Christopher Flores" ,
636+ "initial_quota" : 589 ,
637+ "quota_increase" : 815 ,
638+ "period" : "Page power would end he stage." ,
639+ }
640+ ],
641+ "scheduler" : {
642+ "period" : None ,
643+ "database_reconnection_count" : 374 ,
644+ "database_reconnection_delay" : 70 ,
645+ },
646+ "enable_token_history" : False ,
647+ },
648+ {
649+ "sqlite" : None ,
650+ "postgres" : None ,
651+ "limiters" : [
652+ {
653+ "type" : "user_limiter" ,
654+ "name" : "Shannon Martin" ,
655+ "initial_quota" : 110 ,
656+ "quota_increase" : 755 ,
657+ "period" : "Case material system career ever these short." ,
658+ },
659+ {
660+ "type" : "user_limiter" ,
661+ "name" : "Gabrielle Meadows" ,
662+ "initial_quota" : 760 ,
663+ "quota_increase" : 55 ,
664+ "period" : "Page serve civil question series purpose." ,
665+ },
666+ {
667+ "type" : "user_limiter" ,
668+ "name" : "Kelly Velasquez" ,
669+ "initial_quota" : 419 ,
670+ "quota_increase" : 633 ,
671+ "period" : "Behavior half loss during pay." ,
672+ },
673+ ],
674+ "scheduler" : {
675+ "period" : 387 ,
676+ "database_reconnection_count" : 216 ,
677+ "database_reconnection_delay" : 894 ,
678+ },
679+ "enable_token_history" : None ,
680+ },
681+ {
682+ "sqlite" : {"db_path" : "Camera agent general always like." },
683+ "postgres" : None ,
684+ "limiters" : [
685+ {
686+ "type" : "user_limiter" ,
687+ "name" : "Bill Boyd" ,
688+ "initial_quota" : 582 ,
689+ "quota_increase" : 84 ,
690+ "period" : "Side no born set. Different weight speak why daugh" ,
691+ }
692+ ],
693+ "scheduler" : None ,
694+ "enable_token_history" : True ,
695+ },
696+ {
697+ "sqlite" : {"db_path" : "Begin remain inside practice ability Mrs." },
698+ "postgres" : {
699+ "host" : "Police stuff black." ,
700+ "port" : None ,
701+ "db" : "Decide history worker can stand." ,
702+ "user" : "Type away organization debate stand." ,
703+ "password" : "@alvNH%qK%47" ,
704+ "namespace" : "Compare gun trip establish key." ,
705+ "ssl_mode" : "disable" ,
706+ "gss_encmode" : "disable" ,
707+ },
708+ "limiters" : [
709+ {
710+ "type" : "user_limiter" ,
711+ "name" : "William Armstrong" ,
712+ "initial_quota" : 305 ,
713+ "quota_increase" : 648 ,
714+ "period" : "Relate couple song way wind rule model." ,
715+ },
716+ {
717+ "type" : "user_limiter" ,
718+ "name" : "Terry Mitchell" ,
719+ "initial_quota" : 206 ,
720+ "quota_increase" : 316 ,
721+ "period" : "Onto within arrive type group. Black none human re" ,
722+ },
723+ {
724+ "type" : "user_limiter" ,
725+ "name" : "Deborah Vazquez" ,
726+ "initial_quota" : 24 ,
727+ "quota_increase" : 24 ,
728+ "period" : "Call close table." ,
729+ },
730+ ],
731+ "scheduler" : {
732+ "period" : 959 ,
733+ "database_reconnection_count" : 125 ,
734+ "database_reconnection_delay" : 94 ,
735+ },
736+ "enable_token_history" : False ,
737+ },
738+ ]
739+
740+
741+ @pytest .mark .parametrize ("config_dict" , incorrect_configurations )
742+ def test_quota_handlers_from_dict_negative_cases (config_dict : dict [str , Any ]) -> None :
743+ """Test the configuration initialization from dictionary with config values."""
744+ with pytest .raises (
745+ ValidationError ,
746+ match = " validation error for QuotaHandlersConfiguration" ,
747+ ):
748+ # try to initialize the app config and load configuration from a Python
749+ # dictionary
750+ QuotaHandlersConfiguration (** config_dict )
0 commit comments