示例#1
0
def test_raise_smtp_response_exception(code, message):
    with pytest.raises(SMTPResponseException) as excinfo:
        raise SMTPResponseException(code, message)

    assert issubclass(excinfo.type, SMTPException)
    assert excinfo.value.code == code
    assert excinfo.value.message == message
async def test_send_exception(mock_smtp):

    mock_smtp.raise_on_send(SMTPRecipientsRefused(mail.to))

    with pytest.raises(FailedToSendMessage):
        await send(mail, templates)

    mock_smtp.raise_on_send(SMTPResponseException(404, "Message"))

    with pytest.raises(FailedToSendMessage):
        await send(mail, templates)

    mock_smtp.reset_exceptions()