# Path: imap_tools/mailbox.py
# class MailBox(BaseMailBox):
#     """Working with the email box through IMAP4 over SSL connection"""
# 
#     def __init__(self, host='', port=993, timeout=None, keyfile=None, certfile=None, ssl_context=None):
#         """
#         :param host: host's name (default: localhost)
#         :param port: port number
#         :param timeout: timeout in seconds for the connection attempt, since python 3.9
#         :param keyfile: PEM formatted file that contains your private key (deprecated)
#         :param certfile: PEM formatted certificate chain file (deprecated)
#         :param ssl_context: SSLContext object that contains your certificate chain and private key
#         """
#         check_timeout_arg_support(timeout)
#         self._host = host
#         self._port = port
#         self._timeout = timeout
#         self._keyfile = keyfile
#         self._certfile = certfile
#         self._ssl_context = ssl_context
#         super().__init__()
# 
#     def _get_mailbox_client(self) -> imaplib.IMAP4:
#         if PYTHON_VERSION_MINOR < 9:
#             return imaplib.IMAP4_SSL(self._host, self._port, self._keyfile, self._certfile, self._ssl_context)
#         else:
#             return imaplib.IMAP4_SSL(self._host, self._port, self._keyfile, self._certfile, self._ssl_context,
#                                      self._timeout)
# 
# Path: tests/utils.py
# def get_test_mailbox_config(mailbox_name: str) -> dict:
#     config = configparser.ConfigParser()
#     for config_path in (r'../tests/credentials.ini', r'tests/credentials.ini'):
#         if not os.path.exists(config_path):
#             continue
#         config.read(config_path)
#         return dict(
#             host=config[mailbox_name]['host'],
#             email=config[mailbox_name]['email'],
#             password=config[mailbox_name]['password'],
#             path_separator=config[mailbox_name]['path_separator'],
#             test_folder=config[mailbox_name]['test_folder'],
#         )
# 
# TEST_MAILBOX_NAME_SET = {'YANDEX', 'ZIMBRA', 'MAIL_RU', 'OUTLOOK', 'GOOGLE', 'YAHOO'}


import unittest
from imap_tools import MailBox
from tests.utils import get_test_mailbox_config, TEST_MAILBOX_NAME_SET



class ConnectionTest(unittest.TestCase):
    def test_connection(self):
        # simple
        for test_mailbox_name in TEST_MAILBOX_NAME_SET:
            config = get_test_mailbox_config(test_mailbox_name)
            mailbox = MailBox(config['host'])
            self.assertIs(type(mailbox), MailBox)
            login_result = mailbox.login(config['email'], config['password'])
            self.assertEqual(login_result.login_result[0], 'OK')
            logout_result = mailbox.logout()
            self.assertEqual(logout_result[0], 'BYE')
        # with
        for test_mailbox_name in TEST_MAILBOX_NAME_SET:

# Path: imap_tools/mailbox.py
# class MailBox(BaseMailBox):
#     """Working with the email box through IMAP4 over SSL connection"""
# 
#     def __init__(self, host='', port=993, timeout=None, keyfile=None, certfile=None, ssl_context=None):
#         """
#         :param host: host's name (default: localhost)
#         :param port: port number
#         :param timeout: timeout in seconds for the connection attempt, since python 3.9
#         :param keyfile: PEM formatted file that contains your private key (deprecated)
#         :param certfile: PEM formatted certificate chain file (deprecated)
#         :param ssl_context: SSLContext object that contains your certificate chain and private key
#         """
#         check_timeout_arg_support(timeout)
#         self._host = host
#         self._port = port
#         self._timeout = timeout
#         self._keyfile = keyfile
#         self._certfile = certfile
#         self._ssl_context = ssl_context
#         super().__init__()
# 
#     def _get_mailbox_client(self) -> imaplib.IMAP4:
#         if PYTHON_VERSION_MINOR < 9:
#             return imaplib.IMAP4_SSL(self._host, self._port, self._keyfile, self._certfile, self._ssl_context)
#         else:
#             return imaplib.IMAP4_SSL(self._host, self._port, self._keyfile, self._certfile, self._ssl_context,
#                                      self._timeout)
# 
# Path: tests/utils.py
# def get_test_mailbox_config(mailbox_name: str) -> dict:
#     config = configparser.ConfigParser()
#     for config_path in (r'../tests/credentials.ini', r'tests/credentials.ini'):
#         if not os.path.exists(config_path):
#             continue
#         config.read(config_path)
#         return dict(
#             host=config[mailbox_name]['host'],
#             email=config[mailbox_name]['email'],
#             password=config[mailbox_name]['password'],
#             path_separator=config[mailbox_name]['path_separator'],
#             test_folder=config[mailbox_name]['test_folder'],
#         )
# 
# TEST_MAILBOX_NAME_SET = {'YANDEX', 'ZIMBRA', 'MAIL_RU', 'OUTLOOK', 'GOOGLE', 'YAHOO'}


# Path: tests/test_connection.py
import unittest
from imap_tools import MailBox
from tests.utils import get_test_mailbox_config, TEST_MAILBOX_NAME_SET




class ConnectionTest(unittest.TestCase):
    def test_connection(self):
        # simple
        for test_mailbox_name in TEST_MAILBOX_NAME_SET:
            config = get_test_mailbox_config(test_mailbox_name)
            mailbox = MailBox(config['host'])
            self.assertIs(type(mailbox), MailBox)
            login_result = mailbox.login(config['email'], config['password'])
            self.assertEqual(login_result.login_result[0], 'OK')
            logout_result = mailbox.logout()
            self.assertEqual(logout_result[0], 'BYE')
        # with
        for test_mailbox_name in TEST_MAILBOX_NAME_SET:

            config = get_test_mailbox_config(test_mailbox_name)