Files
notifications-api/app/clients/__init__.py
Christa Hartsock af6495cd4c Get tests passing locally
When we cloned the repository and started making modifications, we
didn't initially keep tests in step. This commit tries to get us to a
clean test run by skipping tests that are failing and removing some
that we no longer expect to use (MMG, Firetext), with the intention that
we will come back in future and update or remove them as appropriate.

To find all tests skipped, search for `@pytest.mark.skip(reason="Needs
updating for TTS:`. There will be a brief description of the work that
needs to be done to get them passing, if known. Delete that line to make
them run in a standard test run (`make test`).
2022-07-07 15:41:15 -07:00

48 lines
1.1 KiB
Python

from celery import current_app
class ClientException(Exception):
'''
Base Exceptions for sending notifications that fail
'''
pass
class Client(object):
'''
Base client for sending notifications.
'''
pass
STATISTICS_REQUESTED = 'requested'
STATISTICS_DELIVERED = 'delivered'
STATISTICS_FAILURE = 'failure'
class NotificationProviderClients(object):
sms_clients = {}
email_clients = {}
def init_app(self, sms_clients, email_clients):
for client in sms_clients:
self.sms_clients[client.name] = client
for client in email_clients:
self.email_clients[client.name] = client
def get_sms_client(self, name):
return self.sms_clients.get(name)
def get_email_client(self, name):
return self.email_clients.get(name)
def get_client_by_name_and_type(self, name, notification_type):
assert notification_type in ['email', 'sms']
if notification_type == 'email':
return self.get_email_client(name)
if notification_type == 'sms':
return self.get_sms_client(name)