mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-06 16:58:25 -04:00
Merge pull request #2239 from alphagov/remove-unused-task
Remove unused task
This commit is contained in:
@@ -35,7 +35,6 @@ from app.dao.inbound_sms_dao import dao_get_inbound_sms_by_id
|
|||||||
from app.dao.jobs_dao import (
|
from app.dao.jobs_dao import (
|
||||||
dao_update_job,
|
dao_update_job,
|
||||||
dao_get_job_by_id,
|
dao_get_job_by_id,
|
||||||
dao_update_job_status
|
|
||||||
)
|
)
|
||||||
from app.dao.notifications_dao import (
|
from app.dao.notifications_dao import (
|
||||||
get_notification_by_id,
|
get_notification_by_id,
|
||||||
@@ -59,7 +58,6 @@ from app.models import (
|
|||||||
JOB_STATUS_FINISHED,
|
JOB_STATUS_FINISHED,
|
||||||
JOB_STATUS_IN_PROGRESS,
|
JOB_STATUS_IN_PROGRESS,
|
||||||
JOB_STATUS_PENDING,
|
JOB_STATUS_PENDING,
|
||||||
JOB_STATUS_ERROR,
|
|
||||||
KEY_TYPE_NORMAL,
|
KEY_TYPE_NORMAL,
|
||||||
LETTER_TYPE,
|
LETTER_TYPE,
|
||||||
NOTIFICATION_CREATED,
|
NOTIFICATION_CREATED,
|
||||||
@@ -342,13 +340,6 @@ def save_letter(
|
|||||||
handle_exception(self, notification, notification_id, e)
|
handle_exception(self, notification, notification_id, e)
|
||||||
|
|
||||||
|
|
||||||
@notify_celery.task(bind=True, name='update-letter-job-to-error')
|
|
||||||
@statsd(namespace="tasks")
|
|
||||||
def update_dvla_job_to_error(self, job_id):
|
|
||||||
dao_update_job_status(job_id, JOB_STATUS_ERROR)
|
|
||||||
current_app.logger.info("Updated {} job to {}".format(job_id, JOB_STATUS_ERROR))
|
|
||||||
|
|
||||||
|
|
||||||
@notify_celery.task(bind=True, name='update-letter-notifications-to-sent')
|
@notify_celery.task(bind=True, name='update-letter-notifications-to-sent')
|
||||||
@statsd(namespace="tasks")
|
@statsd(namespace="tasks")
|
||||||
def update_letter_notifications_to_sent_to_dvla(self, notification_references):
|
def update_letter_notifications_to_sent_to_dvla(self, notification_references):
|
||||||
|
|||||||
@@ -115,11 +115,6 @@ def dao_update_job(job):
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
|
||||||
def dao_update_job_status(job_id, status):
|
|
||||||
db.session.query(Job).filter_by(id=job_id).update({'job_status': status})
|
|
||||||
db.session.commit()
|
|
||||||
|
|
||||||
|
|
||||||
def dao_get_jobs_older_than_limited_by(job_types, older_than=7, limit_days=2):
|
def dao_get_jobs_older_than_limited_by(job_types, older_than=7, limit_days=2):
|
||||||
end_date = datetime.utcnow() - timedelta(days=older_than)
|
end_date = datetime.utcnow() - timedelta(days=older_than)
|
||||||
start_date = end_date - timedelta(days=limit_days)
|
start_date = end_date - timedelta(days=limit_days)
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ from flask import current_app
|
|||||||
|
|
||||||
from app.exceptions import DVLAException, NotificationTechnicalFailureException
|
from app.exceptions import DVLAException, NotificationTechnicalFailureException
|
||||||
from app.models import (
|
from app.models import (
|
||||||
Job,
|
|
||||||
Notification,
|
Notification,
|
||||||
NotificationHistory,
|
NotificationHistory,
|
||||||
NOTIFICATION_CREATED,
|
NOTIFICATION_CREATED,
|
||||||
@@ -21,7 +20,6 @@ from app.celery.tasks import (
|
|||||||
get_billing_date_in_bst_from_filename,
|
get_billing_date_in_bst_from_filename,
|
||||||
persist_daily_sorted_letter_counts,
|
persist_daily_sorted_letter_counts,
|
||||||
process_updates_from_file,
|
process_updates_from_file,
|
||||||
update_dvla_job_to_error,
|
|
||||||
update_letter_notifications_statuses,
|
update_letter_notifications_statuses,
|
||||||
update_letter_notifications_to_error,
|
update_letter_notifications_to_error,
|
||||||
update_letter_notifications_to_sent_to_dvla
|
update_letter_notifications_to_sent_to_dvla
|
||||||
@@ -41,19 +39,6 @@ def notification_update():
|
|||||||
return NotificationUpdate('REFERENCE_ABC', 'sent', '1', 'cost')
|
return NotificationUpdate('REFERENCE_ABC', 'sent', '1', 'cost')
|
||||||
|
|
||||||
|
|
||||||
def test_update_dvla_job_to_error(sample_letter_template, sample_letter_job):
|
|
||||||
create_notification(template=sample_letter_template, job=sample_letter_job)
|
|
||||||
create_notification(template=sample_letter_template, job=sample_letter_job)
|
|
||||||
update_dvla_job_to_error(job_id=sample_letter_job.id)
|
|
||||||
|
|
||||||
updated_notifications = Notification.query.all()
|
|
||||||
for n in updated_notifications:
|
|
||||||
assert n.status == 'created'
|
|
||||||
assert not n.sent_by
|
|
||||||
|
|
||||||
assert Job.query.filter_by(id=sample_letter_job.id).one().job_status == 'error'
|
|
||||||
|
|
||||||
|
|
||||||
def test_update_letter_notifications_statuses_raises_for_invalid_format(notify_api, mocker):
|
def test_update_letter_notifications_statuses_raises_for_invalid_format(notify_api, mocker):
|
||||||
invalid_file = 'ref-foo|Sent|1|Unsorted\nref-bar|Sent|2'
|
invalid_file = 'ref-foo|Sent|1|Unsorted\nref-bar|Sent|2'
|
||||||
mocker.patch('app.celery.tasks.s3.get_s3_file', return_value=invalid_file)
|
mocker.patch('app.celery.tasks.s3.get_s3_file', return_value=invalid_file)
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ from app.dao.jobs_dao import (
|
|||||||
dao_set_scheduled_jobs_to_pending,
|
dao_set_scheduled_jobs_to_pending,
|
||||||
dao_get_future_scheduled_job_by_id_and_service_id,
|
dao_get_future_scheduled_job_by_id_and_service_id,
|
||||||
dao_get_notification_outcomes_for_job,
|
dao_get_notification_outcomes_for_job,
|
||||||
dao_update_job_status,
|
|
||||||
dao_get_jobs_older_than_limited_by
|
dao_get_jobs_older_than_limited_by
|
||||||
)
|
)
|
||||||
from app.models import (
|
from app.models import (
|
||||||
@@ -348,13 +347,6 @@ def test_get_jobs_for_service_doesnt_return_test_messages(
|
|||||||
assert jobs == [sample_job]
|
assert jobs == [sample_job]
|
||||||
|
|
||||||
|
|
||||||
def test_dao_update_job_status(sample_job):
|
|
||||||
dao_update_job_status(sample_job.id, 'sent to dvla')
|
|
||||||
updated_job = Job.query.get(sample_job.id)
|
|
||||||
assert updated_job.job_status == 'sent to dvla'
|
|
||||||
assert updated_job.updated_at
|
|
||||||
|
|
||||||
|
|
||||||
@freeze_time('2016-10-31 10:00:00')
|
@freeze_time('2016-10-31 10:00:00')
|
||||||
def test_should_get_jobs_seven_days_old_filters_type(notify_db, notify_db_session):
|
def test_should_get_jobs_seven_days_old_filters_type(notify_db, notify_db_session):
|
||||||
eight_days_ago = datetime.utcnow() - timedelta(days=8)
|
eight_days_ago = datetime.utcnow() - timedelta(days=8)
|
||||||
|
|||||||
Reference in New Issue
Block a user