mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 15:46:07 -05:00
Refactor code
- removed redundant dao method - also handle letter jobs
This commit is contained in:
@@ -32,6 +32,7 @@ from app.models import (
|
||||
EMAIL_TYPE,
|
||||
JOB_STATUS_ERROR,
|
||||
JOB_STATUS_FINISHED,
|
||||
JOB_STATUS_SENT_TO_DVLA,
|
||||
KEY_TYPE_NORMAL,
|
||||
KEY_TYPE_TEAM,
|
||||
KEY_TYPE_TEST,
|
||||
@@ -1234,6 +1235,14 @@ def test_job_incomplete_raises_job_incomplete_error(sample_job):
|
||||
assert e.value.message == 'Job {} did not complete'.format(sample_job.id)
|
||||
|
||||
|
||||
def test_job_finished_does_not_raises_job_incomplete_error(sample_job):
|
||||
sample_job.job_status = JOB_STATUS_FINISHED
|
||||
@pytest.mark.parametrize('job_status,notification_type',
|
||||
[
|
||||
(JOB_STATUS_FINISHED, SMS_TYPE),
|
||||
(JOB_STATUS_SENT_TO_DVLA, LETTER_TYPE)
|
||||
]
|
||||
)
|
||||
def test_job_finished_does_not_raises_job_incomplete_error(
|
||||
sample_job, job_status, notification_type):
|
||||
sample_job.job_status = job_status
|
||||
sample_job.template.template_type = notification_type
|
||||
check_job_status(str(sample_job.id))
|
||||
|
||||
@@ -35,7 +35,6 @@ from app.dao.notifications_dao import (
|
||||
dao_get_potential_notification_statistics_for_day,
|
||||
dao_get_scheduled_notifications,
|
||||
dao_get_template_usage,
|
||||
dao_get_total_notifications_for_job_id,
|
||||
dao_timeout_notifications,
|
||||
dao_update_notification,
|
||||
dao_update_notifications_for_job_to_sent_to_dvla,
|
||||
@@ -2001,13 +2000,3 @@ def test_dao_get_notification_ememail_reply_toail_reply_for_notification(sample_
|
||||
|
||||
def test_dao_get_notification_email_reply_for_notification_where_no_mapping(notify_db_session, fake_uuid):
|
||||
assert dao_get_notification_email_reply_for_notification(fake_uuid) is None
|
||||
|
||||
|
||||
def test_dao_get_total_notifications_for_job_id(sample_job):
|
||||
job = create_job(sample_job.template)
|
||||
create_notification(sample_job.template, job=sample_job)
|
||||
create_notification(sample_job.template, job=sample_job)
|
||||
create_notification(sample_job.template, job=sample_job)
|
||||
create_notification(sample_job.template, job=job)
|
||||
|
||||
assert dao_get_total_notifications_for_job_id(sample_job.id) == 3
|
||||
|
||||
Reference in New Issue
Block a user