def test_response(self): """'download_document_nginx' view returns a valid X-Accel response.""" document = Document.objects.create( slug='hello-world', file=File(open(self.files['hello-world.txt'])), ) download_url = reverse('download_document_nginx', kwargs={'slug': 'hello-world'}) response = self.client.get(download_url) self.assertEquals(response.status_code, 200) # Validation shortcut: assert_x_accel_redirect. assert_x_accel_redirect( self, response, content_type="text/plain; charset=utf-8", charset="utf-8", basename="hello-world.txt", redirect_url="/download-optimized/document/hello-world.txt", expires=None, with_buffering=None, limit_rate=None) # Check some more items, because this test is part of # django-downloadview tests. self.assertFalse('ContentEncoding' in response) self.assertEquals(response['Content-Disposition'], 'attachment; filename=hello-world.txt')
def test_response(self): """'nginx:optimized_by_decorator' returns X-Accel response.""" setup_file() url = reverse('nginx:optimized_by_decorator') response = self.client.get(url) assert_x_accel_redirect( self, response, content_type="text/plain; charset=utf-8", charset="utf-8", basename="hello-world.txt", redirect_url="/nginx-optimized-by-decorator/hello-world.txt", expires=None, with_buffering=None, limit_rate=None)
def test_response(self): """X-Accel optimization respects ``attachment`` attribute.""" document = Document.objects.create( slug='hello-world', file=File(open(self.files['hello-world.txt'])), ) download_url = reverse('download_document_nginx_inline', kwargs={'slug': 'hello-world'}) response = self.client.get(download_url) assert_x_accel_redirect( self, response, content_type="text/plain; charset=utf-8", charset="utf-8", attachment=False, redirect_url="/download-optimized/document/hello-world.txt", expires=None, with_buffering=None, limit_rate=None)