Add scheduled letter jobs

This commit is contained in:
Ken Tsang
2017-08-22 09:55:47 +01:00
parent 8c4a084a0d
commit 18881cd580
6 changed files with 81 additions and 6 deletions

View File

@@ -1,3 +1,5 @@
import uuid
from datetime import datetime, timedelta
from functools import partial
from unittest.mock import call, patch, PropertyMock
@@ -20,6 +22,7 @@ from app.celery.scheduled_tasks import (
remove_csv_files,
remove_transformed_dvla_files,
run_scheduled_jobs,
run_letter_jobs,
s3,
send_daily_performance_platform_stats,
send_scheduled_notifications,
@@ -28,6 +31,7 @@ from app.celery.scheduled_tasks import (
timeout_notifications,
populate_monthly_billing)
from app.clients.performance_platform.performance_platform_client import PerformancePlatformClient
from app.config import QueueNames
from app.dao.jobs_dao import dao_get_job_by_id
from app.dao.notifications_dao import dao_get_scheduled_notifications
from app.dao.provider_details_dao import (
@@ -677,3 +681,18 @@ def test_populate_monthly_billing_updates_correct_month_in_bst(sample_template):
assert monthly_billing[1].notification_type == 'sms'
assert monthly_billing[1].monthly_totals[0]['billing_units'] == 1
assert monthly_billing[1].monthly_totals[0]['total_cost'] == 0.0123
def test_run_letter_jobs(client, mocker):
job_ids = [str(uuid.uuid4()), str(uuid.uuid4())]
mocker.patch(
"app.celery.scheduled_tasks.dao_get_letter_jobs_by_status",
return_value=job_ids
)
mock_celery = mocker.patch("app.celery.tasks.notify_celery.send_task")
run_letter_jobs()
mock_celery.assert_called_once_with(name=QueueNames.DVLA_FILES,
args=(job_ids),
queue=QueueNames.PROCESS_FTP)