Skip to content

Commit

Permalink
Fixed issue with empty state field in DTO (#237)
Browse files Browse the repository at this point in the history
Closes #236 

Fixed an issue with empty state codes failing on sending an associated
DTO back.

---------

Co-authored-by: Hans Keeler <[email protected]>
  • Loading branch information
jcadam14 and hkeeler authored Oct 1, 2024
1 parent b4a9f92 commit e0b1a08
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/regtech_user_fi_management/entities/models/dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class FinancialInstitutionWithRelationsDto(FinancialInstitutionDto):
primary_federal_regulator: FederalRegulatorDto | None = None
hmda_institution_type: InstitutionTypeDto | None = None
sbl_institution_types: List[SblTypeAssociationDetailsDto] = []
hq_address_state: AddressStateDto
hq_address_state: AddressStateDto | None = None
domains: List[FinancialInsitutionDomainDto] = []


Expand Down
29 changes: 29 additions & 0 deletions tests/api/routers/test_institutions_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,35 @@ def test_create_institution_authed(self, mocker: MockerFixture, app_fixture: Fas
assert res.status_code == 200
assert res.json()[1].get("name") == "testName"

def test_empty_state_field(self, mocker: MockerFixture, app_fixture: FastAPI, authed_user_mock: Mock):
upsert_institution_mock = mocker.patch(
"regtech_user_fi_management.entities.repos.institutions_repo.upsert_institution"
)
upsert_institution_mock.return_value = FinancialInstitutionDao(
name="testName",
lei="1234567890ABCDEFGH00",
is_active=True,
hq_address_street_1="Test Address Street 1",
hq_address_city="Test City 1",
hq_address_zip="00000",
)
upsert_group_mock = mocker.patch("regtech_api_commons.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": "1234567890ABCDEFGH00",
"is_active": True,
"hq_address_street_1": "Test Address Street 1",
"hq_address_city": "Test City 1",
"hq_address_zip": "00000",
},
)
assert res.status_code == 200
assert res.json()[1].get("hq_address_state") is None

def test_create_institution_only_required_fields(
self, mocker: MockerFixture, app_fixture: FastAPI, authed_user_mock: Mock
):
Expand Down

0 comments on commit e0b1a08

Please sign in to comment.