Exemplo n.º 1
0
def test_sender_send_all(queue, sendmail):
    sender = queuelib.QueueSender(queue=queue, sendmail=sendmail)
    queue['sophie'] = mock.sentinel.sophie
    queue['prachta'] = mock.sentinel.prachta
    with mock.patch.object(type(sender), 'send') as send:
        sender.send_all()
    assert mock.call('sophie') in send.call_args_list
    assert mock.call('prachta') in send.call_args_list
Exemplo n.º 2
0
def test_sender_repr():
    sender = queuelib.QueueSender(
        queue=mock.sentinel.queue,
        sendmail=mock.sentinel.sendmail,
    )
    got = repr(sender)
    assert got == ("QueueSender(queue=sentinel.queue,"
                   " sendmail=sentinel.sendmail)")
Exemplo n.º 3
0
def test_sender_send_error(queue, sendmail):
    sendmail.side_effect = queuelib.SendmailError
    sender = queuelib.QueueSender(queue=queue, sendmail=sendmail)
    message = queuelib.Message(
        args=['foo'],
        message='Sophie is cute.',
    )
    queue['sophie'] = message
    sender.send('sophie')
    assert 'sophie' in queue
Exemplo n.º 4
0
def test_sender_send(queue, sendmail):
    sender = queuelib.QueueSender(queue=queue, sendmail=sendmail)
    message = queuelib.Message(
        args=['foo'],
        message='Sophie is cute.',
    )
    queue['sophie'] = message
    sender.send('sophie')
    assert len(sendmail.call_args_list) == 1
    assert sendmail.call_args == mock.call(message)
    assert 'sophie' not in queue
Exemplo n.º 5
0
def _get_sender():
    return queuelib.QueueSender(
        queue=_get_queue(),
        sendmail=_get_sendmail(),
    )