'If unsolicited data is received along with solicited data in the
response to a I{FETCH} command issued by L{IMAP4Client.fetchSpecific},
the unsolicited data is passed to the appropriate callback and not
included in the result with which the L{Deferred} returned by
L{IMAP4Client.fetchSpecific} fires.'

def test_unsolicitedResponseMixedWithSolicitedResponse(self):

    transport = StringTransport()
    c = StillSimplerClient()
    c.makeConnection(transport)
    c.lineReceived('*    OK    [IMAP4rev1]')
    def login():
        d = c.login('blah', 'blah')
        c.dataReceived('0001    OK    LOGIN\r\n')
        return d
    def select():
        d = c.select('inbox')
        c.lineReceived('0002    OK    SELECT')
        return d
    def fetch():
        d = c.fetchSpecific('1:*', headerType='HEADER.FIELDS', headerArgs=['SUBJECT'])
        c.dataReceived('*    1    FETCH    (BODY[HEADER.FIELDS    ("SUBJECT")]    {38}\r\n')
        c.dataReceived('Subject:    Suprise    for    your    woman...\r\n')
        c.dataReceived('\r\n')
        c.dataReceived(')\r\n')
        c.dataReceived('*    1    FETCH    (FLAGS    (\\Seen))\r\n')
        c.dataReceived('*    2    FETCH    (BODY[HEADER.FIELDS    ("SUBJECT")]    {75}\r\n')
        c.dataReceived('Subject:    What    you    been    doing.    Order    your    meds    here    .    ,.    handcuff    madsen\r\n')
        c.dataReceived('\r\n')
        c.dataReceived(')\r\n')
        c.dataReceived('0003    OK    FETCH    completed\r\n')
        return d
    def test(res):
        self.assertEqual(res, {1: [['BODY', ['HEADER.FIELDS', ['SUBJECT']], 'Subject:    Suprise    for    your    woman...\r\n\r\n']], 2: [['BODY', ['HEADER.FIELDS', ['SUBJECT']], 'Subject:    What    you    been    doing.    Order    your    meds    here    .    ,.    handcuff    madsen\r\n\r\n']]})
        self.assertEqual(c.flags, {1: ['\\Seen']})
    return login().addCallback(strip(select)).addCallback(strip(fetch)).addCallback(test)
