diff --git a/tests/conftest.py b/tests/conftest.py index 7ebff10..2ce67d6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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 diff --git a/tests/unit/test_api_banks.py b/tests/unit/test_api_banks.py index f3f97cd..1e08456 100644 --- a/tests/unit/test_api_banks.py +++ b/tests/unit/test_api_banks.py @@ -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): diff --git a/tests/unit/test_api_client.py b/tests/unit/test_api_client.py index ce61d40..8a36689 100644 --- a/tests/unit/test_api_client.py +++ b/tests/unit/test_api_client.py @@ -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", }