File tree Expand file tree Collapse file tree 2 files changed +32
-3
lines changed
Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change 11import random
22from typing import List , Union
33
4+ from pydantic .errors import NotDigitError
5+
46from .banks import BANK_NAMES , BANKS
57from .errors import (
68 BankCodeABMAlreadyExistsError ,
@@ -83,12 +85,26 @@ def configure_additional_bank(
8385 already exists in the provided dictionaries.
8486 """
8587
88+ if not all (
89+ isinstance (x , str )
90+ for x in [bank_code_abm , bank_code_banxico , bank_name ]
91+ ):
92+ raise TypeError ("All parameters must be strings" )
93+
94+ if not bank_code_abm .isdigit ():
95+ raise NotDigitError
96+
97+ if not bank_code_banxico .isdigit ():
98+ raise NotDigitError
99+
100+ if not bank_name .strip ():
101+ raise ValueError ("bank_name cannot be empty" )
102+
86103 if bank_code_abm in BANKS :
87104 raise BankCodeABMAlreadyExistsError
88105
89106 if bank_code_banxico in BANK_NAMES :
90107 raise BankCodeBanxicoAlreadyExistsError
91108
92- BANKS .update ({bank_code_abm : bank_code_banxico })
93-
94- BANK_NAMES .update ({bank_code_banxico : bank_name })
109+ BANKS [bank_code_abm ] = bank_code_banxico
110+ BANK_NAMES [bank_code_banxico ] = bank_name .strip ()
Original file line number Diff line number Diff line change @@ -56,3 +56,16 @@ def test_configure_additional_bank_existing_abm_code():
5656def test_configure_additional_bank_existing_banxico_code ():
5757 with pytest .raises (BankCodeBanxicoAlreadyExistsError ):
5858 configure_additional_bank ("666" , "40137" , "New Bank" )
59+
60+
61+ def test_configure_additional_bank_invalid_inputs ():
62+ with pytest .raises (TypeError ):
63+ configure_additional_bank (3 , 3 , 3 )
64+ with pytest .raises (ValueError ):
65+ configure_additional_bank ("A" , "B" , "C" )
66+ with pytest .raises (ValueError ):
67+ configure_additional_bank ("666" , "B" , "C" )
68+ with pytest .raises (ValueError ):
69+ configure_additional_bank ("777" , "713" , "" )
70+ with pytest .raises (ValueError ):
71+ configure_additional_bank ("abc" , "def" , "Test Bank" )
You can’t perform that action at this time.
0 commit comments