def test_process_response_error(self, mock_simple_minify, settings): settings.DEBUG = False response = HttpResponse('foo ') response['Content-Type'] = 'text/html' mock_simple_minify.side_effect = ValueError middleware = MinifyHTMLMiddleware() assert middleware.process_response(None, response) is response assert response.content == b'foo ' mock_simple_minify.assert_called_once_with(b'foo')
def test_process_response_html(self, mock_simple_minify, settings): settings.DEBUG = False response = HttpResponse('foo ') response['Content-Type'] = 'text/html' mock_simple_minify.return_value = 'hello there' middleware = MinifyHTMLMiddleware() assert middleware.process_response(None, response) is response assert response.content == b'hello there' mock_simple_minify.assert_called_once_with(b'foo')