Pulled out the tests that send SMSs into provider_tasks file/tests

- updated tests to validate creation of next task, not sending direct to provider
This commit is contained in:
Martyn Inglis
2016-06-07 12:53:31 +01:00
parent 37fe2342ae
commit 92e4c0872b
5 changed files with 199 additions and 223 deletions

View File

@@ -35,6 +35,7 @@ retry_iteration_to_delay = {
4: 60 * 30 # 30 minutes
}
@notify_celery.task(bind=True, name="send-sms-to-provider", max_retries=5, default_retry_delay=5)
def send_sms_to_provider(self, service_id, notification_id, encrypted_notification):
task_start = monotonic()
@@ -92,7 +93,7 @@ def send_sms_to_provider(self, service_id, notification_id, encrypted_notificati
)
statsd_client.incr("notifications.tasks.send-sms-to-provider")
statsd_client.timing("notifications.tasks.send-sms-to-provider.task-time", monotonic() - task_start)
statsd_client.timing("notifications.sms.total-time", monotonic() - notification.created_at)
statsd_client.timing("notifications.sms.total-time", notification.sent_at - notification.created_at)
def provider_to_use(notification_type, notification_id):

View File

@@ -3,6 +3,7 @@ from datetime import datetime
from flask import current_app
from monotonic import monotonic
from sqlalchemy.exc import SQLAlchemyError
from app import clients, statsd_client
from app.clients.email import EmailClientException
@@ -10,7 +11,7 @@ from app.clients.sms import SmsClientException
from app.dao.services_dao import dao_fetch_service_by_id
from app.dao.templates_dao import dao_get_template_by_id
from app.dao.provider_details_dao import get_provider_details_by_notification_type
from app.celery.research_mode_tasks import send_email_response, send_sms_response
from app.celery.research_mode_tasks import send_email_response
from app.celery.provider_tasks import (
send_sms_to_provider
)
@@ -285,7 +286,7 @@ def send_email(service_id, notification_id, from_address, encrypted_notification
sent_by=provider.get_name()
)
dao_create_notification(notification_db_object, TEMPLATE_TYPE_EMAIL, provider.get_name())
dao_create_notification(notification_db_object, TEMPLATE_TYPE_EMAIL)
statsd_client.timing_with_dates(
"notifications.tasks.send-email.queued-for",
sent_at,