Skip to content

Commit

Permalink
Address the comment by moving the seed data from config.py to db_revi…
Browse files Browse the repository at this point in the history
…sions/seed.py; renamed filenames and functions names that had 'feed' to 'seed'
  • Loading branch information
Nargis Sultani committed Dec 21, 2023
1 parent b570fd6 commit f96e709
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 144 deletions.
Empty file added db_revisions/__init__.py
Empty file.
119 changes: 119 additions & 0 deletions db_revisions/seed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
"""
START seed data for the lookup tables:
address_state
federal_regulator
hmda_institution_type
sbl_institution_type
These are accessed in db_revisions/versions/* scripts and in test/migrations/test_lookup_tables_data_feed .
"""

address_state_seed = [
{"code": "AL", "name": "Alabama"},
{"code": "AK", "name": "Alaska"},
{"code": "AZ", "name": "Arizona"},
{"code": "AR", "name": "Arkansas"},
{"code": "CA", "name": "California"},
{"code": "CO", "name": "Colorado"},
{"code": "CT", "name": "Connecticut"},
{"code": "DE", "name": "Delaware"},
{"code": "FL", "name": "Florida"},
{"code": "GA", "name": "Georgia"},
{"code": "HI", "name": "Hawaii"},
{"code": "ID", "name": "Idaho"},
{"code": "IL", "name": "Illinois"},
{"code": "IN", "name": "Indiana"},
{"code": "IA", "name": "Iowa"},
{"code": "KS", "name": "Kansas"},
{"code": "KY", "name": "Kentucky"},
{"code": "LA", "name": "Louisiana"},
{"code": "ME", "name": "Maine"},
{"code": "MD", "name": "Maryland"},
{"code": "MA", "name": "Massachusetts"},
{"code": "MI", "name": "Michigan"},
{"code": "MN", "name": "Minnesota"},
{"code": "MS", "name": "Mississippi"},
{"code": "MO", "name": "Missouri"},
{"code": "MT", "name": "Montana"},
{"code": "NE", "name": "Nebraska"},
{"code": "NV", "name": "Nevada"},
{"code": "NH", "name": "New Hampshire"},
{"code": "NJ", "name": "New Jersey"},
{"code": "NM", "name": "New Mexico"},
{"code": "NY", "name": "New York"},
{"code": "NC", "name": "North Carolina"},
{"code": "ND", "name": "North Dakota"},
{"code": "OH", "name": "Ohio"},
{"code": "OK", "name": "Oklahoma"},
{"code": "OR", "name": "Oregon"},
{"code": "PA", "name": "Pennsylvania"},
{"code": "RI", "name": "Rhode Island"},
{"code": "SC", "name": "South Carolina"},
{"code": "SD", "name": "South Dakota"},
{"code": "TN", "name": "Tennessee"},
{"code": "TX", "name": "Texas"},
{"code": "UT", "name": "Utah"},
{"code": "VT", "name": "Vermont"},
{"code": "VA", "name": "Virginia"},
{"code": "WA", "name": "Washington"},
{"code": "WV", "name": "West Virginia"},
{"code": "WI", "name": "Wisconsin"},
{"code": "WY", "name": "Wyoming"},
{"code": "DC", "name": "District of Columbia"},
{"code": "AS", "name": "American Samoa"},
{"code": "GU", "name": "Guam"},
{"code": "MP", "name": "Northern Mariana Islands"},
{"code": "PR", "name": "Puerto Rico"},
{"code": "UM", "name": "United States Minor Outlying Islands"},
{"code": "VI", "name": "Virgin Islands, U.S."},
]

federal_regulator_seed = [
{"id": "FCA", "name": "Farm Credit Administration"},
{"id": "FDIC", "name": "Federal Deposit Insurance Corporation"},
{"id": "FHFA", "name": "Federal Housing Finance Agency"},
{"id": "FRS", "name": "Federal Reserve System"},
{"id": "NCUA", "name": "National Credit Union Administration"},
{"id": "OCC", "name": "Office of the Comptroller of the Currency"},
{"id": "OTS", "name": "Office of Thrift Supervision (only valid until July 21, 2011)"},
]

sbl_institution_type_seed = [
{"id": "1", "name": "Bank or savings association."},
{"id": "2", "name": "Minority depository institution."},
{"id": "3", "name": "Credit union."},
{"id": "4", "name": "Nondepository institution."},
{"id": "5", "name": "Community development financial institution (CDFI)."},
{"id": "6", "name": "Other nonprofit financial institution."},
{"id": "7", "name": "Farm Credit System institution."},
{"id": "8", "name": "Government lender."},
{"id": "9", "name": "Commercial finance company."},
{"id": "10", "name": "Equipment finance company."},
{"id": "11", "name": "Industrial loan company."},
{"id": "12", "name": "Online lender."},
{"id": "13", "name": "Other"},
]

hmda_institution_type_seed = [
{"id": "1", "name": "National Bank (OCC supervised)"},
{"id": "2", "name": "State Member Bank (FRS Supervised)"},
{"id": "3", "name": "State non-member bank (FDIC supervised)"},
{"id": "4", "name": "State Chartered Thrift (FDIC supervised)"},
{"id": "5", "name": "Federal Chartered Thrift (OCC supervised)"},
{"id": "6", "name": "Credit Union (NCUA supervised)"},
{"id": "7", "name": "Federal Branch or Agency of Foreign Banking Organization (FBO)"},
{"id": "8", "name": "Branch or Agency of FBO (FRS supervised)"},
{"id": "9", "name": "MBS of national Bank (OCC supervised)"},
{"id": "10", "name": "MBS of state member bank (FRS supervised)"},
{"id": "11", "name": "MBS of state non-member bank (FDIC supervised)"},
{"id": "12", "name": "MBS of Bank Holding Company (BHC) (FRS supervised)"},
{"id": "13", "name": "MBS of credit union (NCUA supervised)"},
{"id": "14", "name": "independent MBS, no depository affiliation"},
{"id": "15", "name": "MBS of Savings and Loan Holding Co"},
{"id": "16", "name": "MBS of state chartered Thrift"},
{"id": "17", "name": "MBS of federally chartered thrift (OCC supervised)"},
{"id": "18", "name": "Affiliate of depository institution. MBS is in the same ownership org as a depository."},
]

"""
END seed data for the lookup tables:
"""
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Feed Federal Regulator table
"""Seed Federal Regulator table
Revision ID: 26a742d97ad9
Revises: 7b6ff51002b5
Expand All @@ -8,7 +8,7 @@
from typing import Sequence, Union
from alembic import op
from entities.models import FederalRegulatorDao
from config import federal_regulator_feed
from db_revisions.seed import federal_regulator_seed


# revision identifiers, used by Alembic.
Expand All @@ -19,7 +19,7 @@


def upgrade() -> None:
op.bulk_insert(FederalRegulatorDao.__table__, federal_regulator_feed)
op.bulk_insert(FederalRegulatorDao.__table__, federal_regulator_seed)


def downgrade() -> None:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Feed Address State table
"""Seed Address State table
Revision ID: 7b6ff51002b5
Revises: 045aa502e050
Expand All @@ -8,7 +8,7 @@
from typing import Sequence, Union
from alembic import op
from entities.models import AddressStateDao
from config import address_state_feed
from db_revisions.seed import address_state_seed


# revision identifiers, used by Alembic.
Expand All @@ -19,7 +19,7 @@


def upgrade() -> None:
op.bulk_insert(AddressStateDao.__table__, address_state_feed)
op.bulk_insert(AddressStateDao.__table__, address_state_seed)


def downgrade() -> None:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Feed SBL Institution Type table
"""Seed SBL Institution Type table
Revision ID: a41281b1e109
Revises: f4ff7d1aa6df
Expand All @@ -8,7 +8,7 @@
from typing import Sequence, Union
from alembic import op
from entities.models import SBLInstitutionTypeDao
from config import sbl_institution_type_feed
from db_revisions.seed import sbl_institution_type_seed

# revision identifiers, used by Alembic.
revision: str = "a41281b1e109"
Expand All @@ -18,7 +18,7 @@


def upgrade() -> None:
op.bulk_insert(SBLInstitutionTypeDao.__table__, sbl_institution_type_feed)
op.bulk_insert(SBLInstitutionTypeDao.__table__, sbl_institution_type_seed)


def downgrade() -> None:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Feed HMDA Institution Type table
"""Seed HMDA Institution Type table
Revision ID: f4ff7d1aa6df
Revises: 26a742d97ad9
Expand All @@ -8,7 +8,7 @@
from typing import Sequence, Union
from alembic import op
from entities.models import HMDAInstitutionTypeDao
from config import hmda_institution_type_feed
from db_revisions.seed import hmda_institution_type_seed


# revision identifiers, used by Alembic.
Expand All @@ -19,7 +19,7 @@


def upgrade() -> None:
op.bulk_insert(HMDAInstitutionTypeDao.__table__, hmda_institution_type_feed)
op.bulk_insert(HMDAInstitutionTypeDao.__table__, hmda_institution_type_seed)


def downgrade() -> None:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pytest-alembic = "^0.10.7"

[tool.pytest.ini_options]
asyncio_mode = "auto"
pythonpath = ["src"]
pythonpath = ["src","db_revisions"]
addopts = [
"--cov-report=term-missing",
"--cov-branch",
Expand Down
118 changes: 0 additions & 118 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,125 +6,7 @@
from pydantic.types import SecretStr
from pydantic_settings import BaseSettings, SettingsConfigDict

"""
START Feed data for the lookup tables:
address_state
federal_regulator
hmda_institution_type
sbl_institution_type
These are accessed in db_revisions/versions/* scripts and in test/migrations/test_lookup_tables_data_feed .
"""

address_state_feed = [
{"code": "AL", "name": "Alabama"},
{"code": "AK", "name": "Alaska"},
{"code": "AZ", "name": "Arizona"},
{"code": "AR", "name": "Arkansas"},
{"code": "CA", "name": "California"},
{"code": "CO", "name": "Colorado"},
{"code": "CT", "name": "Connecticut"},
{"code": "DE", "name": "Delaware"},
{"code": "FL", "name": "Florida"},
{"code": "GA", "name": "Georgia"},
{"code": "HI", "name": "Hawaii"},
{"code": "ID", "name": "Idaho"},
{"code": "IL", "name": "Illinois"},
{"code": "IN", "name": "Indiana"},
{"code": "IA", "name": "Iowa"},
{"code": "KS", "name": "Kansas"},
{"code": "KY", "name": "Kentucky"},
{"code": "LA", "name": "Louisiana"},
{"code": "ME", "name": "Maine"},
{"code": "MD", "name": "Maryland"},
{"code": "MA", "name": "Massachusetts"},
{"code": "MI", "name": "Michigan"},
{"code": "MN", "name": "Minnesota"},
{"code": "MS", "name": "Mississippi"},
{"code": "MO", "name": "Missouri"},
{"code": "MT", "name": "Montana"},
{"code": "NE", "name": "Nebraska"},
{"code": "NV", "name": "Nevada"},
{"code": "NH", "name": "New Hampshire"},
{"code": "NJ", "name": "New Jersey"},
{"code": "NM", "name": "New Mexico"},
{"code": "NY", "name": "New York"},
{"code": "NC", "name": "North Carolina"},
{"code": "ND", "name": "North Dakota"},
{"code": "OH", "name": "Ohio"},
{"code": "OK", "name": "Oklahoma"},
{"code": "OR", "name": "Oregon"},
{"code": "PA", "name": "Pennsylvania"},
{"code": "RI", "name": "Rhode Island"},
{"code": "SC", "name": "South Carolina"},
{"code": "SD", "name": "South Dakota"},
{"code": "TN", "name": "Tennessee"},
{"code": "TX", "name": "Texas"},
{"code": "UT", "name": "Utah"},
{"code": "VT", "name": "Vermont"},
{"code": "VA", "name": "Virginia"},
{"code": "WA", "name": "Washington"},
{"code": "WV", "name": "West Virginia"},
{"code": "WI", "name": "Wisconsin"},
{"code": "WY", "name": "Wyoming"},
{"code": "DC", "name": "District of Columbia"},
{"code": "AS", "name": "American Samoa"},
{"code": "GU", "name": "Guam"},
{"code": "MP", "name": "Northern Mariana Islands"},
{"code": "PR", "name": "Puerto Rico"},
{"code": "UM", "name": "United States Minor Outlying Islands"},
{"code": "VI", "name": "Virgin Islands, U.S."},
]

federal_regulator_feed = [
{"id": "FCA", "name": "Farm Credit Administration"},
{"id": "FDIC", "name": "Federal Deposit Insurance Corporation"},
{"id": "FHFA", "name": "Federal Housing Finance Agency"},
{"id": "FRS", "name": "Federal Reserve System"},
{"id": "NCUA", "name": "National Credit Union Administration"},
{"id": "OCC", "name": "Office of the Comptroller of the Currency"},
{"id": "OTS", "name": "Office of Thrift Supervision (only valid until July 21, 2011)"},
]

sbl_institution_type_feed = [
{"id": "1", "name": "Bank or savings association."},
{"id": "2", "name": "Minority depository institution."},
{"id": "3", "name": "Credit union."},
{"id": "4", "name": "Nondepository institution."},
{"id": "5", "name": "Community development financial institution (CDFI)."},
{"id": "6", "name": "Other nonprofit financial institution."},
{"id": "7", "name": "Farm Credit System institution."},
{"id": "8", "name": "Government lender."},
{"id": "9", "name": "Commercial finance company."},
{"id": "10", "name": "Equipment finance company."},
{"id": "11", "name": "Industrial loan company."},
{"id": "12", "name": "Online lender."},
{"id": "13", "name": "Other"},
]

hmda_institution_type_feed = [
{"id": "1", "name": "National Bank (OCC supervised)"},
{"id": "2", "name": "State Member Bank (FRS Supervised)"},
{"id": "3", "name": "State non-member bank (FDIC supervised)"},
{"id": "4", "name": "State Chartered Thrift (FDIC supervised)"},
{"id": "5", "name": "Federal Chartered Thrift (OCC supervised)"},
{"id": "6", "name": "Credit Union (NCUA supervised)"},
{"id": "7", "name": "Federal Branch or Agency of Foreign Banking Organization (FBO)"},
{"id": "8", "name": "Branch or Agency of FBO (FRS supervised)"},
{"id": "9", "name": "MBS of national Bank (OCC supervised)"},
{"id": "10", "name": "MBS of state member bank (FRS supervised)"},
{"id": "11", "name": "MBS of state non-member bank (FDIC supervised)"},
{"id": "12", "name": "MBS of Bank Holding Company (BHC) (FRS supervised)"},
{"id": "13", "name": "MBS of credit union (NCUA supervised)"},
{"id": "14", "name": "independent MBS, no depository affiliation"},
{"id": "15", "name": "MBS of Savings and Loan Holding Co"},
{"id": "16", "name": "MBS of state chartered Thrift"},
{"id": "17", "name": "MBS of federally chartered thrift (OCC supervised)"},
{"id": "18", "name": "Affiliate of depository institution. MBS is in the same ownership org as a depository."},
]

"""
END Feed data for the lookup tables:
"""
JWT_OPTS_PREFIX = "jwt_opts_"

env_files_to_load = [".env"]
Expand Down
Loading

0 comments on commit f96e709

Please sign in to comment.