Ticket #1105: imaptest.patch

File imaptest.patch, 3.0 KB (added by cablehead, 14 years ago)
  • twisted/mail/test/test_imap.py

     
    6565        [u'Hello & world', 'Hello &- world'],
    6666        [u'Hello\xffworld', 'Hello&AP8-world'],
    6767        [u'\xff\xfe\xfd\xfc', '&AP8A,gD9APw-'],
    68         [u'~peter/mail/\u65e5\u672c\u8a9e/\u53f0\u5317', 
     68        [u'~peter/mail/\u65e5\u672c\u8a9e/\u53f0\u5317',
    6969         '~peter/mail/&ZeVnLIqe-/&U,BTFw-'], # example from RFC 2060
    7070    ]
    7171
     
    16111611        c.dataReceived('0003 OK FETCH\r\n')
    16121612        self.failUnless(unittest.deferredResult(d))
    16131613
     1614    def testUnsolicitedResponseMixedWithSolicitedResponse(self):
     1615
     1616        class StillSimplerClient(imap4.IMAP4Client):
     1617            events = []
     1618            def flagsChanged(self, newFlags):
     1619                self.events.append(['flagsChanged', newFlags])
     1620
     1621        transport = StringTransport()
     1622        c = StillSimplerClient()
     1623        c.makeConnection(transport)
     1624        c.lineReceived('* OK [IMAP4rev1]')
     1625
     1626        d = c.login('blah', 'blah')
     1627        c.dataReceived('0001 OK LOGIN\r\n')
     1628        self.failUnless(unittest.deferredResult(d))
     1629
     1630        d = c.select('inbox')
     1631        c.lineReceived('0002 OK SELECT')
     1632        self.failUnless(unittest.deferredResult(d))
     1633
     1634        d = c.fetchSpecific('1:*',
     1635            headerType='HEADER.FIELDS',
     1636            headerArgs=['SUBJECT'])
     1637
     1638        c.dataReceived('* 1 FETCH (BODY[HEADER.FIELDS ("SUBJECT")] {38}\r\n')
     1639        c.dataReceived('Subject: Suprise for your woman...\r\n')
     1640        c.dataReceived('\r\n')
     1641        c.dataReceived(')\r\n')
     1642        c.dataReceived('* 1 FETCH (FLAGS (\Seen))\r\n')
     1643        c.dataReceived('* 2 FETCH (BODY[HEADER.FIELDS ("SUBJECT")] {75}\r\n')
     1644        c.dataReceived('Subject: What you been doing. Order your meds here . ,. handcuff madsen\r\n')
     1645        c.dataReceived('\r\n')
     1646        c.dataReceived(')\r\n')
     1647        c.dataReceived('0003 OK FETCH completed\r\n')
     1648
     1649        self.assertEquals(unittest.deferredResult(d), {
     1650            1: [['BODY', ['HEADER.FIELDS', ['SUBJECT']],
     1651                'Subject: Suprise for your woman...\r\n\r\n']],
     1652            2: [['BODY', ['HEADER.FIELDS', ['SUBJECT']],
     1653                'Subject: What you been doing. Order your meds here . ,. handcuff madsen\r\n\r\n']]
     1654        })
     1655
     1656        self.assertEquals(c.events, [['flagsChanged', {1: ['\\Seen']}]])
     1657
    16141658    def testPathelogicalScatteringOfLiterals(self):
    16151659        transport = StringTransport()
    16161660        c = imap4.IMAP4Server()
     
    18671911
    18681912    def testFetchBodyStructureUID(self):
    18691913        self.testFetchBodyStructure(1)
    1870    
     1914
    18711915    def testFetchSimplifiedBody(self, uid=0):
    18721916        self.function = self.client.fetchSimplifiedBody
    18731917        self.messages = '21'
     
    23382382        self.loopback()
    23392383        self.failUnless(failure)
    23402384        self.assertIdentical(failure[0], imap4.IMAP4Exception)
    2341        
     2385
    23422386class SlowMailbox(SimpleMailbox):
    23432387    howSlow = 2
    23442388