mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 14:31:57 -05:00
rename clients to notification_provider_clients
i think it's causing havoc with my attempts to mock stuff in the `app.clients` directory because it's also accessible at that path. the name's super vague and doesn't explain what it is anyway
This commit is contained in:
@@ -22,7 +22,7 @@ from werkzeug.exceptions import HTTPException as WerkzeugHTTPException
|
|||||||
from werkzeug.local import LocalProxy
|
from werkzeug.local import LocalProxy
|
||||||
|
|
||||||
from app.celery.celery import NotifyCelery
|
from app.celery.celery import NotifyCelery
|
||||||
from app.clients import Clients
|
from app.clients import NotificationProviderClients
|
||||||
from app.clients.cbc_proxy import CBCProxyClient, CBCProxyNoopClient
|
from app.clients.cbc_proxy import CBCProxyClient, CBCProxyNoopClient
|
||||||
from app.clients.document_download import DocumentDownloadClient
|
from app.clients.document_download import DocumentDownloadClient
|
||||||
from app.clients.email.aws_ses import AwsSesClient
|
from app.clients.email.aws_ses import AwsSesClient
|
||||||
@@ -65,7 +65,7 @@ cbc_proxy_client = CBCProxyNoopClient()
|
|||||||
document_download_client = DocumentDownloadClient()
|
document_download_client = DocumentDownloadClient()
|
||||||
metrics = GDSMetrics()
|
metrics = GDSMetrics()
|
||||||
|
|
||||||
clients = Clients()
|
notification_provider_clients = NotificationProviderClients()
|
||||||
|
|
||||||
api_user = LocalProxy(lambda: _request_ctx_stack.top.api_user)
|
api_user = LocalProxy(lambda: _request_ctx_stack.top.api_user)
|
||||||
authenticated_service = LocalProxy(lambda: _request_ctx_stack.top.authenticated_service)
|
authenticated_service = LocalProxy(lambda: _request_ctx_stack.top.authenticated_service)
|
||||||
@@ -106,7 +106,7 @@ def create_app(application):
|
|||||||
)
|
)
|
||||||
# If a stub url is provided for SES, then use the stub client rather than the real SES boto client
|
# If a stub url is provided for SES, then use the stub client rather than the real SES boto client
|
||||||
email_clients = [aws_ses_stub_client] if application.config['SES_STUB_URL'] else [aws_ses_client]
|
email_clients = [aws_ses_stub_client] if application.config['SES_STUB_URL'] else [aws_ses_client]
|
||||||
clients.init_app(sms_clients=[firetext_client, mmg_client], email_clients=email_clients)
|
notification_provider_clients.init_app(sms_clients=[firetext_client, mmg_client], email_clients=email_clients)
|
||||||
|
|
||||||
notify_celery.init_app(application)
|
notify_celery.init_app(application)
|
||||||
encryption.init_app(application)
|
encryption.init_app(application)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ STATISTICS_DELIVERED = 'delivered'
|
|||||||
STATISTICS_FAILURE = 'failure'
|
STATISTICS_FAILURE = 'failure'
|
||||||
|
|
||||||
|
|
||||||
class Clients(object):
|
class NotificationProviderClients(object):
|
||||||
sms_clients = {}
|
sms_clients = {}
|
||||||
email_clients = {}
|
email_clients = {}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from notifications_utils.recipients import (
|
|||||||
)
|
)
|
||||||
from notifications_utils.template import HTMLEmailTemplate, PlainTextEmailTemplate, SMSMessageTemplate
|
from notifications_utils.template import HTMLEmailTemplate, PlainTextEmailTemplate, SMSMessageTemplate
|
||||||
|
|
||||||
from app import clients, statsd_client, create_uuid
|
from app import notification_provider_clients, statsd_client, create_uuid
|
||||||
from app.dao.notifications_dao import (
|
from app.dao.notifications_dao import (
|
||||||
dao_update_notification
|
dao_update_notification
|
||||||
)
|
)
|
||||||
@@ -144,7 +144,7 @@ def provider_to_use(notification_type, international=False):
|
|||||||
|
|
||||||
chosen_provider = random.choices(active_providers, weights=[p.priority for p in active_providers])[0]
|
chosen_provider = random.choices(active_providers, weights=[p.priority for p in active_providers])[0]
|
||||||
|
|
||||||
return clients.get_client_by_name_and_type(chosen_provider.identifier, notification_type)
|
return notification_provider_clients.get_client_by_name_and_type(chosen_provider.identifier, notification_type)
|
||||||
|
|
||||||
|
|
||||||
def get_logo_url(base_url, logo_file):
|
def get_logo_url(base_url, logo_file):
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from freezegun import freeze_time
|
|||||||
from sqlalchemy.sql import desc
|
from sqlalchemy.sql import desc
|
||||||
|
|
||||||
from app.models import ProviderDetails, ProviderDetailsHistory
|
from app.models import ProviderDetails, ProviderDetailsHistory
|
||||||
from app import clients
|
from app import notification_provider_clients
|
||||||
from app.dao.provider_details_dao import (
|
from app.dao.provider_details_dao import (
|
||||||
get_alternative_sms_provider,
|
get_alternative_sms_provider,
|
||||||
get_provider_details_by_identifier,
|
get_provider_details_by_identifier,
|
||||||
@@ -76,7 +76,7 @@ def test_can_get_email_providers(notify_db_session):
|
|||||||
def test_should_not_error_if_any_provider_in_code_not_in_database(restore_provider_details):
|
def test_should_not_error_if_any_provider_in_code_not_in_database(restore_provider_details):
|
||||||
ProviderDetails.query.filter_by(identifier='mmg').delete()
|
ProviderDetails.query.filter_by(identifier='mmg').delete()
|
||||||
|
|
||||||
assert clients.get_sms_client('mmg')
|
assert notification_provider_clients.get_sms_client('mmg')
|
||||||
|
|
||||||
|
|
||||||
@freeze_time('2000-01-01T00:00:00')
|
@freeze_time('2000-01-01T00:00:00')
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from notifications_utils.recipients import validate_and_format_phone_number
|
|||||||
from requests import HTTPError
|
from requests import HTTPError
|
||||||
|
|
||||||
import app
|
import app
|
||||||
from app import clients, mmg_client, firetext_client
|
from app import notification_provider_clients, mmg_client, firetext_client
|
||||||
from app.dao import notifications_dao
|
from app.dao import notifications_dao
|
||||||
from app.dao.provider_details_dao import get_provider_details_by_identifier
|
from app.dao.provider_details_dao import get_provider_details_by_identifier
|
||||||
from app.delivery import send_to_providers
|
from app.delivery import send_to_providers
|
||||||
@@ -535,7 +535,10 @@ def test_update_notification_to_sending_does_not_update_status_from_a_final_stat
|
|||||||
):
|
):
|
||||||
template = create_template(sample_service)
|
template = create_template(sample_service)
|
||||||
notification = create_notification(template=template, status=starting_status)
|
notification = create_notification(template=template, status=starting_status)
|
||||||
send_to_providers.update_notification_to_sending(notification, clients.get_client_by_name_and_type("mmg", "sms"))
|
send_to_providers.update_notification_to_sending(
|
||||||
|
notification,
|
||||||
|
notification_provider_clients.get_client_by_name_and_type("mmg", "sms")
|
||||||
|
)
|
||||||
assert notification.status == expected_status
|
assert notification.status == expected_status
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user