def test_send_sms_messages_to_queue_adds_message_queue(notify_api):
    q = set_up_mock_queue('sms')
    sms = Notification(to='+441234512345',
                       message='hello world',
                       job_id=1234)
    q.send_message(MessageBody=json.dumps(sms.serialize()),
                   MessageAttributes={'type': {'StringValue': 'sms', 'DataType': 'String'}})

    messages = [notification]
    b = send_messages_to_queue('sms', messages)
    assert b is True
Пример #2
0
def test_send_sms_messages_to_queue_adds_message_queue(notify_api):
    q = set_up_mock_queue('sms')
    sms = Notification(to='+441234512345', message='hello world', job_id=1234)
    q.send_message(MessageBody=json.dumps(sms.serialize()),
                   MessageAttributes={
                       'type': {
                           'StringValue': 'sms',
                           'DataType': 'String'
                       }
                   })

    messages = [notification]
    b = send_messages_to_queue('sms', messages)
    assert b is True
Пример #3
0
def set_up_mock_queue():
    # set up mock queue
    boto3.setup_default_session(region_name='eu-west-1')
    conn = boto3.resource('sqs')
    q = conn.create_queue(QueueName='gov_uk_notify_email_queue')
    notification = Notification(id=1234,
                                to='*****@*****.**',
                                sender='*****@*****.**',
                                message='notification message',
                                status='created',
                                method='email',
                                created_at=datetime.utcnow(),
                                job=Job(id=1234, name='jobname',
                                        filename='filename',
                                        created_at=datetime.utcnow(), service_id=1234))

    q.send_message(MessageBody=json.dumps(notification.serialize()),
                   MessageAttributes={'type': {'StringValue': 'email', 'DataType': 'String'}})
    return q