Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ticket 133: added optional hq_address_street_3 and hq_address_street_… #134

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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")
2 changes: 2 additions & 0 deletions src/regtech_user_fi_management/entities/models/dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions src/regtech_user_fi_management/entities/models/dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/api/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
18 changes: 18 additions & 0 deletions tests/api/routers/test_institutions_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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"),
Expand All @@ -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"),
Expand Down Expand Up @@ -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"),
Expand Down
8 changes: 8 additions & 0 deletions tests/entities/repos/test_institutions_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions tests/entities/test_listeners.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 9 additions & 0 deletions tests/migrations/test_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Loading