mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-05 02:41:14 -05:00
more tests
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import pytest
|
||||
from flask import json
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
|
||||
from app import db
|
||||
from app.celery.process_ses_receipts_tasks import (
|
||||
check_and_queue_callback_task,
|
||||
handle_complaint,
|
||||
@@ -35,7 +37,7 @@ def test_ses_callback_should_not_set_status_once_status_is_delivered(
|
||||
def test_process_ses_results_in_complaint(sample_email_template):
|
||||
notification = create_notification(template=sample_email_template, reference="ref1")
|
||||
handle_complaint(json.loads(ses_complaint_callback()["Message"]))
|
||||
complaints = Complaint.query.all()
|
||||
complaints = db.session.execute(select(Complaint)).scalars().all()
|
||||
assert len(complaints) == 1
|
||||
assert complaints[0].notification_id == notification.id
|
||||
|
||||
@@ -43,7 +45,7 @@ def test_process_ses_results_in_complaint(sample_email_template):
|
||||
def test_handle_complaint_does_not_raise_exception_if_reference_is_missing(notify_api):
|
||||
response = json.loads(ses_complaint_callback_malformed_message_id()["Message"])
|
||||
handle_complaint(response)
|
||||
assert len(Complaint.query.all()) == 0
|
||||
assert len(db.session.execute(select(Complaint)).scalars().all()) == 0
|
||||
|
||||
|
||||
def test_handle_complaint_does_raise_exception_if_notification_not_found(notify_api):
|
||||
@@ -57,7 +59,7 @@ def test_process_ses_results_in_complaint_if_notification_history_does_not_exist
|
||||
):
|
||||
notification = create_notification(template=sample_email_template, reference="ref1")
|
||||
handle_complaint(json.loads(ses_complaint_callback()["Message"]))
|
||||
complaints = Complaint.query.all()
|
||||
complaints = db.session.execute(select(Complaint)).scalars().all()
|
||||
assert len(complaints) == 1
|
||||
assert complaints[0].notification_id == notification.id
|
||||
|
||||
@@ -69,7 +71,7 @@ def test_process_ses_results_in_complaint_if_notification_does_not_exist(
|
||||
template=sample_email_template, reference="ref1"
|
||||
)
|
||||
handle_complaint(json.loads(ses_complaint_callback()["Message"]))
|
||||
complaints = Complaint.query.all()
|
||||
complaints = db.session.execute(select(Complaint)).scalars().all()
|
||||
assert len(complaints) == 1
|
||||
assert complaints[0].notification_id == notification.id
|
||||
|
||||
@@ -80,7 +82,7 @@ def test_process_ses_results_in_complaint_save_complaint_with_null_complaint_typ
|
||||
notification = create_notification(template=sample_email_template, reference="ref1")
|
||||
msg = json.loads(ses_complaint_callback_with_missing_complaint_type()["Message"])
|
||||
handle_complaint(msg)
|
||||
complaints = Complaint.query.all()
|
||||
complaints = db.session.execute(select(Complaint)).scalars().all()
|
||||
assert len(complaints) == 1
|
||||
assert complaints[0].notification_id == notification.id
|
||||
assert not complaints[0].complaint_type
|
||||
|
||||
Reference in New Issue
Block a user