mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-19 05:58:53 -04:00
more
This commit is contained in:
@@ -3,6 +3,7 @@ from unittest.mock import Mock
|
||||
|
||||
import pytest
|
||||
|
||||
from app import db
|
||||
from app.dao.service_guest_list_dao import dao_add_and_commit_guest_list_contacts
|
||||
from app.enums import (
|
||||
KeyType,
|
||||
@@ -266,7 +267,7 @@ def test_send_one_off_notification_should_add_email_reply_to_text_for_notificati
|
||||
notification_id = send_one_off_notification(
|
||||
service_id=sample_email_template.service.id, post_data=data
|
||||
)
|
||||
notification = Notification.query.get(notification_id["id"])
|
||||
notification = db.session.get(Notification, notification_id["id"])
|
||||
celery_mock.assert_called_once_with(notification=notification, queue=None)
|
||||
assert notification.reply_to_text == reply_to_email.email_address
|
||||
|
||||
@@ -289,7 +290,7 @@ def test_send_one_off_sms_notification_should_use_sms_sender_reply_to_text(
|
||||
notification_id = send_one_off_notification(
|
||||
service_id=sample_service.id, post_data=data
|
||||
)
|
||||
notification = Notification.query.get(notification_id["id"])
|
||||
notification = db.session.get(Notification, notification_id["id"])
|
||||
celery_mock.assert_called_once_with(notification=notification, queue=None)
|
||||
|
||||
assert notification.reply_to_text == "+12028675309"
|
||||
@@ -313,7 +314,7 @@ def test_send_one_off_sms_notification_should_use_default_service_reply_to_text(
|
||||
notification_id = send_one_off_notification(
|
||||
service_id=sample_service.id, post_data=data
|
||||
)
|
||||
notification = Notification.query.get(notification_id["id"])
|
||||
notification = db.session.get(Notification, notification_id["id"])
|
||||
celery_mock.assert_called_once_with(notification=notification, queue=None)
|
||||
|
||||
assert notification.reply_to_text == "+12028675309"
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import json
|
||||
import uuid
|
||||
|
||||
from sqlalchemy import select
|
||||
|
||||
from app import db
|
||||
from app.dao.service_guest_list_dao import dao_add_and_commit_guest_list_contacts
|
||||
from app.enums import RecipientType
|
||||
from app.models import ServiceGuestList
|
||||
@@ -87,7 +90,12 @@ def test_update_guest_list_replaces_old_guest_list(client, sample_service_guest_
|
||||
)
|
||||
|
||||
assert response.status_code == 204
|
||||
guest_list = ServiceGuestList.query.order_by(ServiceGuestList.recipient).all()
|
||||
guest_list = (
|
||||
db.session.execute(select(ServiceGuestList))
|
||||
.order_by(ServiceGuestList.recipient)
|
||||
.scalars()
|
||||
.all()
|
||||
)
|
||||
assert len(guest_list) == 2
|
||||
assert guest_list[0].recipient == "+12028765309"
|
||||
assert guest_list[1].recipient == "foo@bar.com"
|
||||
@@ -112,5 +120,5 @@ def test_update_guest_list_doesnt_remove_old_guest_list_if_error(
|
||||
"result": "error",
|
||||
"message": 'Invalid guest list: "" is not a valid email address or phone number',
|
||||
}
|
||||
guest_list = ServiceGuestList.query.one()
|
||||
guest_list = db.session.execute(select(ServiceGuestList)).scalars().one()
|
||||
assert guest_list.id == sample_service_guest_list.id
|
||||
|
||||
@@ -3,7 +3,9 @@ from datetime import datetime
|
||||
|
||||
import pytest
|
||||
from freezegun import freeze_time
|
||||
from sqlalchemy import select
|
||||
|
||||
from app import db
|
||||
from app.models import Service
|
||||
from tests import create_admin_authorization_header
|
||||
|
||||
@@ -77,8 +79,10 @@ def test_service_history_is_created(client, sample_service, action, original_sta
|
||||
)
|
||||
ServiceHistory = Service.get_history_model()
|
||||
history = (
|
||||
ServiceHistory.query.filter_by(id=sample_service.id)
|
||||
db.session.execute(select(ServiceHistory))
|
||||
.filter_by(id=sample_service.id)
|
||||
.order_by(ServiceHistory.version.desc())
|
||||
.scalars()
|
||||
.first()
|
||||
)
|
||||
|
||||
|
||||
@@ -5,7 +5,9 @@ from functools import partial
|
||||
import pytest
|
||||
from flask import current_app
|
||||
from freezegun import freeze_time
|
||||
from sqlalchemy import select
|
||||
|
||||
from app import db
|
||||
from app.enums import AuthType, InvitedUserStatus
|
||||
from app.models import Notification
|
||||
from notifications_utils.url_safe_token import generate_token
|
||||
@@ -72,7 +74,7 @@ def test_create_invited_user(
|
||||
"folder_3",
|
||||
]
|
||||
|
||||
notification = Notification.query.first()
|
||||
notification = db.session.execute(select(Notification)).scalars().first()
|
||||
|
||||
assert notification.reply_to_text == invite_from.email_address
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ def test_should_create_a_new_template_for_a_service(
|
||||
else:
|
||||
assert not json_resp["data"]["subject"]
|
||||
|
||||
template = Template.query.get(json_resp["data"]["id"])
|
||||
template = db.session.get(Template, json_resp["data"]["id"])
|
||||
from app.schemas import template_schema
|
||||
|
||||
assert sorted(json_resp["data"]) == sorted(template_schema.dump(template))
|
||||
@@ -352,7 +352,8 @@ def test_update_should_update_a_template(client, sample_user):
|
||||
|
||||
assert update_json_resp["data"]["created_by"] == str(sample_user.id)
|
||||
template_created_by_users = [
|
||||
template.created_by_id for template in TemplateHistory.query.all()
|
||||
template.created_by_id
|
||||
for template in db.session.execute(select(TemplateHistory)).scalars().all()
|
||||
]
|
||||
assert len(template_created_by_users) == 2
|
||||
assert service.created_by.id in template_created_by_users
|
||||
@@ -380,7 +381,7 @@ def test_should_be_able_to_archive_template(client, sample_template):
|
||||
)
|
||||
|
||||
assert resp.status_code == 200
|
||||
assert Template.query.first().archived
|
||||
assert db.session.execute(select(Template)).scalars().first().archived
|
||||
|
||||
|
||||
def test_should_be_able_to_archive_template_should_remove_template_folders(
|
||||
@@ -402,7 +403,7 @@ def test_should_be_able_to_archive_template_should_remove_template_folders(
|
||||
data=json.dumps(data),
|
||||
)
|
||||
|
||||
updated_template = Template.query.get(template.id)
|
||||
updated_template = db.session.get(Template, template.id)
|
||||
assert updated_template.archived
|
||||
assert not updated_template.folder
|
||||
|
||||
|
||||
@@ -270,7 +270,7 @@ def test_delete_template_folder(admin_request, sample_service):
|
||||
template_folder_id=existing_folder.id,
|
||||
)
|
||||
|
||||
assert TemplateFolder.query.all() == []
|
||||
assert db.session.execute(select(TemplateFolder)).scalars().all() == []
|
||||
|
||||
|
||||
def test_delete_template_folder_fails_if_folder_has_subfolders(
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import pytest
|
||||
from freezegun import freeze_time
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
|
||||
from app import encryption
|
||||
from app import db, encryption
|
||||
from app.enums import (
|
||||
AgreementStatus,
|
||||
AgreementType,
|
||||
@@ -408,7 +409,7 @@ def test_annual_billing_serialize():
|
||||
|
||||
def test_repr():
|
||||
service = create_service()
|
||||
sps = ServicePermission.query.all()
|
||||
sps = db.session.execute(select(ServicePermission)).scalars().all()
|
||||
for sp in sps:
|
||||
assert "has service permission" in sp.__repr__()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user