Changeset 276:2e8ae6303dae
- Timestamp:
- 08/11/11 22:44:19 (7 months ago)
- Author:
- Menno Smits <menno@…>
- Branch:
- default
- Message:
-
Return expunge responses (#80)
- Location:
- imapclient
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r268
|
r276
|
|
| 727 | 727 | """Remove any messages from the currently selected folder that |
| 728 | 728 | have the ``\\Deleted`` flag set. |
| 729 | | """ |
| 730 | | typ, data = self._imap.expunge() |
| 731 | | self._checkok('expunge', typ, data) |
| 732 | | #TODO: expunge response |
| | 729 | |
| | 730 | The return value is the server response message |
| | 731 | followed by a list of expunge responses. For example:: |
| | 732 | |
| | 733 | ('Expunge completed.', |
| | 734 | [(2, 'EXPUNGE'), |
| | 735 | (1, 'EXPUNGE'), |
| | 736 | (0, 'RECENT')]) |
| | 737 | |
| | 738 | In this case, the responses indicate that the message with |
| | 739 | sequence numbers 2 and 1 where deleted, leaving no recent |
| | 740 | messages in the folder. |
| | 741 | |
| | 742 | See `RFC 3501 section 6.4.3 |
| | 743 | <http://tools.ietf.org/html/rfc3501#section-6.4.3>`_ and |
| | 744 | `RFC 3501 section 7.4.1 |
| | 745 | <http://tools.ietf.org/html/rfc3501#section-7.4.1>`_ for more |
| | 746 | details. |
| | 747 | """ |
| | 748 | tag = self._imap._command('EXPUNGE') |
| | 749 | return self._consume_until_tagged_response(tag, 'EXPUNGE') |
| 733 | 750 | |
| 734 | 751 | def getacl(self, folder): |
-
|
r272
|
r276
|
|
| 528 | 528 | self.assertIn((1, 'EXISTS'), resps) |
| 529 | 529 | |
| | 530 | def test_expunge(self): |
| | 531 | self.client.select_folder('INBOX') |
| | 532 | |
| | 533 | # Test empty mailbox |
| | 534 | text, resps = self.client.expunge() |
| | 535 | self.assertTrue(isinstance(text, str)) |
| | 536 | self.assertGreater(len(text), 0) |
| | 537 | self.assertEqual(resps, []) |
| | 538 | |
| | 539 | # Now try with a message to expunge |
| | 540 | self.client.append('INBOX', SIMPLE_MESSAGE, flags=[imapclient.DELETED]) |
| | 541 | |
| | 542 | msg, resps = self.client.expunge() |
| | 543 | |
| | 544 | self.assertTrue(isinstance(text, str)) |
| | 545 | self.assertGreater(len(text), 0) |
| | 546 | self.assertTrue(isinstance(resps, list)) |
| | 547 | if not self.is_gmail(): |
| | 548 | # GMail has an auto-expunge feature which might be |
| | 549 | # on. EXPUNGE won't return anything in this case |
| | 550 | self.assertIn((1, 'EXPUNGE'), resps) |
| | 551 | |
| 530 | 552 | return LiveTest |
| 531 | 553 | |