| | 15 | |
| | 16 | MULTIPART_MESSAGE = """\ |
| | 17 | From: Bob Smith <bob@smith.com> |
| | 18 | To: Some One <some@one.com> |
| | 19 | Date: Tue, 16 Mar 2010 16:45:32 +0000 |
| | 20 | Message-ID: <1A472770E042064698CB5ADC83A12ACD39455AAB@ABC> |
| | 21 | MIME-Version: 1.0 |
| | 22 | Subject: A multipart message |
| | 23 | Content-Type: multipart/mixed; boundary="===============1534046211==" |
| | 24 | |
| | 25 | --===============1534046211== |
| | 26 | Content-Type: text/html; charset="us-ascii" |
| | 27 | Content-Transfer-Encoding: quoted-printable |
| | 28 | |
| | 29 | <html><body> |
| | 30 | Here is the first part. |
| | 31 | </body></html> |
| | 32 | |
| | 33 | --===============1534046211== |
| | 34 | Content-Type: text/plain; charset="us-ascii" |
| | 35 | Content-Transfer-Encoding: 7bit |
| | 36 | |
| | 37 | Here is the second part. |
| | 38 | |
| | 39 | --===============1534046211==-- |
| | 40 | """.replace('\n', '\r\n') |
| | 300 | def test_fetch(client): |
| | 301 | clear_folder(client, 'INBOX') |
| | 302 | |
| | 303 | client.select_folder('INBOX') |
| | 304 | client.append('INBOX', MULTIPART_MESSAGE) |
| | 305 | |
| | 306 | fields = ['RFC822', 'FLAGS', 'INTERNALDATE', 'ENVELOPE'] |
| | 307 | msg_id = client.search()[0] |
| | 308 | resp = client.fetch(msg_id, fields) |
| | 309 | |
| | 310 | assert len(resp) == 1 |
| | 311 | msginfo = resp[msg_id] |
| | 312 | |
| | 313 | assert set(msginfo.keys()) == set(fields + ['SEQ']) |
| | 314 | assert msginfo['SEQ'] == 1 |
| | 315 | assert msginfo['RFC822'] == MULTIPART_MESSAGE |
| | 316 | assert isinstance(msginfo['INTERNALDATE'], datetime) |
| | 317 | assert isinstance(msginfo['FLAGS'], tuple) |
| | 318 | assert msginfo['ENVELOPE'] == ('Tue, 16 Mar 2010 16:45:32 +0000', |
| | 319 | 'A multipart message', |
| | 320 | (('Bob Smith', None, 'bob', 'smith.com'),), |
| | 321 | (('Bob Smith', None, 'bob', 'smith.com'),), |
| | 322 | (('Bob Smith', None, 'bob', 'smith.com'),), |
| | 323 | (('Some One', None, 'some', 'one.com'),), |
| | 324 | None, None, None, |
| | 325 | '<1A472770E042064698CB5ADC83A12ACD39455AAB@ABC>') |
| | 326 | |
| | 327 | |