Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

FS-4780: Add ggis_scheme_reference_number for fund config #359

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,38 @@
"""Add ggis_scheme_reference_number

Revision ID: 71ec50f94e6f
Revises: de8d7954ffda
Create Date: 2024-11-13 13:49:03.498795

"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "71ec50f94e6f"
down_revision = "de8d7954ffda"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("fund", schema=None) as batch_op:
batch_op.add_column(sa.Column("ggis_scheme_reference_number", sa.String(length=255), nullable=True))

with op.batch_alter_table("round", schema=None) as batch_op:
batch_op.alter_column("reference_contact_page_over_email", existing_type=sa.BOOLEAN(), nullable=False)
samuelhwilliams marked this conversation as resolved.
Show resolved Hide resolved

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("round", schema=None) as batch_op:
batch_op.alter_column("reference_contact_page_over_email", existing_type=sa.BOOLEAN(), nullable=True)

with op.batch_alter_table("fund", schema=None) as batch_op:
batch_op.drop_column("ggis_scheme_reference_number")

# ### end Alembic commands ###
1 change: 1 addition & 0 deletions db/models/fund.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ class Fund(BaseModel):
owner_organisation_shortname = Column("owner_organisation_shortname", db.String(), nullable=False, unique=False)
owner_organisation_logo_uri = Column("owner_organisation_logo_uri", db.Text(), nullable=True, unique=False)
funding_type = Column("funding_type", SQLAEnum(FundingType, name="fundingtype"), nullable=False, unique=False)
ggis_scheme_reference_number = Column("ggis_scheme_reference_number", db.String(255), nullable=True, unique=False)
3 changes: 3 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def seed_dynamic_data(request, app, clear_test_data, _db):
"id": fund_id,
"short_name": "FUND",
"funding_type": "COMPETITIVE",
"ggis_scheme_reference_number": "",
"rounds": [
{
"id": round_id_1,
Expand Down Expand Up @@ -123,6 +124,7 @@ def seed_dynamic_data(request, app, clear_test_data, _db):
"owner_organisation_shortname": "TON",
"owner_organisation_logo_uri": "...",
"funding_type": fund["funding_type"] or FundingType.COMPETITIVE,
"ggis_scheme_reference_number": fund["ggis_scheme_reference_number"] or "",
}
insert_fund_data(fund_config)
rounds = []
Expand Down Expand Up @@ -202,6 +204,7 @@ def mock_get_fund_round(mocker):
title_json={"en": "Fund 1"},
description_json={"en": "description text"},
funding_type=FundingType.COMPETITIVE,
ggis_scheme_reference_number="G2-SCH-0000092414",
)
round_config = {
"id": uuid4(),
Expand Down
1 change: 1 addition & 0 deletions tests/test_data/test_fab_round_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"name_json": {"en": "Test"},
"title_json": {"en": "Test Fund"},
"description_json": {"en": "test"},
"ggis_scheme_reference_number": "",
},
"round_config": {
"id": "1a2d6043-689b-4472-a09c-fd8fcfd20151",
Expand Down
2 changes: 2 additions & 0 deletions tests/test_data_fund_round.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ def test_get_fund_by_id(seed_dynamic_data):
f = get_fund_by_id(seed_dynamic_data["funds"][0]["id"])
assert f.name_json["en"] == "Unit Test Fund 1"
assert f.short_name == "FND1"
assert hasattr(f, "ggis_scheme_reference_number")
assert f.ggis_scheme_reference_number is None


def test_get_fund_by_short_name(seed_dynamic_data):
Expand Down