Skip to content

Conversation

@mdcg-buser
Copy link
Contributor

Modificações no client.py

  • refund_charge (linhas 170-182): Adicionada verificação de erro que lança BarteError
  • partial_refund_charge (linhas 184-199): Adicionada verificação de erro com isinstance(json_response, dict) antes de verificar "errors" (necessário porque o sucesso retorna uma lista)

Novos testes no test_client.py

  • Fixture mock_refund_error_response (linhas 106-121): Resposta de erro para refunds
  • test_refund_charge_with_error (linhas 726-739): Testa que refund_charge lança BarteError
  • test_partial_refund_charge_with_error (linhas 741-756): Testa que partial_refund_charge lança BarteError

@CLAassistant
Copy link

CLAassistant commented Nov 26, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

Copilot AI left a 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.

Copy link
Member

@avelino avelino left a 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

@avelino avelino merged commit 48baca4 into buserbrasil:main Nov 26, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants