# Path: aiosmtplib/errors.py
# class SMTPDataError(SMTPResponseException):
#     """
#     Server refused DATA content.
#     """
# 
# class SMTPHeloError(SMTPResponseException):
#     """
#     Server refused HELO or EHLO.
#     """
# 
# class SMTPNotSupported(SMTPException):
#     """
#     A command or argument sent to the SMTP server is not supported.
#     """
# 
# 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)
# 
# Path: aiosmtplib/status.py
# class SMTPStatus(enum.IntEnum):
#     """
#     Defines SMTP statuses for code readability.
# 
#     See also: http://www.greenend.org.uk/rjk/tech/smtpreplies.html
#     """
# 
#     invalid_response = -1
#     system_status_ok = 211
#     help_message = 214
#     ready = 220
#     closing = 221
#     auth_successful = 235
#     completed = 250
#     will_forward = 251
#     cannot_vrfy = 252
#     auth_continue = 334
#     start_input = 354
#     domain_unavailable = 421
#     mailbox_unavailable = 450
#     error_processing = 451
#     insufficient_storage = 452
#     tls_not_available = 454
#     unrecognized_command = 500
#     unrecognized_parameters = 501
#     command_not_implemented = 502
#     bad_command_sequence = 503
#     parameter_not_implemented = 504
#     domain_does_not_accept_mail = 521
#     access_denied = 530  # Sendmail specific
#     auth_failed = 535
#     mailbox_does_not_exist = 550
#     user_not_local = 551
#     storage_exceeded = 552
#     mailbox_name_invalid = 553
#     transaction_failed = 554
#     syntax_error = 555


import pytest
from aiosmtplib import (
    SMTPDataError,
    SMTPHeloError,
    SMTPNotSupported,
    SMTPResponseException,
    SMTPStatus,
)
    smtpd_class,
    smtpd_response_handler_factory,
    monkeypatch,
    error_code,
):
    response_handler = smtpd_response_handler_factory("{} error".format(error_code))
    monkeypatch.setattr(smtpd_class, "smtp_DATA", response_handler)

    async with smtp_client:
        await smtp_client.mail("admin@example.com")
        await smtp_client.rcpt("test@example.com")
        with pytest.raises(SMTPDataError) as exception_info:
            await smtp_client.data("TEST MESSAGE")
        assert exception_info.value.code == error_code


async def test_data_complete_error(
    smtp_client,
    smtpd_server,
    smtpd_handler,
    smtpd_response_handler_factory,
    monkeypatch,
    error_code,
):
    response_handler = smtpd_response_handler_factory("{} error".format(error_code))
    monkeypatch.setattr(smtpd_handler, "handle_DATA", response_handler)

    async with smtp_client:
        await smtp_client.mail("admin@example.com")
        await smtp_client.rcpt("test@example.com")

# Path: aiosmtplib/errors.py
# class SMTPDataError(SMTPResponseException):
#     """
#     Server refused DATA content.
#     """
# 
# class SMTPHeloError(SMTPResponseException):
#     """
#     Server refused HELO or EHLO.
#     """
# 
# class SMTPNotSupported(SMTPException):
#     """
#     A command or argument sent to the SMTP server is not supported.
#     """
# 
# 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)
# 
# Path: aiosmtplib/status.py
# class SMTPStatus(enum.IntEnum):
#     """
#     Defines SMTP statuses for code readability.
# 
#     See also: http://www.greenend.org.uk/rjk/tech/smtpreplies.html
#     """
# 
#     invalid_response = -1
#     system_status_ok = 211
#     help_message = 214
#     ready = 220
#     closing = 221
#     auth_successful = 235
#     completed = 250
#     will_forward = 251
#     cannot_vrfy = 252
#     auth_continue = 334
#     start_input = 354
#     domain_unavailable = 421
#     mailbox_unavailable = 450
#     error_processing = 451
#     insufficient_storage = 452
#     tls_not_available = 454
#     unrecognized_command = 500
#     unrecognized_parameters = 501
#     command_not_implemented = 502
#     bad_command_sequence = 503
#     parameter_not_implemented = 504
#     domain_does_not_accept_mail = 521
#     access_denied = 530  # Sendmail specific
#     auth_failed = 535
#     mailbox_does_not_exist = 550
#     user_not_local = 551
#     storage_exceeded = 552
#     mailbox_name_invalid = 553
#     transaction_failed = 554
#     syntax_error = 555


# Path: tests/test_commands.py
import pytest
from aiosmtplib import (
    SMTPDataError,
    SMTPHeloError,
    SMTPNotSupported,
    SMTPResponseException,
    SMTPStatus,
)

    smtpd_class,
    smtpd_response_handler_factory,
    monkeypatch,
    error_code,
):
    response_handler = smtpd_response_handler_factory("{} error".format(error_code))
    monkeypatch.setattr(smtpd_class, "smtp_DATA", response_handler)

    async with smtp_client:
        await smtp_client.mail("admin@example.com")
        await smtp_client.rcpt("test@example.com")
        with pytest.raises(SMTPDataError) as exception_info:
            await smtp_client.data("TEST MESSAGE")
        assert exception_info.value.code == error_code


async def test_data_complete_error(
    smtp_client,
    smtpd_server,
    smtpd_handler,
    smtpd_response_handler_factory,
    monkeypatch,
    error_code,
):
    response_handler = smtpd_response_handler_factory("{} error".format(error_code))
    monkeypatch.setattr(smtpd_handler, "handle_DATA", response_handler)

    async with smtp_client:
        await smtp_client.mail("admin@example.com")
        await smtp_client.rcpt("test@example.com")

        with pytest.raises(SMTPDataError) as exception_info: