1
0
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:
Ben Lomax
2023-09-13 10:00:01 +02:00
committed by Mariusz Felisiak
parent fe19b33e2f
commit 059cb0dbc9
3 changed files with 111 additions and 2 deletions

View 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")