MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_bracket_flags

Method test_bracket_flags

Lib/test/test_imaplib.py:782–828  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

780
781 @threading_helper.reap_threads
782 def test_bracket_flags(self):
783
784 # This violates RFC 3501, which disallows ']' characters in tag names,
785 # but imaplib has allowed producing such tags forever, other programs
786 # also produce them (eg: OtherInbox's Organizer app as of 20140716),
787 # and Gmail, for example, accepts them and produces them. So we
788 # support them. See issue #21815.
789
790 class BracketFlagHandler(SimpleIMAPHandler):
791
792 def handle(self):
793 self.flags = ['Answered', 'Flagged', 'Deleted', 'Seen', 'Draft']
794 super().handle()
795
796 def cmd_AUTHENTICATE(self, tag, args):
797 self._send_textline('+')
798 self.server.response = yield
799 self._send_tagged(tag, 'OK', 'FAKEAUTH successful')
800
801 def cmd_SELECT(self, tag, args):
802 flag_msg = ' \\'.join(self.flags)
803 self._send_line(('* FLAGS (%s)' % flag_msg).encode('ascii'))
804 self._send_line(b'* 2 EXISTS')
805 self._send_line(b'* 0 RECENT')
806 msg = ('* OK [PERMANENTFLAGS %s \\*)] Flags permitted.'
807 % flag_msg)
808 self._send_line(msg.encode('ascii'))
809 self._send_tagged(tag, 'OK', '[READ-WRITE] SELECT completed.')
810
811 def cmd_STORE(self, tag, args):
812 new_flags = args[2].strip('(').strip(')').split()
813 self.flags.extend(new_flags)
814 flags_msg = '(FLAGS (%s))' % ' \\'.join(self.flags)
815 msg = '* %s FETCH %s' % (args[0], flags_msg)
816 self._send_line(msg.encode('ascii'))
817 self._send_tagged(tag, 'OK', 'STORE completed.')
818
819 with self.reaped_pair(BracketFlagHandler) as (server, client):
820 code, data = client.authenticate('MYAUTH', lambda x: b'fake')
821 self.assertEqual(code, 'OK')
822 self.assertEqual(server.response, b'ZmFrZQ==\r\n')
823 client.select('test')
824 typ, [data] = client.store(b'1', "+FLAGS", "[test]")
825 self.assertIn(b'[test]', data)
826 client.select('test')
827 typ, [data] = client.response('PERMANENTFLAGS')
828 self.assertIn(b'[test]', data)
829
830 @threading_helper.reap_threads
831 def test_issue5949(self):

Callers

nothing calls this directly

Calls 7

reaped_pairMethod · 0.95
authenticateMethod · 0.80
assertInMethod · 0.80
responseMethod · 0.80
assertEqualMethod · 0.45
selectMethod · 0.45
storeMethod · 0.45

Tested by

no test coverage detected