From 4f8cd133df00837d233ab9b100e8523cdeef0560 Mon Sep 17 00:00:00 2001 From: Tatiana Date: Sat, 23 Nov 2024 23:59:54 -0300 Subject: [PATCH] Fix and update all withdrawal tests: handle balance, limit checks, and error messages --- __pycache__/sistema_bancario.cpython-312.pyc | Bin 5547 -> 4322 bytes tests/test_sistema_bancario.py | 117 +++++++++++++------ 2 files changed, 79 insertions(+), 38 deletions(-) diff --git a/__pycache__/sistema_bancario.cpython-312.pyc b/__pycache__/sistema_bancario.cpython-312.pyc index ca09e86f84f99033e25622b039fa89642dec926a..4a06b29fc981138278f392087a9826c18351ada2 100644 GIT binary patch literal 4322 zcmb_fU2NOd6(%K8q9p3aw%p3jj~P2ot0qyL*lru=*Qu4pi0h>O3EIq=z?!td*b)_z z3KBsAykY~KG{98MLtF$MT=Zcs{9<4jknJg$UkYpwOeA-zpoakKORyKgZeRSgbFWB= zPF*DEdI27ihv%Nld+zt0bMHUBUN-^lzrQ&*z04BCf6$BBY{tXp1$ekm2*huRtAs#; zBn2Btn_vfN7buXFK!c8b5_k8Zj0?v?l3nHy}b5^(ZR7x7X2~M zkM_Sm9<}JYK^OgCY@~miWe>I-9I<-cHrx&`7N=j4B|51{3GFLl6U}bx+GO9vxGE~@ zgvM(UKXF-+rxiZVPx3N)zAkFAIx#SKDKq6y3|ePx8Jl360p2TK4SA^A+0E}Hks(Im%GlB{e3r);Q0JGe_`ivYA^U0Oiam2T;yc#CO<1HoFH=mg0;UO6!dY=&?r9y zKwQCJrNqs(FJ>h{j--%sz_f%u+{k`z%N{v4we>2ei2SUS=E2vb9Ou;3q^PQLButg) zsacuVO0<+nrZj~D7bORuOo|C1Y%kF&KP$*3mkC0(#MB;9{2=31A=_a1S7PROr3Jq4 zgG;>z0toF7E{yBDPUM?U=KZJUE)<>q+|iG-WyY%qxB}B&aT9FA+)%|yxO}Dy{Bhxw;XWgec7xa&5AVwDcMPM*aZ5jKHIHl^nE&u6)k=%e&&o-PIGYhlBsSb$t zkQA3R5n&C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(f"Limite de R$ {LIMITE_SAQUE}.00 por saque.") + return saldo, saque_diario, saques - LIMITE_SAQUE = 3 - saldo = 200 - saque_diario = 0 - saques = [] - novo_saldo, novo_saque_diario = realizar_saque(LIMITE_SAQUE, saldo, saque_diario, saques) + # Verifica se o saque não ultrapassa o limite de saques diários + if saque_diario >= LIMITE_SAQUES_DIARIOS: + print("Limite de saques diários atingido.") + return saldo, saque_diario, saques + + # Verifica se o saldo é suficiente + if saque > saldo: + print("Saldo insuficiente") + return saldo, saque_diario, saques + + # Atualiza saldo e saques + saldo -= saque + saque_diario += 1 + saques.append(saque) + return saldo, saque_diario, saques - assert novo_saldo == 200 - assert novo_saque_diario == 0 - assert saques == [] + # Chamada à função + novo_saldo, novo_saque_diario, saques_atualizados = realizar_saque(LIMITE_SAQUE, saldo, saque_diario, saques) + + # Validação dos resultados + assert novo_saldo == saldo_esperado + assert novo_saque_diario == saque_diario_esperado + assert saques_atualizados == saques_esperados + + # Captura de saída para verificar mensagens + captured = capsys.readouterr() + assert mensagem_esperada in captured.out # Teste para exibir_extrato -def test_exibir_extrato(capsys): +def test_exibir_extrato(capsys, setup_conta): saldo = 700 saques = [300] depositos = [200, 300] + exibir_extrato(saldo, saques, depositos) captured = capsys.readouterr() @@ -65,3 +105,4 @@ def test_exibir_extrato(capsys): assert "2º depósito: R$ 300.00" in captured.out assert "1º saque: R$ 300.00" in captured.out assert "Saldo: R$ 700.00" in captured.out +