def probe_host(config): client = create_client_from_config(config) ns = client.namespace() client.logout() if not ns.personal: raise RuntimeError('Can\'t run tests: IMAP account has no personal namespace') return ns.personal[0] # Use first personal namespace
def test_idle(self): if not self.client.has_capability('IDLE'): return self.skipTest("Server doesn't support IDLE") # Start main connection idling self.client.select_folder(self.base_folder) self.client.idle() # Start a new connection and upload a new message client2 = create_client_from_config(conf) client2.select_folder(self.base_folder) client2.append(self.base_folder, SIMPLE_MESSAGE) # Check for the idle data responses = self.client.idle_check(timeout=5) text, more_responses = self.client.idle_done() self.assertIn((1, 'EXISTS'), responses) self.assertTrue(isinstance(text, str)) self.assertGreater(len(text), 0) self.assertTrue(isinstance(more_responses, list)) # Check for IDLE data returned by idle_done() self.client.idle() client2.select_folder(self.base_folder) client2.append(self.base_folder, SIMPLE_MESSAGE) time.sleep(2) # Allow some time for the IDLE response to be sent text, responses = self.client.idle_done() self.assertIn((2, 'EXISTS'), responses) self.assertTrue(isinstance(text, str)) self.assertGreater(len(text), 0)
def main(): opts = command_line() print 'Connecting...' client = create_client_from_config(opts) print 'Connected.' banner = '\nIMAPClient instance is "c"' def ipython_011(c): from IPython.frontend.terminal.embed import InteractiveShellEmbed ipshell = InteractiveShellEmbed(banner1=banner) ipshell('') def ipython_010(c): from IPython.Shell import IPShellEmbed IPShellEmbed('', banner=banner)() def builtin(c): import code code.interact(banner, local=dict(c=c)) for shell_attempt in (ipython_011, ipython_010, builtin): try: shell_attempt(client) break except ImportError: pass
def setUp(self): self.client = create_client_from_config(conf) self.client.use_uid = use_uid self.base_folder = conf.namespace[0] + ('__imapclient') self.folder_delimiter = conf.namespace[1] self.clear_test_folders() self.unsub_all_test_folders() self.client.create_folder(self.base_folder) self.client.select_folder(self.base_folder)
def test_noop(self): self.client.select_folder(self.base_folder) # Initially there should be no responses text, resps = self.client.noop() self.assertTrue(isinstance(text, str)) self.assertGreater(len(text), 0) self.assertEquals(resps, []) # Start a new connection and upload a new message client2 = create_client_from_config(conf) client2.select_folder(self.base_folder) client2.append(self.base_folder, SIMPLE_MESSAGE) # Check for this addition in the NOOP data msg, resps = self.client.noop() self.assertTrue(isinstance(text, str)) self.assertGreater(len(text), 0) self.assertTrue(isinstance(resps, list)) self.assertIn((1, 'EXISTS'), resps)