diff --git a/db_revisions/versions/2ad66aaf4583_add_hq_address_state_3_and_4_to_financial_institutions_table.py b/db_revisions/versions/2ad66aaf4583_add_hq_address_state_3_and_4_to_financial_institutions_table.py new file mode 100644 index 0000000..13ddfad --- /dev/null +++ b/db_revisions/versions/2ad66aaf4583_add_hq_address_state_3_and_4_to_financial_institutions_table.py @@ -0,0 +1,31 @@ +"""add hq_address_state_3 and hq_address_state_3 fields to financial_institutions table + +Revision ID: 2ad66aaf4583 +Revises: d6e4a13fbebd +Create Date: 2024-04-09 00:17:23.263719 + +""" + +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = "2ad66aaf4583" +down_revision: Union[str, None] = "d6e4a13fbebd" +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + with op.batch_alter_table("financial_institutions") as batch_op: + batch_op.add_column(sa.Column("hq_address_street_3", sa.String, nullable=True)) + batch_op.add_column(sa.Column("hq_address_street_4", sa.String, nullable=True)) + + +def downgrade() -> None: + with op.batch_alter_table("financial_institutions") as batch_op: + batch_op.drop_column("hq_address_street_3") + batch_op.drop_column("hq_address_street_4") diff --git a/src/regtech_user_fi_management/entities/models/dao.py b/src/regtech_user_fi_management/entities/models/dao.py index e8060af..0ccddc0 100644 --- a/src/regtech_user_fi_management/entities/models/dao.py +++ b/src/regtech_user_fi_management/entities/models/dao.py @@ -55,6 +55,8 @@ class FinancialInstitutionDao(AuditMixin, Base): sbl_institution_types: Mapped[List[SblTypeMappingDao]] = relationship(lazy="selectin", cascade="all, delete-orphan") hq_address_street_1: Mapped[str] hq_address_street_2: Mapped[str] = mapped_column(nullable=True) + hq_address_street_3: Mapped[str] = mapped_column(nullable=True) + hq_address_street_4: Mapped[str] = mapped_column(nullable=True) hq_address_city: Mapped[str] hq_address_state_code: Mapped[str] = mapped_column(ForeignKey("address_state.code")) hq_address_state: Mapped["AddressStateDao"] = relationship(lazy="selectin") diff --git a/src/regtech_user_fi_management/entities/models/dto.py b/src/regtech_user_fi_management/entities/models/dto.py index 4b61607..911ee32 100644 --- a/src/regtech_user_fi_management/entities/models/dto.py +++ b/src/regtech_user_fi_management/entities/models/dto.py @@ -67,6 +67,8 @@ class FinancialInstitutionDto(FinancialInstitutionBase): sbl_institution_types: List[SblTypeAssociationDto | str] = [] hq_address_street_1: str hq_address_street_2: str | None = None + hq_address_street_3: str | None = None + hq_address_street_4: str | None = None hq_address_city: str hq_address_state_code: str hq_address_zip: str diff --git a/tests/api/conftest.py b/tests/api/conftest.py index 906093d..71c861f 100644 --- a/tests/api/conftest.py +++ b/tests/api/conftest.py @@ -73,6 +73,8 @@ def get_institutions_mock(mocker: MockerFixture, authed_user_mock: Mock) -> Mock sbl_institution_types=[SblTypeMappingDao(sbl_type=SBLInstitutionTypeDao(id="SIT1", name="SIT1"))], hq_address_street_1="Test Address Street 1", hq_address_street_2="", + hq_address_street_3="", + hq_address_street_4="", hq_address_city="Test City 1", hq_address_state_code="GA", hq_address_state=AddressStateDao(code="GA", name="Georgia"), diff --git a/tests/api/routers/test_institutions_api.py b/tests/api/routers/test_institutions_api.py index 5590892..555882a 100644 --- a/tests/api/routers/test_institutions_api.py +++ b/tests/api/routers/test_institutions_api.py @@ -72,6 +72,8 @@ def test_invalid_tax_id(self, mocker: MockerFixture, app_fixture: FastAPI, authe "sbl_institution_type_ids": ["SIT2"], "hq_address_street_1": "Test Address Street 1", "hq_address_street_2": "", + "hq_address_street_3": "", + "hq_address_street_4": "", "hq_address_city": "Test City 1", "hq_address_state_code": "VA", "hq_address_zip": "00000", @@ -104,6 +106,8 @@ def test_invalid_lei(self, mocker: MockerFixture, app_fixture: FastAPI, authed_u "sbl_institution_type_ids": ["SIT2"], "hq_address_street_1": "Test Address Street 1", "hq_address_street_2": "", + "hq_address_street_3": "", + "hq_address_street_4": "", "hq_address_city": "Test City 1", "hq_address_state_code": "VA", "hq_address_zip": "00000", @@ -140,6 +144,8 @@ def test_create_institution_authed(self, mocker: MockerFixture, app_fixture: Fas sbl_institution_types=[SblTypeMappingDao(sbl_type=SBLInstitutionTypeDao(id="SIT2", name="SIT2"))], hq_address_street_1="Test Address Street 1", hq_address_street_2="", + hq_address_street_3="", + hq_address_street_4="", hq_address_city="Test City 1", hq_address_state_code="VA", hq_address_state=AddressStateDao(code="VA", name="Virginia"), @@ -167,6 +173,8 @@ def test_create_institution_authed(self, mocker: MockerFixture, app_fixture: Fas "sbl_institution_type_ids": ["SIT2"], "hq_address_street_1": "Test Address Street 1", "hq_address_street_2": "", + "hq_address_street_3": "", + "hq_address_street_4": "", "hq_address_city": "Test City 1", "hq_address_state_code": "VA", "hq_address_zip": "00000", @@ -277,6 +285,8 @@ def test_create_institution_authed_no_permission(self, app_fixture: FastAPI, aut "sbl_institution_type_ids": ["SIT2"], "hq_address_street_1": "Test Address Street 1", "hq_address_street_2": "", + "hq_address_street_3": "", + "hq_address_street_4": "", "hq_address_city": "Test City 1", "hq_address_state_code": "VA", "hq_address_zip": "00000", @@ -314,6 +324,8 @@ def test_get_institution_authed(self, mocker: MockerFixture, app_fixture: FastAP sbl_institution_types=[SblTypeMappingDao(sbl_type=SBLInstitutionTypeDao(id="SIT1", name="SIT1"))], hq_address_street_1="Test Address Street 1", hq_address_street_2="", + hq_address_street_3="", + hq_address_street_4="", hq_address_city="Test City 1", hq_address_state_code="GA", hq_address_state=AddressStateDao(code="GA", name="Georgia"), @@ -415,6 +427,8 @@ def test_get_associated_institutions( sbl_institution_types=[SblTypeMappingDao(sbl_type=SBLInstitutionTypeDao(id="SIT1", name="SIT1"))], hq_address_street_1="Test Address Street 1", hq_address_street_2="", + hq_address_street_3="", + hq_address_street_4="", hq_address_city="Test City 1", hq_address_state_code="GA", hq_address_state=AddressStateDao(code="GA", name="Georgia"), @@ -440,6 +454,8 @@ def test_get_associated_institutions( sbl_institution_types=[SblTypeMappingDao(sbl_type=SBLInstitutionTypeDao(id="SIT1", name="SIT1"))], hq_address_street_1="Test Address Street 2", hq_address_street_2="", + hq_address_street_3="", + hq_address_street_4="", hq_address_city="Test City 2", hq_address_state_code="GA", hq_address_state=AddressStateDao(code="GA", name="Georgia"), @@ -543,6 +559,8 @@ def test_get_sbl_types(self, mocker: MockerFixture, app_fixture: FastAPI, authed sbl_institution_types=[SblTypeMappingDao(sbl_type=SBLInstitutionTypeDao(id="SIT1", name="SIT1"))], hq_address_street_1="Test Address Street 1", hq_address_street_2="", + hq_address_street_3="", + hq_address_street_4="", hq_address_city="Test City 1", hq_address_state_code="GA", hq_address_state=AddressStateDao(code="GA", name="Georgia"), diff --git a/tests/entities/repos/test_institutions_repo.py b/tests/entities/repos/test_institutions_repo.py index c54921b..524e775 100644 --- a/tests/entities/repos/test_institutions_repo.py +++ b/tests/entities/repos/test_institutions_repo.py @@ -62,6 +62,8 @@ async def setup( sbl_institution_types=[SblTypeMappingDao(sbl_type=sbl_it_dao_sit1, modified_by="test_user_id")], hq_address_street_1="Test Address Street 1", hq_address_street_2="", + hq_address_street_3="", + hq_address_street_4="", hq_address_city="Test City 1", hq_address_state_code="GA", hq_address_zip="00000", @@ -85,6 +87,8 @@ async def setup( sbl_institution_types=[SblTypeMappingDao(sbl_type=sbl_it_dao_sit2, modified_by="test_user_id")], hq_address_street_1="Test Address Street 2", hq_address_street_2="", + hq_address_street_3="", + hq_address_street_4="", hq_address_city="Test City 2", hq_address_state_code="CA", hq_address_zip="11111", @@ -110,6 +114,8 @@ async def setup( ], hq_address_street_1="Test Address Street 3", hq_address_street_2="", + hq_address_street_3="", + hq_address_street_4="", hq_address_city="Test City 3", hq_address_state_code="FL", hq_address_zip="11111", @@ -213,6 +219,8 @@ async def test_add_institution(self, transaction_session: AsyncSession): sbl_institution_types=[SblTypeAssociationDto(id="1")], hq_address_street_1="Test Address Street 3", hq_address_street_2="", + hq_address_street_3="", + hq_address_street_4="", hq_address_city="Test City 3", hq_address_state_code="FL", hq_address_zip="22222", diff --git a/tests/entities/test_listeners.py b/tests/entities/test_listeners.py index 60aec26..a337342 100644 --- a/tests/entities/test_listeners.py +++ b/tests/entities/test_listeners.py @@ -32,6 +32,8 @@ class TestListeners: sbl_institution_types=[SblTypeMappingDao(sbl_type=SBLInstitutionTypeDao(id="SIT1", name="SIT1"))], hq_address_street_1="Test Address Street 1", hq_address_street_2="", + hq_address_street_3="", + hq_address_street_4="", hq_address_city="Test City 1", hq_address_state_code="GA", hq_address_zip="00000", diff --git a/tests/migrations/test_migrations.py b/tests/migrations/test_migrations.py index d92ffbf..81377db 100644 --- a/tests/migrations/test_migrations.py +++ b/tests/migrations/test_migrations.py @@ -58,3 +58,12 @@ def test_fi_history_tables_0e520c01fb42(alembic_runner: MigrationContext, alembi tax_column = [c for c in inspector.get_columns("financial_institutions_history") if c["name"] == "tax_id"][0] assert tax_column["type"].length == 10 + + +def test_migration_to_2ad66aaf4583(alembic_runner: MigrationContext, alembic_engine: Engine): + alembic_runner.migrate_up_to("2ad66aaf4583") + + inspector = sqlalchemy.inspect(alembic_engine) + + assert "hq_address_street_3" in [c["name"] for c in inspector.get_columns("financial_institutions")] + assert "hq_address_street_4" in [c["name"] for c in inspector.get_columns("financial_institutions")]