# 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 MailboxCopyError(UnexpectedCommandStatusError):
#     pass
# 
# Path: imap_tools/consts.py
# class MailMessageFlags:
#     """
#     System email message flags
#     All system flags begin with "\"
#     """
#     SEEN = '\\Seen'
#     ANSWERED = '\\Answered'
#     FLAGGED = '\\Flagged'
#     DELETED = '\\Deleted'
#     DRAFT = '\\Draft'
#     RECENT = '\\Recent'
#     all = (
#         SEEN, ANSWERED, FLAGGED, DELETED, DRAFT, RECENT
#     )
# 
# Path: imap_tools/query.py
# A = AND


import unittest
from tests.utils import MailboxTestCase, TEST_MAILBOX_NAME_SET, get_test_mailbox
from imap_tools.errors import MailboxCopyError
from imap_tools.consts import MailMessageFlags
from imap_tools.query import A
                len(found_msgs) ==
                len(found_nums) ==
                len(found_uids) ==
                self.base_test_msg_cnt
            )

            # COPY
            mailbox.folder.set(mailbox.folder_test_base)
            mailbox.copy(mailbox.uids(), mailbox.folder_test_temp1)
            if mailbox.mailbox_name != 'YAHOO':
                # YAHOO:
                #   imaplib.IMAP4.error: UID command error: BAD [b'[TRYCREATE] UID COPY failed -
                #   No mailbox exists with name - "__nonexistent_folder__"']
                with self.assertRaises(MailboxCopyError):
                    mailbox.copy(mailbox.uids(), '__nonexistent_folder__')
            self.assertEqual(len(list(mailbox.numbers())), self.base_test_msg_cnt)
            mailbox.folder.set(mailbox.folder_test_temp1)
            self.assertEqual(len(list(mailbox.numbers())), self.base_test_msg_cnt)

            # MOVE
            mailbox.folder.set(mailbox.folder_test_temp1)
            mailbox.move(mailbox.uids(), mailbox.folder_test_temp2)
            self.assertEqual(len(list(mailbox.numbers())), 0)
            mailbox.folder.set(mailbox.folder_test_temp2)
            self.assertEqual(len(list(mailbox.numbers())), self.base_test_msg_cnt)

            # FLAG
            mailbox.folder.set(mailbox.folder_test_temp2)
            mailbox.flag(mailbox.uids(), MailMessageFlags.FLAGGED, True)
            self.assertTrue(

# 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 MailboxCopyError(UnexpectedCommandStatusError):
#     pass
# 
# Path: imap_tools/consts.py
# class MailMessageFlags:
#     """
#     System email message flags
#     All system flags begin with "\"
#     """
#     SEEN = '\\Seen'
#     ANSWERED = '\\Answered'
#     FLAGGED = '\\Flagged'
#     DELETED = '\\Deleted'
#     DRAFT = '\\Draft'
#     RECENT = '\\Recent'
#     all = (
#         SEEN, ANSWERED, FLAGGED, DELETED, DRAFT, RECENT
#     )
# 
# Path: imap_tools/query.py
# A = AND


# Path: tests/test_mailbox.py
import unittest
from tests.utils import MailboxTestCase, TEST_MAILBOX_NAME_SET, get_test_mailbox
from imap_tools.errors import MailboxCopyError
from imap_tools.consts import MailMessageFlags
from imap_tools.query import A

                len(found_msgs) ==
                len(found_nums) ==
                len(found_uids) ==
                self.base_test_msg_cnt
            )

            # COPY
            mailbox.folder.set(mailbox.folder_test_base)
            mailbox.copy(mailbox.uids(), mailbox.folder_test_temp1)
            if mailbox.mailbox_name != 'YAHOO':
                # YAHOO:
                #   imaplib.IMAP4.error: UID command error: BAD [b'[TRYCREATE] UID COPY failed -
                #   No mailbox exists with name - "__nonexistent_folder__"']
                with self.assertRaises(MailboxCopyError):
                    mailbox.copy(mailbox.uids(), '__nonexistent_folder__')
            self.assertEqual(len(list(mailbox.numbers())), self.base_test_msg_cnt)
            mailbox.folder.set(mailbox.folder_test_temp1)
            self.assertEqual(len(list(mailbox.numbers())), self.base_test_msg_cnt)

            # MOVE
            mailbox.folder.set(mailbox.folder_test_temp1)
            mailbox.move(mailbox.uids(), mailbox.folder_test_temp2)
            self.assertEqual(len(list(mailbox.numbers())), 0)
            mailbox.folder.set(mailbox.folder_test_temp2)
            self.assertEqual(len(list(mailbox.numbers())), self.base_test_msg_cnt)

            # FLAG
            mailbox.folder.set(mailbox.folder_test_temp2)
            mailbox.flag(mailbox.uids(), MailMessageFlags.FLAGGED, True)
            self.assertTrue(

                all([MailMessageFlags.FLAGGED in msg.flags for msg in mailbox.fetch(bulk=1, headers_only=1)]))