mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-26 02:11:41 -05:00
Merge pull request #304 from alphagov/loadtest-provider-3
Load testing client added
This commit is contained in:
@@ -11,6 +11,7 @@ from app.clients import Clients
|
||||
from app.clients.sms.mmg import MMGClient
|
||||
from app.clients.sms.twilio import TwilioClient
|
||||
from app.clients.sms.firetext import FiretextClient
|
||||
from app.clients.sms.loadtesting import LoadtestingClient
|
||||
from app.clients.email.aws_ses import AwsSesClient
|
||||
from app.encryption import Encryption
|
||||
|
||||
@@ -22,6 +23,7 @@ ma = Marshmallow()
|
||||
notify_celery = NotifyCelery()
|
||||
twilio_client = TwilioClient()
|
||||
firetext_client = FiretextClient()
|
||||
loadtest_client = LoadtestingClient()
|
||||
mmg_client = MMGClient()
|
||||
aws_ses_client = AwsSesClient()
|
||||
encryption = Encryption()
|
||||
@@ -46,11 +48,12 @@ def create_app(app_name=None):
|
||||
logging.init_app(application)
|
||||
twilio_client.init_app(application)
|
||||
firetext_client.init_app(application)
|
||||
loadtest_client.init_app(application)
|
||||
mmg_client.init_app(application.config)
|
||||
aws_ses_client.init_app(application.config['AWS_REGION'])
|
||||
notify_celery.init_app(application)
|
||||
encryption.init_app(application)
|
||||
clients.init_app(sms_clients=[firetext_client, mmg_client], email_clients=[aws_ses_client])
|
||||
clients.init_app(sms_clients=[firetext_client, mmg_client, loadtest_client], email_clients=[aws_ses_client])
|
||||
|
||||
from app.service.rest import service as service_blueprint
|
||||
from app.user.rest import user as user_blueprint
|
||||
|
||||
18
app/clients/sms/loadtesting.py
Normal file
18
app/clients/sms/loadtesting.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import logging
|
||||
from app.clients.sms.firetext import (
|
||||
FiretextClient
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class LoadtestingClient(FiretextClient):
|
||||
'''
|
||||
Loadtest sms client.
|
||||
'''
|
||||
|
||||
def init_app(self, config, *args, **kwargs):
|
||||
super(FiretextClient, self).__init__(*args, **kwargs)
|
||||
self.api_key = config.config.get('LOADTESTING_API_KEY')
|
||||
self.from_number = config.config.get('LOADTESTING_NUMBER')
|
||||
self.name = 'loadtesting'
|
||||
@@ -82,6 +82,8 @@ class Config(object):
|
||||
TWILIO_NUMBER = os.getenv('TWILIO_NUMBER')
|
||||
FIRETEXT_NUMBER = os.getenv('FIRETEXT_NUMBER')
|
||||
FIRETEXT_API_KEY = os.getenv("FIRETEXT_API_KEY")
|
||||
LOADTESTING_NUMBER = os.getenv('LOADTESTING_NUMBER')
|
||||
LOADTESTING_API_KEY = os.getenv("LOADTESTING_API_KEY")
|
||||
CSV_UPLOAD_BUCKET_NAME = 'local-notifications-csv-upload'
|
||||
NOTIFICATIONS_ALERT = 5 # five mins
|
||||
|
||||
|
||||
@@ -19,4 +19,6 @@ export FIRETEXT_API_KEY="Firetext"
|
||||
export FIRETEXT_NUMBER="Firetext"
|
||||
export NOTIFY_EMAIL_DOMAIN="test.notify.com"
|
||||
export MMG_API_KEY='mmg-secret-key'
|
||||
export MMG_FROM_NUMBER='test'
|
||||
export MMG_FROM_NUMBER='test'
|
||||
export LOADTESTING_API_KEY="loadtesting"
|
||||
export LOADTESTING_NUMBER="loadtesting"
|
||||
|
||||
27
migrations/versions/0013_add_loadtest_client.py
Normal file
27
migrations/versions/0013_add_loadtest_client.py
Normal file
@@ -0,0 +1,27 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0013_add_loadtest_client
|
||||
Revises: 0012_complete_provider_details
|
||||
Create Date: 2016-05-05 09:14:29.328841
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0013_add_loadtest_client'
|
||||
down_revision = '0012_complete_provider_details'
|
||||
|
||||
import uuid
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
|
||||
op.execute(
|
||||
"INSERT INTO provider_details (id, display_name, identifier, priority, notification_type, active) values ('{}', 'Loadtesting', 'loadtesting', 30, 'sms', true)".format(str(uuid.uuid4()))
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_table('provider_details')
|
||||
@@ -7,11 +7,11 @@ from app.dao.provider_details_dao import (
|
||||
|
||||
|
||||
def test_can_get_all_providers(notify_db, notify_db_session):
|
||||
assert len(get_provider_details()) == 3
|
||||
assert len(get_provider_details()) == 4
|
||||
|
||||
|
||||
def test_can_get_sms_providers(notify_db, notify_db_session):
|
||||
assert len(get_provider_details_by_notification_type('sms')) == 2
|
||||
assert len(get_provider_details_by_notification_type('sms')) == 3
|
||||
types = [provider.notification_type for provider in get_provider_details_by_notification_type('sms')]
|
||||
assert all('sms' == notification_type for notification_type in types)
|
||||
|
||||
@@ -21,6 +21,7 @@ def test_can_get_sms_providers_in_order(notify_db, notify_db_session):
|
||||
|
||||
assert providers[0].identifier == "mmg"
|
||||
assert providers[1].identifier == "firetext"
|
||||
assert providers[2].identifier == "loadtesting"
|
||||
|
||||
|
||||
def test_can_get_email_providers_in_order(notify_db, notify_db_session):
|
||||
|
||||
@@ -12,11 +12,12 @@ def test_get_provider_details_in_type_and_identifier_order(notify_db, notify_db_
|
||||
)
|
||||
assert response.status_code == 200
|
||||
json_resp = json.loads(response.get_data(as_text=True))['provider_details']
|
||||
assert len(json_resp) == 3
|
||||
assert len(json_resp) == 4
|
||||
|
||||
assert json_resp[0]['identifier'] == 'ses'
|
||||
assert json_resp[1]['identifier'] == 'mmg'
|
||||
assert json_resp[2]['identifier'] == 'firetext'
|
||||
assert json_resp[3]['identifier'] == 'loadtesting'
|
||||
|
||||
|
||||
def test_get_provider_details_by_id(notify_db, notify_db_session, notify_api):
|
||||
|
||||
Reference in New Issue
Block a user