mirror of
https://github.com/elisiariocouto/leggen.git
synced 2025-12-13 12:32:18 +00:00
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:
@@ -103,22 +103,24 @@ def mock_db_path(temp_db_path):
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def sample_bank_data():
|
def sample_bank_data():
|
||||||
"""Sample bank/institution data for testing."""
|
"""Sample bank/institution data for testing."""
|
||||||
return [
|
return {
|
||||||
{
|
"results": [
|
||||||
"id": "REVOLUT_REVOLT21",
|
{
|
||||||
"name": "Revolut",
|
"id": "REVOLUT_REVOLT21",
|
||||||
"bic": "REVOLT21",
|
"name": "Revolut",
|
||||||
"transaction_total_days": 90,
|
"bic": "REVOLT21",
|
||||||
"countries": ["GB", "LT"],
|
"transaction_total_days": 90,
|
||||||
},
|
"countries": ["GB", "LT"],
|
||||||
{
|
},
|
||||||
"id": "BANCOBPI_BBPIPTPL",
|
{
|
||||||
"name": "Banco BPI",
|
"id": "BANCOBPI_BBPIPTPL",
|
||||||
"bic": "BBPIPTPL",
|
"name": "Banco BPI",
|
||||||
"transaction_total_days": 90,
|
"bic": "BBPIPTPL",
|
||||||
"countries": ["PT"],
|
"transaction_total_days": 90,
|
||||||
},
|
"countries": ["PT"],
|
||||||
]
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class TestBanksAPI:
|
|||||||
|
|
||||||
# Mock empty institutions response for invalid country
|
# Mock empty institutions response for invalid country
|
||||||
respx.get("https://bankaccountdata.gocardless.com/api/v2/institutions/").mock(
|
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):
|
with patch("leggen.utils.config.config", mock_config):
|
||||||
|
|||||||
@@ -37,9 +37,12 @@ class TestLeggenAPIClient:
|
|||||||
"""Test getting institutions via API client."""
|
"""Test getting institutions via API client."""
|
||||||
client = LeggenAPIClient("http://localhost:8000")
|
client = LeggenAPIClient("http://localhost:8000")
|
||||||
|
|
||||||
|
# The API returns processed institutions, not raw GoCardless data
|
||||||
|
processed_institutions = sample_bank_data["results"]
|
||||||
|
|
||||||
api_response = {
|
api_response = {
|
||||||
"success": True,
|
"success": True,
|
||||||
"data": sample_bank_data,
|
"data": processed_institutions,
|
||||||
"message": "Found 2 institutions for PT",
|
"message": "Found 2 institutions for PT",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user