Skip to content

Commit

Permalink
feat: add remove_bank function to manage bank entries
Browse files Browse the repository at this point in the history
  • Loading branch information
gabino committed Dec 23, 2024
1 parent 4eb15b9 commit d84ee8a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions clabe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'get_bank_name',
'validate_clabe',
'configure_additional_bank',
'remove_bank',
]

from .banks import BANK_NAMES, BANKS
Expand All @@ -17,6 +18,7 @@
configure_additional_bank,
generate_new_clabes,
get_bank_name,
remove_bank,
validate_clabe,
)
from .version import __version__
15 changes: 15 additions & 0 deletions clabe/validations.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,18 @@ def configure_additional_bank(bank_code_banxico: str, bank_name: str) -> None:
)
BANKS[request.bank_code_abm] = request.bank_code_banxico
BANK_NAMES[request.bank_code_banxico] = request.bank_name


def remove_bank(bank_code_banxico: str) -> None:
bank_code_abm = next(
(
abm
for abm, banxico in BANKS.items()
if banxico == bank_code_banxico
),
None,
)

if bank_code_abm:
BANKS.pop(bank_code_abm)
BANK_NAMES.pop(bank_code_banxico)
7 changes: 7 additions & 0 deletions tests/test_clabe.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
configure_additional_bank,
generate_new_clabes,
get_bank_name,
remove_bank,
validate_clabe,
)

Expand Down Expand Up @@ -64,3 +65,9 @@ def test_configure_additional_bank_success(abm_code, banxico_code, name):
def test_configure_additional_bank_invalid_inputs(banxico_code, name):
with pytest.raises(ValueError):
configure_additional_bank(banxico_code, name)


def test_remove_bank():
remove_bank('40138')
with pytest.raises(ValueError):
get_bank_name('138')

0 comments on commit d84ee8a

Please sign in to comment.