def get_message_status_checker(notification_type, provider):
    def check_nothing(*args, **kwargs):
        current_app.logger.debug(
            f"get_message_status_checker: no status checker available for type {notification_type}"
        )
        yield from ()

    def status_checker(client):
        def check_status(*args, **kwargs):
            if not isinstance(client, PollableSMSClient):
                current_app.logger.debug(
                    f"get_message_status_checker: provider {provider} does not support status checks"
                )
                return

            yield from client.check_message_status(*args, **kwargs)

        return check_status

    if notification_type == SMS_TYPE:
        client = clients.get_sms_client(provider)
        return status_checker(client)

    return check_nothing
Example #2
0
def test_should_not_error_if_any_provider_in_code_not_in_database(
        restore_provider_details):
    ProviderDetails.query.filter_by(identifier='mmg').delete()

    assert clients.get_sms_client('mmg')
def test_should_not_error_if_any_provider_in_code_not_in_database(restore_provider_details):
    providers = ProviderDetails.query.all()

    ProviderDetails.query.filter_by(identifier='mmg').delete()

    assert clients.get_sms_client('mmg')