def test_middleware_optin_parameter(self):
        request = self.get_request('/', data={'appcache_analyze': 1})
        mid_instance = AppCacheAssetsFromResponse()

        view = NewsListView.as_view()
        response = view(request)
        response.render()
        processed = mid_instance.process_response(request, response)

        self.assertTrue('/static/img/icon1_big.png' in processed.appcache['cached'])
        self.assertTrue('/static/img/icon2_big.png' in processed.appcache['cached'])
        self.assertTrue('/static/img/photo1.png' not in processed.appcache['cached'])
        self.assertTrue('/static/img/photo2.png' not in processed.appcache['cached'])
    def test_middleware_extraction(self):
        request = self.get_request('/', data={'appcache_analyze': 1})
        mid_instance = AppCacheAssetsFromResponse()

        view = NewsListView.as_view()
        response = view(request)
        response.render()
        processed = mid_instance.process_response(request, response)
        self.assertTrue(processed.appcache)
        self.assertEqual(len(processed.appcache), 3)

        self.assertEqual(len(processed.appcache['cached']), 6)
        self.assertEqual(len(processed.appcache['fallback']), 2)
        self.assertEqual(len(processed.appcache['network']), 1)