mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
Added more tests for decorators.
This commit is contained in:
committed by
Mariusz Felisiak
parent
fe19b33e2f
commit
059cb0dbc9
19
tests/decorators/test_gzip.py
Normal file
19
tests/decorators/test_gzip.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.test import SimpleTestCase
|
||||
from django.views.decorators.gzip import gzip_page
|
||||
|
||||
|
||||
class GzipPageTests(SimpleTestCase):
|
||||
# Gzip ignores content that is too short.
|
||||
content = "Content " * 100
|
||||
|
||||
def test_gzip_page_decorator(self):
|
||||
@gzip_page
|
||||
def sync_view(request):
|
||||
return HttpResponse(content=self.content)
|
||||
|
||||
request = HttpRequest()
|
||||
request.META["HTTP_ACCEPT_ENCODING"] = "gzip"
|
||||
response = sync_view(request)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.get("Content-Encoding"), "gzip")
|
||||
Reference in New Issue
Block a user