def test_internaldate(generic_client, constants): """ Test that our monkeypatched imaplib works through imapclient """ dates_to_test = [ ('6-Mar-2015 10:02:32 +0900', datetime(2015, 3, 6, 1, 2, 32)), (' 6-Mar-2015 10:02:32 +0900', datetime(2015, 3, 6, 1, 2, 32)), ('06-Mar-2015 10:02:32 +0900', datetime(2015, 3, 6, 1, 2, 32)), ('6-Mar-2015 07:02:32 +0900', datetime(2015, 3, 5, 22, 2, 32)), (' 3-Sep-1922 09:16:51 +0000', datetime(1922, 9, 3, 9, 16, 51)), ('2-Jan-2015 03:05:37 +0800', datetime(2015, 1, 1, 19, 5, 37)) ] for internaldate_string, native_date in dates_to_test: constants['internaldate'] = internaldate_string expected_resp = ('{seq} (UID {uid} MODSEQ ({modseq}) ' 'INTERNALDATE "{internaldate}" FLAGS {flags} ' 'BODY[] {{{body_size}}}'.format(**constants), constants['body']) patch_imap4(generic_client, [expected_resp, ')']) uid = constants['uid'] assert generic_client.uids([uid]) == [ RawMessage(uid=long(uid), internaldate=native_date, flags=constants['flags'], body=constants['body'], g_labels=None, g_thrid=None, g_msgid=None) ]
def test_internaldate(generic_client, constants): """ Test that our monkeypatched imaplib works through imapclient """ dates_to_test = [ ("6-Mar-2015 10:02:32 +0900", datetime(2015, 3, 6, 1, 2, 32)), (" 6-Mar-2015 10:02:32 +0900", datetime(2015, 3, 6, 1, 2, 32)), ("06-Mar-2015 10:02:32 +0900", datetime(2015, 3, 6, 1, 2, 32)), ("6-Mar-2015 07:02:32 +0900", datetime(2015, 3, 5, 22, 2, 32)), (" 3-Sep-1922 09:16:51 +0000", datetime(1922, 9, 3, 9, 16, 51)), ("2-Jan-2015 03:05:37 +0800", datetime(2015, 1, 1, 19, 5, 37)), ] for internaldate_string, native_date in dates_to_test: constants["internaldate"] = internaldate_string expected_resp = ( "{seq} (UID {uid} MODSEQ ({modseq}) " 'INTERNALDATE "{internaldate}" FLAGS {flags} ' "BODY[] {{{body_size}}}".format(**constants).encode(), constants["body"], ) patch_imap4(generic_client, [expected_resp, b")"]) uid = constants["uid"] assert generic_client.uids([uid]) == [ RawMessage( uid=long(uid), internaldate=native_date, flags=constants["flags"], body=constants["body"], g_labels=None, g_thrid=None, g_msgid=None, ) ]
def test_body(generic_client, constants): expected_resp = ( "{seq} (UID {uid} MODSEQ ({modseq}) " 'INTERNALDATE "{internaldate}" FLAGS {flags} ' "BODY[] {{{body_size}}}".format(**constants).encode(), constants["body"], ) unsolicited_resp = b"1198 (UID 1731 MODSEQ (95244) FLAGS (\\Seen))" patch_imap4(generic_client, [expected_resp, b")", unsolicited_resp]) uid = constants["uid"] flags = constants["flags"] body = constants["body"] assert generic_client.uids([uid]) == [ RawMessage( uid=long(uid), internaldate=datetime(2015, 3, 2, 23, 36, 20), flags=flags, body=body, g_labels=None, g_thrid=None, g_msgid=None, ) ]
def test_gmail_body(gmail_client, constants): expected_resp = ( "{seq} (X-GM-MSGID {g_msgid} X-GM-THRID {g_thrid} " "X-GM-LABELS {raw_g_labels} UID {uid} MODSEQ ({modseq}) " 'INTERNALDATE "{internaldate}" FLAGS {flags} ' "BODY[] {{{body_size}}}".format(**constants), constants["body"], ) unsolicited_resp = "1198 (UID 1731 MODSEQ (95244) FLAGS (\\Seen))" patch_imap4(gmail_client, [expected_resp, ")", unsolicited_resp]) uid = constants["uid"] flags = constants["flags"] g_labels = constants["unicode_g_labels"] g_thrid = constants["g_thrid"] g_msgid = constants["g_msgid"] body = constants["body"] assert gmail_client.uids([uid]) == [ RawMessage( uid=long(uid), internaldate=datetime(2015, 3, 2, 23, 36, 20), flags=flags, body=body, g_labels=g_labels, g_thrid=g_thrid, g_msgid=g_msgid, ) ]
def test_body(generic_client, constants): expected_resp = ('{seq} (UID {uid} MODSEQ ({modseq}) ' 'INTERNALDATE "{internaldate}" FLAGS {flags} ' 'BODY[] {{{body_size}}}'.format(**constants), constants['body']) unsolicited_resp = '1198 (UID 1731 MODSEQ (95244) FLAGS (\\Seen))' patch_imap4(generic_client, [expected_resp, ')', unsolicited_resp]) uid = constants['uid'] flags = constants['flags'] body = constants['body'] assert generic_client.uids([uid]) == [ RawMessage(uid=long(uid), internaldate=datetime(2015, 3, 2, 23, 36, 20), flags=flags, body=body, g_labels=None, g_thrid=None, g_msgid=None) ]
def test_gmail_body(gmail_client, constants): expected_resp = ('{seq} (X-GM-MSGID {g_msgid} X-GM-THRID {g_thrid} ' 'X-GM-LABELS {raw_g_labels} UID {uid} MODSEQ ({modseq}) ' 'INTERNALDATE "{internaldate}" FLAGS {flags} ' 'BODY[] {{{body_size}}}'.format(**constants), constants['body']) unsolicited_resp = '1198 (UID 1731 MODSEQ (95244) FLAGS (\\Seen))' patch_imap4(gmail_client, [expected_resp, ')', unsolicited_resp]) uid = constants['uid'] flags = constants['flags'] g_labels = constants['unicode_g_labels'] g_thrid = constants['g_thrid'] g_msgid = constants['g_msgid'] body = constants['body'] assert gmail_client.uids([uid]) == [ RawMessage(uid=long(uid), internaldate=datetime(2015, 3, 2, 23, 36, 20), flags=flags, body=body, g_labels=g_labels, g_thrid=g_thrid, g_msgid=g_msgid) ]