# Path: aiosmtplib/errors.py
# class SMTPAuthenticationError(SMTPResponseException):
#     """
#     Server refused our AUTH request; may be caused by invalid credentials.
#     """
# 
# class SMTPConnectError(SMTPException, ConnectionError):
#     """
#     An error occurred while connecting to the SMTP server.
#     """
# 
# class SMTPConnectTimeoutError(SMTPTimeoutError, SMTPConnectError):
#     """
#     A timeout occurred while connecting to the SMTP server.
#     """
# 
# class SMTPDataError(SMTPResponseException):
#     """
#     Server refused DATA content.
#     """
# 
# class SMTPException(Exception):
#     """
#     Base class for all SMTP exceptions.
#     """
# 
#     def __init__(self, message: str) -> None:
#         self.message = message
#         self.args = (message,)
# 
# class SMTPHeloError(SMTPResponseException):
#     """
#     Server refused HELO or EHLO.
#     """
# 
# class SMTPNotSupported(SMTPException):
#     """
#     A command or argument sent to the SMTP server is not supported.
#     """
# 
# class SMTPReadTimeoutError(SMTPTimeoutError):
#     """
#     A timeout occurred while waiting for a response from the SMTP server.
#     """
# 
# class SMTPRecipientRefused(SMTPResponseException):
#     """
#     SMTP server refused a message recipient.
#     """
# 
#     def __init__(self, code: int, message: str, recipient: str) -> None:
#         self.code = code
#         self.message = message
#         self.recipient = recipient
#         self.args = (code, message, recipient)
# 
# class SMTPRecipientsRefused(SMTPException):
#     """
#     SMTP server refused multiple recipients.
#     """
# 
#     def __init__(self, recipients: List[SMTPRecipientRefused]) -> None:
#         self.recipients = recipients
#         self.args = (recipients,)
# 
# class SMTPResponseException(SMTPException):
#     """
#     Base class for all server responses with error codes.
#     """
# 
#     def __init__(self, code: int, message: str) -> None:
#         self.code = code
#         self.message = message
#         self.args = (code, message)
# 
# class SMTPSenderRefused(SMTPResponseException):
#     """
#     SMTP server refused the message sender.
#     """
# 
#     def __init__(self, code: int, message: str, sender: str) -> None:
#         self.code = code
#         self.message = message
#         self.sender = sender
#         self.args = (code, message, sender)
# 
# class SMTPServerDisconnected(SMTPException, ConnectionError):
#     """
#     The connection was lost unexpectedly, or a command was run that requires
#     a connection.
#     """
# 
# class SMTPTimeoutError(SMTPException, TimeoutError):
#     """
#     A timeout occurred while performing a network operation.
#     """


import asyncio
import pytest
from hypothesis import given
from hypothesis.strategies import integers, lists, text
from aiosmtplib import (
    SMTPAuthenticationError,
    SMTPConnectError,
    SMTPConnectTimeoutError,
    SMTPDataError,
    SMTPException,
    SMTPHeloError,
    SMTPNotSupported,
    SMTPReadTimeoutError,
    SMTPRecipientRefused,
    SMTPRecipientsRefused,
    SMTPResponseException,
    SMTPSenderRefused,
    SMTPServerDisconnected,
    SMTPTimeoutError,
)

@pytest.mark.parametrize(
    "error_class", (SMTPTimeoutError, SMTPConnectTimeoutError, SMTPReadTimeoutError)
)
@given(message=text())
def test_timeout_exceptions(message, error_class):
    with pytest.raises(error_class) as excinfo:
        raise error_class(message)

    assert issubclass(excinfo.type, SMTPException)
    assert issubclass(excinfo.type, asyncio.TimeoutError)
    assert excinfo.value.message == message


@pytest.mark.parametrize(
    "error_class", (SMTPHeloError, SMTPDataError, SMTPAuthenticationError)
)
@given(code=integers(), message=text())
def test_simple_response_exceptions(code, message, error_class):
    with pytest.raises(error_class) as excinfo:
        raise error_class(code, message)

    assert issubclass(excinfo.type, SMTPResponseException)
    assert excinfo.value.code == code
    assert excinfo.value.message == message


@given(integers(), text(), text())
def test_raise_smtp_sender_refused(code, message, sender):
    with pytest.raises(SMTPSenderRefused) as excinfo:

# Path: aiosmtplib/errors.py
# class SMTPAuthenticationError(SMTPResponseException):
#     """
#     Server refused our AUTH request; may be caused by invalid credentials.
#     """
# 
# class SMTPConnectError(SMTPException, ConnectionError):
#     """
#     An error occurred while connecting to the SMTP server.
#     """
# 
# class SMTPConnectTimeoutError(SMTPTimeoutError, SMTPConnectError):
#     """
#     A timeout occurred while connecting to the SMTP server.
#     """
# 
# class SMTPDataError(SMTPResponseException):
#     """
#     Server refused DATA content.
#     """
# 
# class SMTPException(Exception):
#     """
#     Base class for all SMTP exceptions.
#     """
# 
#     def __init__(self, message: str) -> None:
#         self.message = message
#         self.args = (message,)
# 
# class SMTPHeloError(SMTPResponseException):
#     """
#     Server refused HELO or EHLO.
#     """
# 
# class SMTPNotSupported(SMTPException):
#     """
#     A command or argument sent to the SMTP server is not supported.
#     """
# 
# class SMTPReadTimeoutError(SMTPTimeoutError):
#     """
#     A timeout occurred while waiting for a response from the SMTP server.
#     """
# 
# class SMTPRecipientRefused(SMTPResponseException):
#     """
#     SMTP server refused a message recipient.
#     """
# 
#     def __init__(self, code: int, message: str, recipient: str) -> None:
#         self.code = code
#         self.message = message
#         self.recipient = recipient
#         self.args = (code, message, recipient)
# 
# class SMTPRecipientsRefused(SMTPException):
#     """
#     SMTP server refused multiple recipients.
#     """
# 
#     def __init__(self, recipients: List[SMTPRecipientRefused]) -> None:
#         self.recipients = recipients
#         self.args = (recipients,)
# 
# class SMTPResponseException(SMTPException):
#     """
#     Base class for all server responses with error codes.
#     """
# 
#     def __init__(self, code: int, message: str) -> None:
#         self.code = code
#         self.message = message
#         self.args = (code, message)
# 
# class SMTPSenderRefused(SMTPResponseException):
#     """
#     SMTP server refused the message sender.
#     """
# 
#     def __init__(self, code: int, message: str, sender: str) -> None:
#         self.code = code
#         self.message = message
#         self.sender = sender
#         self.args = (code, message, sender)
# 
# class SMTPServerDisconnected(SMTPException, ConnectionError):
#     """
#     The connection was lost unexpectedly, or a command was run that requires
#     a connection.
#     """
# 
# class SMTPTimeoutError(SMTPException, TimeoutError):
#     """
#     A timeout occurred while performing a network operation.
#     """


# Path: tests/test_errors.py
import asyncio
import pytest
from hypothesis import given
from hypothesis.strategies import integers, lists, text
from aiosmtplib import (
    SMTPAuthenticationError,
    SMTPConnectError,
    SMTPConnectTimeoutError,
    SMTPDataError,
    SMTPException,
    SMTPHeloError,
    SMTPNotSupported,
    SMTPReadTimeoutError,
    SMTPRecipientRefused,
    SMTPRecipientsRefused,
    SMTPResponseException,
    SMTPSenderRefused,
    SMTPServerDisconnected,
    SMTPTimeoutError,
)


@pytest.mark.parametrize(
    "error_class", (SMTPTimeoutError, SMTPConnectTimeoutError, SMTPReadTimeoutError)
)
@given(message=text())
def test_timeout_exceptions(message, error_class):
    with pytest.raises(error_class) as excinfo:
        raise error_class(message)

    assert issubclass(excinfo.type, SMTPException)
    assert issubclass(excinfo.type, asyncio.TimeoutError)
    assert excinfo.value.message == message


@pytest.mark.parametrize(
    "error_class", (SMTPHeloError, SMTPDataError, SMTPAuthenticationError)
)
@given(code=integers(), message=text())
def test_simple_response_exceptions(code, message, error_class):
    with pytest.raises(error_class) as excinfo:
        raise error_class(code, message)

    assert issubclass(excinfo.type, SMTPResponseException)
    assert excinfo.value.code == code
    assert excinfo.value.message == message


@given(integers(), text(), text())
def test_raise_smtp_sender_refused(code, message, sender):
    with pytest.raises(SMTPSenderRefused) as excinfo:

        raise SMTPSenderRefused(code, message, sender)