fix(api): Fix banks API test fixtures to match GoCardless response format.

Updated test fixtures to correctly mock GoCardless API response format
with "results" key for institutions data. Fixed API client test to use
processed institutions data instead of raw GoCardless format.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Elisiário Couto
2025-09-24 20:04:44 +01:00
parent b9ca74e7e6
commit 24792744f9
3 changed files with 23 additions and 18 deletions

View File

@@ -103,22 +103,24 @@ def mock_db_path(temp_db_path):
@pytest.fixture
def sample_bank_data():
"""Sample bank/institution data for testing."""
return [
{
"id": "REVOLUT_REVOLT21",
"name": "Revolut",
"bic": "REVOLT21",
"transaction_total_days": 90,
"countries": ["GB", "LT"],
},
{
"id": "BANCOBPI_BBPIPTPL",
"name": "Banco BPI",
"bic": "BBPIPTPL",
"transaction_total_days": 90,
"countries": ["PT"],
},
]
return {
"results": [
{
"id": "REVOLUT_REVOLT21",
"name": "Revolut",
"bic": "REVOLT21",
"transaction_total_days": 90,
"countries": ["GB", "LT"],
},
{
"id": "BANCOBPI_BBPIPTPL",
"name": "Banco BPI",
"bic": "BBPIPTPL",
"transaction_total_days": 90,
"countries": ["PT"],
},
]
}
@pytest.fixture

View File

@@ -50,7 +50,7 @@ class TestBanksAPI:
# Mock empty institutions response for invalid country
respx.get("https://bankaccountdata.gocardless.com/api/v2/institutions/").mock(
return_value=httpx.Response(200, json=[])
return_value=httpx.Response(200, json={"results": []})
)
with patch("leggen.utils.config.config", mock_config):

View File

@@ -37,9 +37,12 @@ class TestLeggenAPIClient:
"""Test getting institutions via API client."""
client = LeggenAPIClient("http://localhost:8000")
# The API returns processed institutions, not raw GoCardless data
processed_institutions = sample_bank_data["results"]
api_response = {
"success": True,
"data": sample_bank_data,
"data": processed_institutions,
"message": "Found 2 institutions for PT",
}