# 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()


import unittest
from tests.utils import MailboxTestCase



class IdleTest(MailboxTestCase):

    def test_idle(self):
        for mailbox_name, mailbox in self.mailbox_set.items():
            if mailbox.mailbox_name in ('MAIL_RU', 'YAHOO'):
                continue
            responses1 = mailbox.idle.wait(timeout=0.5)
            self.assertIs(type(responses1), list)

            mailbox.idle.start()
            responses2 = mailbox.idle.poll(0.5)
            mailbox.idle.stop()
            self.assertIs(type(responses2), list)

            self.assertEqual(len(tuple(mailbox.fetch(limit=1))), 1)


if __name__ == "__main__":

# 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()


# Path: tests/test_idle.py
import unittest
from tests.utils import MailboxTestCase




class IdleTest(MailboxTestCase):

    def test_idle(self):
        for mailbox_name, mailbox in self.mailbox_set.items():
            if mailbox.mailbox_name in ('MAIL_RU', 'YAHOO'):
                continue
            responses1 = mailbox.idle.wait(timeout=0.5)
            self.assertIs(type(responses1), list)

            mailbox.idle.start()
            responses2 = mailbox.idle.poll(0.5)
            mailbox.idle.stop()
            self.assertIs(type(responses2), list)

            self.assertEqual(len(tuple(mailbox.fetch(limit=1))), 1)


if __name__ == "__main__":

    unittest.main()