mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-16 10:12:32 -05:00
fix for failing tests
This commit is contained in:
@@ -14,7 +14,7 @@ from flask import current_app, json
|
||||
from notifications_python_client.authentication import create_jwt_token
|
||||
from notifications_utils.recipients import RecipientCSV
|
||||
from notifications_utils.template import SMSMessageTemplate
|
||||
from sqlalchemy import and_
|
||||
from sqlalchemy import and_, text
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
from sqlalchemy.orm.exc import NoResultFound
|
||||
|
||||
@@ -173,13 +173,15 @@ def insert_inbound_numbers_from_file(file_name):
|
||||
|
||||
print(f"Inserting inbound numbers from {file_name}")
|
||||
with open(file_name) as file:
|
||||
sql = "insert into inbound_numbers values('{}', '{}', 'sns', null, True, now(), null);"
|
||||
sql = text(
|
||||
"insert into inbound_numbers values(:uuid, :line, 'sns', null, True, now(), null);"
|
||||
)
|
||||
|
||||
for line in file:
|
||||
line = line.strip()
|
||||
if line:
|
||||
print(line)
|
||||
db.session.execute(sql.format(uuid.uuid4(), line))
|
||||
db.session.execute(sql, {"uuid": str(uuid.uuid4()), "line": line})
|
||||
db.session.commit()
|
||||
|
||||
|
||||
@@ -333,7 +335,7 @@ def update_jobs_archived_flag(start_date, end_date):
|
||||
and created_at < (date :end + time '00:00:00')
|
||||
"""
|
||||
result = db.session.execute(
|
||||
sql, {"start": process_date, "end": process_date + timedelta(days=1)}
|
||||
text(sql), {"start": process_date, "end": process_date + timedelta(days=1)}
|
||||
)
|
||||
db.session.commit()
|
||||
current_app.logger.info(
|
||||
|
||||
@@ -206,7 +206,7 @@ def dao_fetch_all_services_by_user(user_id, only_active=False):
|
||||
query = (
|
||||
Service.query.filter(Service.users.any(id=user_id))
|
||||
.order_by(asc(Service.created_at))
|
||||
.options(joinedload("users"))
|
||||
.options(joinedload(Service.users))
|
||||
)
|
||||
|
||||
if only_active:
|
||||
|
||||
@@ -17,7 +17,7 @@ session events.
|
||||
import datetime
|
||||
|
||||
from sqlalchemy import Column, ForeignKeyConstraint, Integer, Table, util
|
||||
from sqlalchemy.orm import attributes, class_mapper, object_mapper, registry
|
||||
from sqlalchemy.orm import attributes, object_mapper, registry
|
||||
from sqlalchemy.orm.properties import ColumnProperty, RelationshipProperty
|
||||
|
||||
|
||||
@@ -169,7 +169,9 @@ def _add_version_for_non_super_history_mapper(super_history_mapper, local_mapper
|
||||
|
||||
def _col_copy(col):
|
||||
orig = col
|
||||
col = Column(col.name, col.type, nullable=col.nullable, unique=False)
|
||||
col = Column(
|
||||
col.name, col.type, nullable=col.nullable, unique=False, default=col.default
|
||||
)
|
||||
orig.info["history_copy"] = col
|
||||
|
||||
# if the column is nullable, we could end up overwriting an on-purpose null value with a default.
|
||||
@@ -189,7 +191,8 @@ class Versioned(object):
|
||||
|
||||
@classmethod
|
||||
def __declare_last__(cls):
|
||||
_history_mapper(class_mapper(cls))
|
||||
if not hasattr(cls, "__history_mapper__"):
|
||||
_history_mapper(cls.__mapper__)
|
||||
|
||||
@classmethod
|
||||
def get_history_model(cls):
|
||||
|
||||
@@ -7,8 +7,8 @@ Create Date: 2023-05-23 10:03:10.485368
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
from sqlalchemy.dialects import postgresql
|
||||
from sqlalchemy import text
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision = "0395_remove_intl_letters_perm"
|
||||
down_revision = "0394_remove_contact_list"
|
||||
|
||||
@@ -469,7 +469,8 @@ def upgrade():
|
||||
postgresql_using=enum_using("notification_type", NotificationType),
|
||||
)
|
||||
# Clobbering bad data here. These are values we don't use any more, and anything with them is unnecessary.
|
||||
op.execute("""
|
||||
op.execute(
|
||||
"""
|
||||
delete from
|
||||
service_permissions
|
||||
where
|
||||
@@ -480,7 +481,8 @@ def upgrade():
|
||||
'international_letters',
|
||||
'broadcast'
|
||||
);
|
||||
""")
|
||||
"""
|
||||
)
|
||||
op.alter_column(
|
||||
"service_permissions",
|
||||
"permission",
|
||||
|
||||
@@ -69,7 +69,7 @@ def _notify_db(notify_api):
|
||||
|
||||
yield db
|
||||
|
||||
db.session.remove()
|
||||
db.session.close_all()
|
||||
db.engine.dispose()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user