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
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)")
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
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
def _get_sender(): return queuelib.QueueSender( queue=_get_queue(), sendmail=_get_sendmail(), )