diff --git a/src/entities/repos/institutions_repo.py b/src/entities/repos/institutions_repo.py index b4820e5..8605ce6 100644 --- a/src/entities/repos/institutions_repo.py +++ b/src/entities/repos/institutions_repo.py @@ -27,7 +27,7 @@ async def get_institutions( .limit(count) .offset(page * count) ) - if leis: + if leis is not None: stmt = stmt.filter(FinancialInstitutionDao.lei.in_(leis)) elif d := domain.strip(): search = "%{}%".format(d) diff --git a/tests/api/routers/test_institutions_api.py b/tests/api/routers/test_institutions_api.py index 3af621f..dd6d706 100644 --- a/tests/api/routers/test_institutions_api.py +++ b/tests/api/routers/test_institutions_api.py @@ -172,3 +172,24 @@ def test_get_associated_institutions( inst2 = next(filter(lambda inst: inst["lei"] == "TESTBANK234", data)) assert inst1["approved"] is False assert inst2["approved"] is True + + def test_get_associated_institutions_with_no_institutions( + self, app_fixture: FastAPI, auth_mock: Mock, get_institutions_mock: Mock + ): + get_institutions_mock.return_value = [] + claims = { + "name": "test", + "preferred_username": "test_user", + "email": "test@test234.bank", + "sub": "testuser123", + "institutions": [], + } + auth_mock.return_value = ( + AuthCredentials(["authenticated"]), + AuthenticatedUser.from_claim(claims), + ) + client = TestClient(app_fixture) + res = client.get("/v1/institutions/associated") + assert res.status_code == 200 + get_institutions_mock.assert_called_once_with(ANY, []) + assert res.json() == []