# Path: tests/utils.py
# class MailboxTestCase(unittest.TestCase):
#     def setUp(self):
#         self.mailbox_set = dict()
#         for test_mailbox_name in TEST_MAILBOX_NAME_SET:
#             self.mailbox_set[test_mailbox_name] = get_test_mailbox(test_mailbox_name)
# 
#     def tearDown(self):
#         for mailbox in self.mailbox_set.values():
#             mailbox.logout()
# 
# TEST_MAILBOX_NAME_SET = {'YANDEX', 'ZIMBRA', 'MAIL_RU', 'OUTLOOK', 'GOOGLE', 'YAHOO'}
# 
# def get_test_mailbox(mailbox_name: str):
#     # get config
#     config = get_test_mailbox_config(mailbox_name)
# 
#     # add test attributes to MailBox
#     class TestMailBox(MailBox):
#         def __init__(self, *args):
#             super().__init__(*args)
#             test_folder = config['test_folder']
#             path_separator = config['path_separator']
#             self.folder_test = '{}'.format(test_folder)
#             self.folder_test_base = '{}{}base'.format(test_folder, path_separator)
#             self.folder_test_temp1 = '{}{}temp1'.format(test_folder, path_separator)
#             self.folder_test_temp2 = '{}{}temp2'.format(test_folder, path_separator)
#             self.folder_test_new = '{}{}new'.format(test_folder, path_separator)
#             self.folder_test_new1 = '{}{}new1'.format(test_folder, path_separator)
#             self.mailbox_name = mailbox_name
# 
#     # create mailbox instance
#     mailbox = TestMailBox(config['host'])
#     # connect
#     mailbox.login(config['email'], config['password'])
#     # done
#     return mailbox
# 
# Path: imap_tools/errors.py
# class MailboxFolderSelectError(UnexpectedCommandStatusError):
#     pass


import unittest
from tests.utils import MailboxTestCase, TEST_MAILBOX_NAME_SET, get_test_mailbox
from imap_tools.errors import MailboxFolderSelectError
            mailbox.folder.rename(mailbox.folder_test_new, mailbox.folder_test_new1)
            folder_list_names = [i.name for i in mailbox.folder.list(mailbox.folder_test)]
            self.assertTrue(mailbox.folder_test_new1 in folder_list_names)
            self.assertFalse(mailbox.folder_test_new in folder_list_names)

            # DELETE
            mailbox.folder.delete(mailbox.folder_test_new1)
            folder_list_names = [i.name for i in mailbox.folder.list(mailbox.folder_test)]
            self.assertFalse(mailbox.folder_test_new1 in folder_list_names)

            # STATUS
            for status_key, status_val in mailbox.folder.status(mailbox.folder_test_base).items():
                self.assertIs(type(status_key), str)
                self.assertIs(type(status_val), int)

            # SUBSCRIBE
            if mailbox.mailbox_name not in ('MAIL_RU',):
                mailbox.folder.subscribe(mailbox.folder_test_temp2, False)
                self.assertIn(mailbox.folder_test_temp2, [i.name for i in mailbox.folder.list()])
                self.assertNotIn(mailbox.folder_test_temp2,
                                 [i.name for i in mailbox.folder.list(subscribed_only=1)])
                mailbox.folder.subscribe(mailbox.folder_test_temp2, True)
                self.assertIn(mailbox.folder_test_temp2,
                              [i.name for i in mailbox.folder.list(subscribed_only=1)])

            # error
            if mailbox.mailbox_name not in ('YAHOO',):
                # YAHOO:
                #   imaplib.IMAP4.error: SELECT command error: BAD [b'[TRYCREATE] SELECT error -
                #   Folder does not exist or server encountered an error']

# Path: tests/utils.py
# class MailboxTestCase(unittest.TestCase):
#     def setUp(self):
#         self.mailbox_set = dict()
#         for test_mailbox_name in TEST_MAILBOX_NAME_SET:
#             self.mailbox_set[test_mailbox_name] = get_test_mailbox(test_mailbox_name)
# 
#     def tearDown(self):
#         for mailbox in self.mailbox_set.values():
#             mailbox.logout()
# 
# TEST_MAILBOX_NAME_SET = {'YANDEX', 'ZIMBRA', 'MAIL_RU', 'OUTLOOK', 'GOOGLE', 'YAHOO'}
# 
# def get_test_mailbox(mailbox_name: str):
#     # get config
#     config = get_test_mailbox_config(mailbox_name)
# 
#     # add test attributes to MailBox
#     class TestMailBox(MailBox):
#         def __init__(self, *args):
#             super().__init__(*args)
#             test_folder = config['test_folder']
#             path_separator = config['path_separator']
#             self.folder_test = '{}'.format(test_folder)
#             self.folder_test_base = '{}{}base'.format(test_folder, path_separator)
#             self.folder_test_temp1 = '{}{}temp1'.format(test_folder, path_separator)
#             self.folder_test_temp2 = '{}{}temp2'.format(test_folder, path_separator)
#             self.folder_test_new = '{}{}new'.format(test_folder, path_separator)
#             self.folder_test_new1 = '{}{}new1'.format(test_folder, path_separator)
#             self.mailbox_name = mailbox_name
# 
#     # create mailbox instance
#     mailbox = TestMailBox(config['host'])
#     # connect
#     mailbox.login(config['email'], config['password'])
#     # done
#     return mailbox
# 
# Path: imap_tools/errors.py
# class MailboxFolderSelectError(UnexpectedCommandStatusError):
#     pass


# Path: tests/test_folders.py
import unittest
from tests.utils import MailboxTestCase, TEST_MAILBOX_NAME_SET, get_test_mailbox
from imap_tools.errors import MailboxFolderSelectError

            mailbox.folder.rename(mailbox.folder_test_new, mailbox.folder_test_new1)
            folder_list_names = [i.name for i in mailbox.folder.list(mailbox.folder_test)]
            self.assertTrue(mailbox.folder_test_new1 in folder_list_names)
            self.assertFalse(mailbox.folder_test_new in folder_list_names)

            # DELETE
            mailbox.folder.delete(mailbox.folder_test_new1)
            folder_list_names = [i.name for i in mailbox.folder.list(mailbox.folder_test)]
            self.assertFalse(mailbox.folder_test_new1 in folder_list_names)

            # STATUS
            for status_key, status_val in mailbox.folder.status(mailbox.folder_test_base).items():
                self.assertIs(type(status_key), str)
                self.assertIs(type(status_val), int)

            # SUBSCRIBE
            if mailbox.mailbox_name not in ('MAIL_RU',):
                mailbox.folder.subscribe(mailbox.folder_test_temp2, False)
                self.assertIn(mailbox.folder_test_temp2, [i.name for i in mailbox.folder.list()])
                self.assertNotIn(mailbox.folder_test_temp2,
                                 [i.name for i in mailbox.folder.list(subscribed_only=1)])
                mailbox.folder.subscribe(mailbox.folder_test_temp2, True)
                self.assertIn(mailbox.folder_test_temp2,
                              [i.name for i in mailbox.folder.list(subscribed_only=1)])

            # error
            if mailbox.mailbox_name not in ('YAHOO',):
                # YAHOO:
                #   imaplib.IMAP4.error: SELECT command error: BAD [b'[TRYCREATE] SELECT error -
                #   Folder does not exist or server encountered an error']

                with self.assertRaises(MailboxFolderSelectError):