mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-20 22:39:43 -04:00
Setup celery config
This commit is contained in:
@@ -49,7 +49,8 @@ def create_sms_notification():
|
|||||||
send_sms.apply_async((
|
send_sms.apply_async((
|
||||||
api_user['client'],
|
api_user['client'],
|
||||||
notification_id,
|
notification_id,
|
||||||
encryption.encrypt(notification)))
|
encryption.encrypt(notification)),
|
||||||
|
queue='sms')
|
||||||
return jsonify({'notification_id': notification_id}), 201
|
return jsonify({'notification_id': notification_id}), 201
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import os
|
import os
|
||||||
from datetime import timedelta
|
|
||||||
|
|
||||||
|
|
||||||
class Config(object):
|
class Config(object):
|
||||||
@@ -26,7 +25,7 @@ class Config(object):
|
|||||||
'region': 'eu-west-1',
|
'region': 'eu-west-1',
|
||||||
'polling_interval': 10, # 1 second
|
'polling_interval': 10, # 1 second
|
||||||
'visibility_timeout': 3600, # 1 hour
|
'visibility_timeout': 3600, # 1 hour
|
||||||
'queue_name_prefix': 'NOTIFY-CELERY-TEST-'
|
'queue_name_prefix': 'preview'
|
||||||
}
|
}
|
||||||
CELERY_ENABLE_UTC = True,
|
CELERY_ENABLE_UTC = True,
|
||||||
CELERY_TIMEZONE = 'Europe/London'
|
CELERY_TIMEZONE = 'Europe/London'
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import os
|
|
||||||
from app import notify_celery, create_app
|
from app import notify_celery, create_app
|
||||||
|
application = create_app()
|
||||||
application = create_app(os.getenv('NOTIFY_API_ENVIRONMENT') or 'development')
|
|
||||||
application.app_context().push()
|
application.app_context().push()
|
||||||
|
|||||||
6
scripts/run_celery.sh
Executable file
6
scripts/run_celery.sh
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
source environment.sh
|
||||||
|
celery -A run_celery.notify_celery worker --loglevel=INFO --concurrency=1 --autoreload -Q sms
|
||||||
@@ -30,7 +30,6 @@ def test_get_notification_by_id(notify_api, sample_notification):
|
|||||||
def test_get_notifications_empty_result(notify_api, sample_api_key):
|
def test_get_notifications_empty_result(notify_api, sample_api_key):
|
||||||
with notify_api.test_request_context():
|
with notify_api.test_request_context():
|
||||||
with notify_api.test_client() as client:
|
with notify_api.test_client() as client:
|
||||||
|
|
||||||
missing_notification_id = uuid.uuid4()
|
missing_notification_id = uuid.uuid4()
|
||||||
auth_header = create_authorization_header(
|
auth_header = create_authorization_header(
|
||||||
service_id=sample_api_key.service_id,
|
service_id=sample_api_key.service_id,
|
||||||
@@ -222,7 +221,8 @@ def test_should_allow_valid_sms_notification(notify_api, sample_template, mocker
|
|||||||
app.celery.tasks.send_sms.apply_async.assert_called_once_with(
|
app.celery.tasks.send_sms.apply_async.assert_called_once_with(
|
||||||
(str(sample_template.service_id),
|
(str(sample_template.service_id),
|
||||||
notification_id,
|
notification_id,
|
||||||
"something_encrypted")
|
"something_encrypted"),
|
||||||
|
queue="sms"
|
||||||
)
|
)
|
||||||
assert response.status_code == 201
|
assert response.status_code == 201
|
||||||
assert notification_id
|
assert notification_id
|
||||||
|
|||||||
Reference in New Issue
Block a user