The update of SQLAlchemy 1.4.10 has caused some conflicts in our code. This PR fixes most of those conflicts.

- sqlalchemy.sql.expression.case must include an else statement.
- clearly define list of columns for inbound_sms_history insert, getting the list from InboundSmsHistory.__table__.c was causing data type errors.
- remove relationships when not needed, the foreign key relationship is established in the creation of the column. This will get rid of the warnings referenced here: http://sqlalche.me/e/14/qzyx.
- update queries now that he user relationship in ServiceUser db model has been removed.
- move the check that a template is archived to the view instead of the dao method. The check was clearing the session before the version history could be done.

Deleting notifications in the night tasks still needs to be
investigated. The raw sql is causing an error.
This commit is contained in:
Rebecca Law
2021-04-26 11:50:17 +01:00
parent df19a91b7f
commit 68d28aa83b
8 changed files with 24 additions and 50 deletions

View File

@@ -13,12 +13,7 @@ from app.dao.templates_dao import (
dao_update_template,
dao_update_template_reply_to,
)
from app.models import (
Template,
TemplateFolder,
TemplateHistory,
TemplateRedacted,
)
from app.models import Template, TemplateHistory, TemplateRedacted
from tests.app.db import create_letter_contact, create_template
@@ -95,35 +90,6 @@ def test_update_template(sample_service, sample_user):
assert dao_get_all_templates_for_service(sample_service.id)[0].name == 'new name'
def test_update_template_in_a_folder_to_archived(sample_service, sample_user):
template_data = {
'name': 'Sample Template',
'template_type': "sms",
'content': "Template content",
'service': sample_service,
'created_by': sample_user
}
template = Template(**template_data)
template_folder_data = {
'name': 'My Folder',
'service_id': sample_service.id,
}
template_folder = TemplateFolder(**template_folder_data)
template.folder = template_folder
dao_create_template(template)
template.archived = True
dao_update_template(template)
template_folder = TemplateFolder.query.one()
archived_template = Template.query.one()
assert template_folder
assert not archived_template.folder
def test_dao_update_template_reply_to_none_to_some(sample_service, sample_user):
letter_contact = create_letter_contact(sample_service, 'Edinburgh, ED1 1AA')