'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.fetchMessage} is passed to the
C{flagsChanged} callback.'

def test_flagsChangedInsideFetchMessageResponse(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.fetchMessage('1:*')
        c.dataReceived('*    1    FETCH    (RFC822    {24}\r\n')
        c.dataReceived('Subject:    first    subject\r\n')
        c.dataReceived('    FLAGS    (\\Seen))\r\n')
        c.dataReceived('*    2    FETCH    (FLAGS    (\\Recent    \\Seen)    RFC822    {25}\r\n')
        c.dataReceived('Subject:    second    subject\r\n')
        c.dataReceived(')\r\n')
        c.dataReceived('0003    OK    FETCH    completed\r\n')
        return d
    def test(res):
        self.assertEqual(res, {1: {'RFC822': 'Subject:    first    subject\r\n'}, 2: {'RFC822': 'Subject:    second    subject\r\n'}})
        self.assertEqual(c.flags, {1: ['\\Seen'], 2: ['\\Recent', '\\Seen']})
    return login().addCallback(strip(select)).addCallback(strip(fetch)).addCallback(test)
