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/src/routers/institutions.py b/src/routers/institutions.py index 2ef1297..78b5d5b 100644 --- a/src/routers/institutions.py +++ b/src/routers/institutions.py @@ -53,8 +53,6 @@ async def create_institution( async def get_associated_institutions(request: Request): user: AuthenticatedUser = request.user email_domain = get_email_domain(user.email) - if not user.institutions: - return [] associated_institutions = await repo.get_institutions(request.state.db_session, user.institutions) return [ FinanicialInstitutionAssociationDto( diff --git a/tests/api/routers/test_institutions_api.py b/tests/api/routers/test_institutions_api.py index 3fe1bcd..dd6d706 100644 --- a/tests/api/routers/test_institutions_api.py +++ b/tests/api/routers/test_institutions_api.py @@ -176,7 +176,7 @@ def test_get_associated_institutions( def test_get_associated_institutions_with_no_institutions( self, app_fixture: FastAPI, auth_mock: Mock, get_institutions_mock: Mock ): - get_institutions_mock.return_value = None + get_institutions_mock.return_value = [] claims = { "name": "test", "preferred_username": "test_user", @@ -191,5 +191,5 @@ def test_get_associated_institutions_with_no_institutions( client = TestClient(app_fixture) res = client.get("/v1/institutions/associated") assert res.status_code == 200 - get_institutions_mock.assert_not_called() + get_institutions_mock.assert_called_once_with(ANY, []) assert res.json() == []