示例#1
0
def test_process_sms_job_notification(mocker, app_, mock_twilio_create,
                                      mock_beta_get_template,
                                      mock_beta_create_notification,
                                      populate_queue_with_sms_job_msg):
    with mock_twilio_create:
        process_all_queues(app_.config,
                           app_.config['NOTIFICATION_QUEUE_PREFIX'])
        msg = populate_queue_with_sms_job_msg.receive_messages()[0]
        content = decrypt_content(app_.config, msg.body)
        service_id = msg.message_attributes.get('service_id').get(
            'StringValue')
        template_id = msg.message_attributes.get('template_id').get(
            'StringValue')
        notification_id = msg.message_attributes.get('notification_id').get(
            'StringValue')
        mock_beta_get_template.assert_called_with(service_id, template_id)
        template_json = mock_beta_get_template(service_id, template_id)
        mock_beta_create_notification.assert_called_with(
            service_id=service_id,
            template_id=template_id,
            job_id=content['job'],
            to=content['to'],
            status='sent',
            notification_id=notification_id)
        assert msg.delete.call_count == 1
示例#2
0
def test_process_sms_content_message(mocker, app_, mock_twilio_create,
                                     populate_queue_with_sms_content_msg):
    with mock_twilio_create:
        process_all_queues(app_.config,
                           app_.config['NOTIFICATION_QUEUE_PREFIX'])
        msg = populate_queue_with_sms_content_msg.receive_messages()[0]
        content = decrypt_content(app_.config, msg.body)
        assert msg.delete.call_count == 1
def test_process_sms_processing_error(mocker,
                                      app_,
                                      populate_queue_with_sms_content_msg,
                                      mock_twilio_create_exception):
    with mock_twilio_create_exception:
        process_all_queues(app_.config, app_.config['NOTIFICATION_QUEUE_PREFIX'])
        msg = populate_queue_with_sms_content_msg.receive_messages()[0]
        content = decrypt_content(app_.config, msg.body)
        assert msg.delete.call_count == 1
示例#4
0
def test_process_email_message(mocker, app_, mock_ses_send_email,
                               populate_queue_with_email_msg):
    process_all_queues(app_.config, app_.config['NOTIFICATION_QUEUE_PREFIX'])
    msg = populate_queue_with_email_msg.receive_messages()[0]
    content = decrypt_content(app_.config, msg.body)
    mock_ses_send_email.assert_called_with(content['from_address'],
                                           content['to_address'],
                                           content['subject'], content['body'])
    assert msg.delete.call_count == 1
def test_process_email_message(mocker,
                               app_,
                               mock_ses_send_email,
                               populate_queue_with_email_msg):
    process_all_queues(app_.config, app_.config['NOTIFICATION_QUEUE_PREFIX'])
    msg = populate_queue_with_email_msg.receive_messages()[0]
    content = decrypt_content(app_.config, msg.body)
    mock_ses_send_email.assert_called_with(
        content['from_address'], content['to_address'], content['subject'], content['body'])
    assert msg.delete.call_count == 1
def test_process_sms_template_message(mocker,
                                      app_,
                                      mock_twilio_create,
                                      mock_beta_get_template,
                                      populate_queue_with_sms_template_msg):
    with mock_twilio_create:
        process_all_queues(app_.config, app_.config['NOTIFICATION_QUEUE_PREFIX'])
        msg = populate_queue_with_sms_template_msg.receive_messages()[0]
        content = decrypt_content(app_.config, msg.body)
        service_id = msg.message_attributes.get('service_id').get('StringValue')
        template_id = msg.message_attributes.get('template_id').get('StringValue')
        mock_beta_get_template.assert_called_with(service_id, template_id)
        template_json = mock_beta_get_template(service_id, template_id)
        assert msg.delete.call_count == 1
示例#7
0
def test_process_sms_template_message(mocker, app_, mock_twilio_create,
                                      mock_beta_get_template,
                                      populate_queue_with_sms_template_msg):
    with mock_twilio_create:
        process_all_queues(app_.config,
                           app_.config['NOTIFICATION_QUEUE_PREFIX'])
        msg = populate_queue_with_sms_template_msg.receive_messages()[0]
        content = decrypt_content(app_.config, msg.body)
        service_id = msg.message_attributes.get('service_id').get(
            'StringValue')
        template_id = msg.message_attributes.get('template_id').get(
            'StringValue')
        mock_beta_get_template.assert_called_with(service_id, template_id)
        template_json = mock_beta_get_template(service_id, template_id)
        assert msg.delete.call_count == 1
def test_process_sms_job_notification(mocker,
                                      app_,
                                      mock_twilio_create,
                                      mock_beta_get_template,
                                      mock_beta_create_notification,
                                      populate_queue_with_sms_job_msg):
    with mock_twilio_create:
        process_all_queues(app_.config, app_.config['NOTIFICATION_QUEUE_PREFIX'])
        msg = populate_queue_with_sms_job_msg.receive_messages()[0]
        content = decrypt_content(app_.config, msg.body)
        service_id = msg.message_attributes.get('service_id').get('StringValue')
        template_id = msg.message_attributes.get('template_id').get('StringValue')
        notification_id = msg.message_attributes.get('notification_id').get('StringValue')
        mock_beta_get_template.assert_called_with(service_id, template_id)
        template_json = mock_beta_get_template(service_id, template_id)
        mock_beta_create_notification.assert_called_with(
            service_id=service_id, template_id=template_id, job_id=content['job'],
            to=content['to'], status='sent',
            notification_id=notification_id)
        assert msg.delete.call_count == 1
def process_queues():
    """Process all queues pulling one message from the queue."""
    # TODO possibly in the future have the prefix option on the management command.
    queue_name_prefix = application.config['NOTIFICATION_QUEUE_PREFIX']
    process_all_queues(application.config, queue_name_prefix)
def test_empty_queue(mocker,
                     app_,
                     create_queue_no_msgs):
    process_all_queues(app_.config, app_.config['NOTIFICATION_QUEUE_PREFIX'])
def process_queues():
    """Process all queues pulling one message from the queue."""
    # TODO possibly in the future have the prefix option on the management command.
    queue_name_prefix = application.config['NOTIFICATION_QUEUE_PREFIX']
    process_all_queues(application.config, queue_name_prefix)
示例#12
0
def test_empty_queue(mocker, app_, create_queue_no_msgs):
    process_all_queues(app_.config, app_.config['NOTIFICATION_QUEUE_PREFIX'])