'Tests that content is removed from regular and streaming responses with
a status_code of 100-199, 204, 304 or a method of "HEAD".'

def test_conditional_content_removal(self):

    req = HttpRequest()
    res = HttpResponse(u'abc')
    conditional_content_removal(req, res)
    self.assertEqual(res.content, 'abc')
    res = StreamingHttpResponse([u'abc'])
    conditional_content_removal(req, res)
    self.assertEqual(''.join(res), 'abc')
    for status_code in (100, 150, 199, 204, 304):
        res = HttpResponse(u'abc', status=status_code)
        conditional_content_removal(req, res)
        self.assertEqual(res.content, '')
        res = StreamingHttpResponse([u'abc'], status=status_code)
        conditional_content_removal(req, res)
        self.assertEqual(''.join(res), '')
    abc = gzip_compress('abc')
    res = HttpResponse(abc, status=304)
    res[u'Content-Encoding'] = u'gzip'
    conditional_content_removal(req, res)
    self.assertEqual(res.content, '')
    res = StreamingHttpResponse([abc], status=304)
    res[u'Content-Encoding'] = u'gzip'
    conditional_content_removal(req, res)
    self.assertEqual(''.join(res), '')
    req.method = u'HEAD'
    res = HttpResponse(u'abc')
    conditional_content_removal(req, res)
    self.assertEqual(res.content, '')
    res = StreamingHttpResponse([u'abc'])
    conditional_content_removal(req, res)
    self.assertEqual(''.join(res), '')
