diff --git a/src/routers/institutions.py b/src/routers/institutions.py index 78b5d5b..94721d5 100644 --- a/src/routers/institutions.py +++ b/src/routers/institutions.py @@ -58,6 +58,22 @@ async def get_associated_institutions(request: Request): FinanicialInstitutionAssociationDto( name=institution.name, lei=institution.lei, + tax_id="123456789", + rssd_id=1234, + primary_federal_regulator_id="FRI1", + hmda_institution_type_id="HIT1", + sbl_institution_type_id="SIT1", + hq_address_street_1="Test Address Street 1", + hq_address_street_2="", + hq_address_city="Test City 1", + hq_address_state="TN", + hq_address_zip="00000", + parent_lei="PARENTTESTBANK123", + parent_legal_name="PARENT TEST BANK 123", + parent_rssd_id=12345, + top_holder_lei="TOPHOLDERLEI123", + top_holder_legal_name="TOP HOLDER LEI 123", + top_holder_rssd_id=123456, approved=email_domain in [inst_domain.domain for inst_domain in institution.domains], ) for institution in associated_institutions diff --git a/tests/api/conftest.py b/tests/api/conftest.py index 451ba6b..e242649 100644 --- a/tests/api/conftest.py +++ b/tests/api/conftest.py @@ -55,6 +55,22 @@ def get_institutions_mock(mocker: MockerFixture) -> Mock: name="Test Bank 123", lei="TESTBANK123", domains=[FinancialInstitutionDomainDao(domain="test.bank", lei="TESTBANK123")], + tax_id="123456789", + rssd_id=1234, + primary_federal_regulator_id="FRI1", + hmda_institution_type_id="HIT1", + sbl_institution_type_id="SIT1", + hq_address_street_1="Test Address Street 1", + hq_address_street_2="", + hq_address_city="Test City 1", + hq_address_state="TN", + hq_address_zip="00000", + parent_lei="PARENTTESTBANK123", + parent_legal_name="PARENT TEST BANK 123", + parent_rssd_id=12345, + top_holder_lei="TOPHOLDERLEI123", + top_holder_legal_name="TOP HOLDER LEI 123", + top_holder_rssd_id=123456, ) ] return mock diff --git a/tests/api/routers/test_institutions_api.py b/tests/api/routers/test_institutions_api.py index dd6d706..87db5c2 100644 --- a/tests/api/routers/test_institutions_api.py +++ b/tests/api/routers/test_institutions_api.py @@ -20,11 +20,18 @@ def test_get_institutions_authed( client = TestClient(app_fixture) res = client.get("/v1/institutions/") assert res.status_code == 200 + print(res.status_code) assert res.json()[0].get("name") == "Test Bank 123" def test_create_institution_unauthed(self, app_fixture: FastAPI, unauthed_user_mock: Mock): client = TestClient(app_fixture) - res = client.post("/v1/institutions/", json={"name": "testName", "lei": "testLei"}) + res = client.post( + "/v1/institutions/", + json={ + "name": "testName", + "lei": "testLei", + }, + ) assert res.status_code == 403 def test_create_institution_authed(self, mocker: MockerFixture, app_fixture: FastAPI, authed_user_mock: Mock): @@ -37,7 +44,29 @@ def test_create_institution_authed(self, mocker: MockerFixture, app_fixture: Fas upsert_group_mock = mocker.patch("oauth2.oauth2_admin.OAuth2Admin.upsert_group") upsert_group_mock.return_value = "leiGroup" client = TestClient(app_fixture) - res = client.post("/v1/institutions/", json={"name": "testName", "lei": "testLei"}) + res = client.post( + "/v1/institutions/", + json={ + "name": "testName", + "lei": "testLei", + "tax_id": "123456789", + "ssd_id": 1234, + "primary_federal_regulator_id": "FRI1", + "hmda_institution_type_id": "HIT1", + "sbl_institution_type_id": "SIT1", + "hq_address_street_1": "Test Address Street 1", + "hq_address_street_2": "", + "hq_address_city": "Test City 1", + "hq_address_state": "TN", + "hq_address_zip": "00000", + "parent_lei": "PARENTTESTBANK123", + "parent_legal_name": "PARENT TEST BANK 123", + "parent_rssd_id": 12345, + "top_holder_lei": "TOPHOLDERLEI123", + "top_holder_legal_name": "TOP HOLDER LEI 123", + "top_holder_rssd_id": 123456, + }, + ) assert res.status_code == 200 assert res.json()[1].get("name") == "testName" @@ -68,6 +97,22 @@ def test_get_institution_authed(self, mocker: MockerFixture, app_fixture: FastAP name="Test Bank 123", lei="TESTBANK123", domains=[FinancialInstitutionDomainDao(domain="test.bank", lei="TESTBANK123")], + tax_id="123456789", + rssd_id=1234, + primary_federal_regulator_id="FRI1", + hmda_institution_type_id="HIT1", + sbl_institution_type_id="SIT1", + hq_address_street_1="Test Address Street 1", + hq_address_street_2="", + hq_address_city="Test City 1", + hq_address_state="TN", + hq_address_zip="00000", + parent_lei="PARENTTESTBANK123", + parent_legal_name="PARENT TEST BANK 123", + parent_rssd_id=12345, + top_holder_lei="TOPHOLDERLEI123", + top_holder_legal_name="TOP HOLDER LEI 123", + top_holder_rssd_id=123456, ) client = TestClient(app_fixture) lei_path = "testLeiPath" diff --git a/tests/entities/repos/test_institutions_repo.py b/tests/entities/repos/test_institutions_repo.py index 3b7279a..6e1784e 100644 --- a/tests/entities/repos/test_institutions_repo.py +++ b/tests/entities/repos/test_institutions_repo.py @@ -8,6 +8,10 @@ ) from entities.models import DeniedDomainDao from entities.repos import institutions_repo as repo +from entities.models import FederalRegulatorDao +from entities.models import HMDAInstitutionTypeDao +from entities.models import SBLInstitutionTypeDao +from entities.models import AddressStateDao class TestInstitutionsRepo: @@ -20,10 +24,42 @@ async def setup( name="Test Bank 123", lei="TESTBANK123", domains=[FinancialInstitutionDomainDao(domain="test.bank.1", lei="TESTBANK123")], + tax_id="123456789", + rssd_id=1234, + primary_federal_regulator_id=FederalRegulatorDao(id="FRI1", name="Test Federal Regulator ID 1").id, + hmda_institution_type_id=HMDAInstitutionTypeDao(id="HIT1", name="Test HMDA Instituion ID 1").id, + sbl_institution_type_id=SBLInstitutionTypeDao(id="SIT1", name="Test SBL Instituion ID 1").id, + hq_address_street_1="Test Address Street 1", + hq_address_street_2="", + hq_address_city="Test City 1", + hq_address_state=AddressStateDao(code="TN", name="Tennessee").code, + hq_address_zip="00000", + parent_lei="PARENTTESTBANK123", + parent_legal_name="PARENT TEST BANK 123", + parent_rssd_id=12345, + top_holder_lei="TOPHOLDERLEI123", + top_holder_legal_name="TOP HOLDER LEI 123", + top_holder_rssd_id=123456, ), FinancialInstitutionDao( name="Test Bank 456", lei="TESTBANK456", domains=[FinancialInstitutionDomainDao(domain="test.bank.2", lei="TESTBANK456")], + tax_id="987654321", + rssd_id=4321, + primary_federal_regulator_id=FederalRegulatorDao(id="FRI2", name="Test Federal Regulator ID 2").id, + hmda_institution_type_id=HMDAInstitutionTypeDao(id="HIT2", name="Test HMDA Instituion ID 2").id, + sbl_institution_type_id=SBLInstitutionTypeDao(id="SIT2", name="Test SBL Instituion ID 2").id, + hq_address_street_1="Test Address Street 2", + hq_address_street_2="", + hq_address_city="Test City 2", + hq_address_state=AddressStateDao(code="TX", name="Texas").code, + hq_address_zip="11111", + parent_lei="PARENTTESTBANK456", + parent_legal_name="PARENT TEST BANK 456", + parent_rssd_id=54321, + top_holder_lei="TOPHOLDERLEI456", + top_holder_legal_name="TOP HOLDER LEI 456", + top_holder_rssd_id=654321, ) transaction_session.add(fi_dao_123) transaction_session.add(fi_dao_456) @@ -52,7 +88,26 @@ async def test_get_institutions_by_lei_list_item_not_existing(self, query_sessio async def test_add_institution(self, transaction_session: AsyncSession): await repo.upsert_institution( transaction_session, - FinancialInstitutionDao(name="New Bank 123", lei="NEWBANK123"), + FinancialInstitutionDao( + name="New Bank 123", + lei="NEWBANK123", + tax_id="654321987", + rssd_id=6543, + primary_federal_regulator_id=FederalRegulatorDao(id="FRI3", name="Test Federal Regulator ID 3").id, + hmda_institution_type_id=HMDAInstitutionTypeDao(id="HIT3", name="Test HMDA Instituion ID 3").id, + sbl_institution_type_id=SBLInstitutionTypeDao(id="SIT3", name="Test SBL Instituion ID 3").id, + hq_address_street_1="Test Address Street 3", + hq_address_street_2="", + hq_address_city="Test City 3", + hq_address_state=AddressStateDao(code="CA", name="California").code, + hq_address_zip="22222", + parent_lei="PARENTNEWBANK123", + parent_legal_name="PARENT NEW BANK 123", + parent_rssd_id=76543, + top_holder_lei="TOPHOLDERNEWBANKLEI123", + top_holder_legal_name="TOP HOLDER NEW BANK LEI 123", + top_holder_rssd_id=876543, + ), ) res = await repo.get_institutions(transaction_session) assert len(res) == 3