Skip to content

Commit 616b301

Browse files
committed
tests: assert MiddlewareNotUsed is raised
if PIPELINE_ENABLED is False
1 parent 8de61b0 commit 616b301

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/tests/test_middleware.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import unicode_literals
33

4+
try:
5+
from mock import patch
6+
except ImportError:
7+
from unittest.mock import patch # noqa
8+
9+
from django.core.exceptions import MiddlewareNotUsed
410
from django.test import TestCase
511
from django.http import HttpRequest, HttpResponse
612

@@ -34,3 +40,9 @@ def test_middleware_text(self):
3440
response = MinifyHTMLMiddleware().process_response(self.req, self.resp)
3541
self.assertIn('text/plain', response['Content-Type'])
3642
self.assertIn(self.whitespace, response.content)
43+
44+
@patch('pipeline.middleware.settings.PIPELINE_ENABLED', False)
45+
def test_middleware_not_used(self):
46+
self.resp['Content-Type'] = 'text/plain; charset=UTF-8'
47+
48+
self.assertRaises(MiddlewareNotUsed, MinifyHTMLMiddleware)

0 commit comments

Comments
 (0)