'Calls SafeSessionMiddleware.process_request and verifies
the response.
Arguments:
safe_cookie_data - If provided, it is serialized and
stored in the request\'s cookies.
success - If True, verifies a successful response.
Else, verifies a failed response with an HTTP redirect.'

def assert_response(self, safe_cookie_data=None, success=True):

    if safe_cookie_data:
        self.request.COOKIES[settings.SESSION_COOKIE_NAME] = unicode(safe_cookie_data)
    response = SafeSessionMiddleware().process_request(self.request)
    if success:
        self.assertIsNone(response)
        self.assertIsNone(getattr(self.request, 'need_to_delete_cookie', None))
    else:
        self.assertEquals(response.status_code, HttpResponseRedirect.status_code)
        self.assertTrue(self.request.need_to_delete_cookie)
