mirror of
https://github.com/GSA/notifications-api.git
synced 2026-07-26 02:49:42 -04:00
Celery task to send the sms verify code.
Each celery task will use it's own queue.
This commit is contained in:
@@ -4,7 +4,9 @@ from datetime import (datetime, timedelta)
|
||||
from flask import url_for
|
||||
|
||||
from app.models import (VerifyCode)
|
||||
from app import db
|
||||
|
||||
import app.celery.tasks
|
||||
from app import db, encryption
|
||||
from tests import create_authorization_header
|
||||
|
||||
|
||||
@@ -247,13 +249,10 @@ def test_user_verify_password_missing_password(notify_api,
|
||||
assert 'Required field missing data' in json_resp['message']['password']
|
||||
|
||||
|
||||
@moto.mock_sqs
|
||||
def test_send_user_code_for_sms(notify_api,
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
sample_sms_code,
|
||||
sqs_client_conn,
|
||||
mock_secret_code):
|
||||
mock_secret_code,
|
||||
mock_celery_send_sms_code):
|
||||
"""
|
||||
Tests POST endpoint '/<user_id>/code' successful sms
|
||||
"""
|
||||
@@ -270,20 +269,20 @@ def test_send_user_code_for_sms(notify_api,
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
|
||||
assert resp.status_code == 204
|
||||
encrpyted = encryption.encrypt({'to': sample_sms_code.user.mobile_number, 'secret_code': '11111'})
|
||||
app.celery.tasks.send_sms_code.apply_async.assert_called_once_with([encrpyted], queue='sms_code')
|
||||
|
||||
|
||||
@moto.mock_sqs
|
||||
def test_send_user_code_for_sms_with_optional_to_field(notify_api,
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
sample_sms_code,
|
||||
sqs_client_conn,
|
||||
mock_secret_code):
|
||||
mock_secret_code,
|
||||
mock_celery_send_sms_code):
|
||||
"""
|
||||
Tests POST endpoint '/<user_id>/code' successful sms with optional to field
|
||||
"""
|
||||
with notify_api.test_request_context():
|
||||
with notify_api.test_client() as client:
|
||||
|
||||
data = json.dumps({'code_type': 'sms', 'to': '+441119876757'})
|
||||
auth_header = create_authorization_header(
|
||||
path=url_for('user.send_user_code', user_id=sample_sms_code.user.id),
|
||||
@@ -295,6 +294,8 @@ def test_send_user_code_for_sms_with_optional_to_field(notify_api,
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
|
||||
assert resp.status_code == 204
|
||||
encrpyted = encryption.encrypt({'to': '+441119876757', 'secret_code': '11111'})
|
||||
app.celery.tasks.send_sms_code.apply_async.assert_called_once_with([encrpyted], queue='sms_code')
|
||||
|
||||
|
||||
@moto.mock_sqs
|
||||
|
||||
Reference in New Issue
Block a user