-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* eft_short_names table * 17829 - eft feature flagging, eft short names tables * version bump * update flags service for LD 8.x
- Loading branch information
Showing
10 changed files
with
169 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
pay-api/migrations/versions/2023_10_18_194cdd7cf986_17829_eft_shortnames.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"""17829-eft-shortnames | ||
Revision ID: 194cdd7cf986 | ||
Revises: 456234145e5e | ||
Create Date: 2023-10-18 08:23:04.207463 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
from pay_api import db | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '194cdd7cf986' | ||
down_revision = '456234145e5e' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.create_table('eft_short_names', | ||
sa.Column('id', sa.Integer(), nullable=False, primary_key=True), | ||
sa.Column('short_name', sa.String(), nullable=False, unique=True), | ||
sa.Column('auth_account_id', sa.String(length=50), nullable=True), | ||
sa.Column('created_on', sa.DateTime(), nullable=False), | ||
) | ||
|
||
op.create_index(op.f('ix_eft_short_names_auth_account_id'), 'eft_short_names', ['auth_account_id'], unique=False) | ||
|
||
|
||
def downgrade(): | ||
op.drop_table('eft_short_names') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Copyright © 2023 Province of British Columbia | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""Model to handle EFT TDI17 short name to BCROS account mapping.""" | ||
|
||
from datetime import datetime | ||
|
||
from .base_model import BaseModel | ||
from .db import db | ||
|
||
|
||
class EFTShortnames(BaseModel): # pylint: disable=too-many-instance-attributes | ||
"""This class manages the EFT short name to auth account mapping.""" | ||
|
||
__tablename__ = 'eft_short_names' | ||
# this mapper is used so that new and old versions of the service can be run simultaneously, | ||
# making rolling upgrades easier | ||
# This is used by SQLAlchemy to explicitly define which fields we're interested | ||
# so it doesn't freak out and say it can't map the structure if other fields are present. | ||
# This could occur from a failed deploy or during an upgrade. | ||
# The other option is to tell SQLAlchemy to ignore differences, but that is ambiguous | ||
# and can interfere with Alembic upgrades. | ||
# | ||
# NOTE: please keep mapper names in alpha-order, easier to track that way | ||
# Exception, id is always first, _fields first | ||
__mapper_args__ = { | ||
'include_properties': [ | ||
'id', | ||
'auth_account_id', | ||
'created_on', | ||
'short_name' | ||
] | ||
} | ||
|
||
id = db.Column(db.Integer, primary_key=True, autoincrement=True) | ||
auth_account_id = db.Column('auth_account_id', db.DateTime, nullable=True, index=True) | ||
created_on = db.Column('created_on', db.DateTime, nullable=False, default=datetime.now) | ||
short_name = db.Column('short_name', db.String, nullable=False, index=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Copyright © 2023 Province of British Columbia | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""Tests to assure the EFT File model. | ||
Test-Suite to ensure that the EFT File model is working as expected. | ||
""" | ||
from datetime import datetime | ||
|
||
from pay_api.models.eft_short_names import EFTShortnames as EFTShortnamesModel | ||
|
||
|
||
def test_eft_short_name_defaults(session): | ||
"""Assert eft short names defaults are stored.""" | ||
eft_short_name = EFTShortnamesModel() | ||
eft_short_name.short_name = 'ABC' | ||
eft_short_name.save() | ||
|
||
assert eft_short_name.id is not None | ||
assert eft_short_name.short_name == 'ABC' | ||
assert eft_short_name.created_on.date() == datetime.now().date() | ||
assert eft_short_name.auth_account_id is None | ||
|
||
|
||
def test_eft_short_names_all_attributes(session): | ||
"""Assert all eft short names attributes are stored.""" | ||
eft_short_name = EFTShortnamesModel() | ||
eft_short_name.short_name = 'ABC' | ||
eft_short_name.auth_account_id = '1234' | ||
eft_short_name.save() | ||
|
||
assert eft_short_name.id is not None | ||
|
||
eft_short_name = EFTShortnamesModel.find_by_id(eft_short_name.id) | ||
assert eft_short_name.short_name == 'ABC' | ||
assert eft_short_name.auth_account_id == '1234' | ||
assert eft_short_name.created_on.date() == datetime.now().date() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters