'Any unrequested flag information received along with other requested
information in an untagged I{FETCH} received in response to a request
issued with L{IMAP4Client.fetchSpecific} is passed to the
C{flagsChanged} callback.'

def test_flagsChangedInsideFetchSpecificResponse(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")]    {22}\r\n')
        c.dataReceived('Subject:    subject    one\r\n')
        c.dataReceived('    FLAGS    (\\Recent))\r\n')
        c.dataReceived('*    2    FETCH    (FLAGS    (\\Seen)    BODY[HEADER.FIELDS    ("SUBJECT")]    {22}\r\n')
        c.dataReceived('Subject:    subject    two\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:    subject    one\r\n']], 2: [['BODY', ['HEADER.FIELDS', ['SUBJECT']], 'Subject:    subject    two\r\n']]})
        self.assertEqual(c.flags, {1: ['\\Recent'], 2: ['\\Seen']})
    return login().addCallback(strip(select)).addCallback(strip(fetch)).addCallback(test)
