-
Notifications
You must be signed in to change notification settings - Fork 2
Capturing error in Barte "refund_transaction" #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Capturing error in Barte "refund_transaction" #35
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds explicit error handling for refund operations and introduces tests to validate the new behavior when the API returns an error response.
- Add BarteError raising on refund endpoints when the API returns an errors payload
- Ensure partial_refund_charge checks for dict response before error inspection (success is a list)
- Add tests and a fixture to validate error handling for refund and partial refund
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| barte/client.py | Adds error handling for refund_charge and partial_refund_charge by detecting "errors" in the API response and raising BarteError. |
| tests/test_client.py | Adds a refund error fixture and two tests asserting BarteError is raised for refund and partial refund error responses. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
avelino
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, PR resolve o problema proposto
porem podemos melhorar com as sugestões que trouxe aqui
Modificações no client.py
refund_charge(linhas 170-182): Adicionada verificação de erro que lançaBarteErrorpartial_refund_charge(linhas 184-199): Adicionada verificação de erro comisinstance(json_response, dict)antes de verificar "errors" (necessário porque o sucesso retorna uma lista)Novos testes no test_client.py
mock_refund_error_response(linhas 106-121): Resposta de erro para refundstest_refund_charge_with_error(linhas 726-739): Testa que refund_charge lançaBarteErrortest_partial_refund_charge_with_error(linhas 741-756): Testa quepartial_refund_chargelançaBarteError