'With the message middleware enabled, tests that messages are properly
stored and then retrieved across the full request/redirect/response
cycle.'

def test_full_request_response_cycle(self):

    settings.MESSAGE_LEVEL = constants.DEBUG
    data = {'messages': [('Test    message    %d' % x) for x in xrange(10)]}
    show_url = reverse('django.contrib.messages.tests.urls.show')
    for level in ('debug', 'info', 'success', 'warning', 'error'):
        add_url = reverse('django.contrib.messages.tests.urls.add', args=(level,))
        response = self.client.post(add_url, data, follow=True)
        self.assertRedirects(response, show_url)
        self.assertTrue(('messages' in response.context))
        messages = [Message(self.levels[level], msg) for msg in data['messages']]
        self.assertEqual(list(response.context['messages']), messages)
        for msg in data['messages']:
            self.assertContains(response, msg)
