def test_fetch_only_the_last_message_data(self): fetch = FetchCommand('TAG') fetch.append_to_resp('12 FETCH (FLAGS (\Seen)') # not closed on purpose self.assertTrue(fetch.wait_data()) fetch.append_to_resp('13 FETCH (FLAGS (\Seen)') self.assertTrue(fetch.wait_data()) fetch.append_to_resp(')') self.assertFalse(fetch.wait_data())
def test_fetch_with_litteral(self): fetch = FetchCommand('TAG') fetch.append_to_resp('12 FETCH (FLAGS () BODY[] {13}') fetch.begin_literal_data(13, b'literal (data') fetch.append_to_resp(')') self.assertFalse(fetch.wait_data())
def test_simple_fetch_with_two_lines(self): fetch = FetchCommand('TAG') fetch.append_to_resp('12 FETCH (FLAGS (\Seen) BODY ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 3028') self.assertTrue(fetch.wait_data()) fetch.append_to_resp('92))') self.assertFalse(fetch.wait_data())
def test_uncomplete_fetch_with_uncomplete_line(self): cmd = FetchCommand('TAG') self.imap_protocol._handle_line = MagicMock(return_value=cmd) self.imap_protocol.data_received(b'* 21 FETCH (FLAGS (\Seen) BODY[] {16}\r\nuncomplete fetch') self.imap_protocol.data_received(b')\r\nTAG OK FETCH completed\r\n') self.imap_protocol._handle_line.assert_has_calls( [call('* 21 FETCH (FLAGS (\Seen) BODY[] {16}', None), call(')', cmd), call('TAG OK FETCH completed', None)])
def test_uncomplete_fetch_message_attributes_without_literal(self): cmd = FetchCommand('TAG') self.imap_protocol._handle_line = MagicMock(return_value=cmd) line = b'* 12 FETCH (FLAGS (\Seen) BODY ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 3028 \r\n' cmd.append_to_resp(line.decode()) self.imap_protocol.data_received(line) line = b'92))\r\nTAG OK FETCH completed\r\n' cmd.append_to_resp(line.decode()) self.imap_protocol.data_received(line) self.imap_protocol._handle_line.assert_has_calls( [call('* 12 FETCH (FLAGS (\Seen) BODY ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 3028 ', None), call('92))', cmd), call('TAG OK FETCH completed', None)])
def test_fetch_only_the_last_message_data(self): fetch = FetchCommand('TAG') fetch.append_to_resp( '12 FETCH (FLAGS (\Seen)') # not closed on purpose self.assertTrue(fetch.wait_data()) fetch.append_to_resp('13 FETCH (FLAGS (\Seen)') self.assertTrue(fetch.wait_data()) fetch.append_to_resp(')') self.assertFalse(fetch.wait_data())
def test_simple_fetch(self): fetch = FetchCommand('TAG') fetch.append_to_resp('12 FETCH (FLAGS (\Seen))') self.assertFalse(fetch.wait_data())
def test_empty_fetch(self): self.assertFalse(FetchCommand('TAG').wait_data())