コード例 #1
0
 def test_attachment_filename_false(self):
     response = real_sendfile(HttpRequest(),
                              self._get_readme(),
                              attachment=True,
                              attachment_filename=False)
     self.assertTrue(response is not None)
     self.assertEqual('attachment', response['Content-Disposition'])
コード例 #2
0
 def test_attachment(self):
     response = real_sendfile(HttpRequest(),
                              self._get_readme(),
                              attachment=True)
     self.assertTrue(response is not None)
     self.assertEqual('attachment; filename="testfile.txt"',
                      response['Content-Disposition'])
コード例 #3
0
 def test_attachment_filename_unicode(self):
     response = real_sendfile(HttpRequest(),
                              self._get_readme(),
                              attachment=True,
                              attachment_filename='test’s.txt')
     self.assertTrue(response is not None)
     self.assertEqual(
         'attachment; filename="tests.txt"; filename*=UTF-8\'\'test%E2%80%99s.txt',
         response['Content-Disposition'])
コード例 #4
0
 def test_correct_url_in_xaccelredirect_header(self):
     filepath = self.ensure_file('readme.txt')
     response = real_sendfile(HttpRequest(), filepath)
     self.assertTrue(response is not None)
     self.assertEqual('/private/readme.txt', response['X-Accel-Redirect'])
コード例 #5
0
 def test_correct_file_in_xsendfile_header(self):
     filepath = self.ensure_file('readme.txt')
     response = real_sendfile(HttpRequest(), filepath)
     self.assertTrue(response is not None)
     self.assertEqual(filepath, response['X-Sendfile'])
コード例 #6
0
 def test_xsendfile_header_containing_unicode(self):
     filepath = self.ensure_file(u'péter_là_gueule.txt')
     response = real_sendfile(HttpRequest(), filepath)
     self.assertTrue(response is not None)
     self.assertEqual(smart_str(filepath), response['X-Sendfile'])
コード例 #7
0
 def test_correct_file_in_xsendfile_header(self):
     response = real_sendfile(HttpRequest(), _get_readme())
     self.assertTrue(response is not None)
     self.assertEqual(_get_readme(), response['X-Sendfile'])
コード例 #8
0
ファイル: tests.py プロジェクト: Engage/django-sendfile
 def test_correct_file_in_xsendfile_header(self):
     filepath = self.ensure_file('readme.txt')
     response = real_sendfile(HttpRequest(), filepath)
     self.assertTrue(response is not None)
     self.assertEqual(filepath, response['X-Sendfile'])
コード例 #9
0
 def test_sendfile(self):
     response = real_sendfile(HttpRequest(), self._get_readme())
     self.assertTrue(response is not None)
     self.assertEqual('text/plain', response['Content-Type'])
     self.assertEqual(self._get_readme(), smart_str(response.content))
コード例 #10
0
 def test_set_encoding(self):
     response = real_sendfile(HttpRequest(),
                              self._get_readme(),
                              encoding='utf8')
     self.assertTrue(response is not None)
     self.assertEqual('utf8', response['Content-Encoding'])
コード例 #11
0
ファイル: tests.py プロジェクト: Engage/django-sendfile
 def test_sendfile(self):
     response = real_sendfile(HttpRequest(), self._get_readme())
     self.assertTrue(response is not None)
     self.assertEqual('text/plain', response['Content-Type'])
     self.assertEqual(self._get_readme(), smart_str(response.content))
コード例 #12
0
ファイル: tests.py プロジェクト: Engage/django-sendfile
 def test_set_mimetype(self):
     response = real_sendfile(HttpRequest(), self._get_readme(), mimetype='text/plain')
     self.assertTrue(response is not None)
     self.assertEqual('text/plain', response['Content-Type'])
コード例 #13
0
ファイル: tests.py プロジェクト: Engage/django-sendfile
 def test_xaccelredirect_header_containing_unicode(self):
     filepath = self.ensure_file(u'péter_là_gueule.txt')
     response = real_sendfile(HttpRequest(), filepath)
     self.assertTrue(response is not None)
     self.assertEqual('/private/p%C3%A9ter_l%C3%A0_gueule.txt', response['X-Accel-Redirect'])
コード例 #14
0
ファイル: tests.py プロジェクト: Engage/django-sendfile
 def test_404(self):
     try:
         real_sendfile(HttpRequest(), 'fhdsjfhjk.txt')
     except Http404:
         pass
コード例 #15
0
ファイル: tests.py プロジェクト: Engage/django-sendfile
 def test_correct_url_in_xaccelredirect_header(self):
     filepath = self.ensure_file('readme.txt')
     response = real_sendfile(HttpRequest(), filepath)
     self.assertTrue(response is not None)
     self.assertEqual('/private/readme.txt', response['X-Accel-Redirect'])
コード例 #16
0
ファイル: tests.py プロジェクト: Engage/django-sendfile
 def test_xsendfile_header_containing_unicode(self):
     filepath = self.ensure_file(u'péter_là_gueule.txt')
     response = real_sendfile(HttpRequest(), filepath)
     self.assertTrue(response is not None)
     self.assertEqual(smart_str(filepath), response['X-Sendfile'])
コード例 #17
0
 def test_correct_url_in_xaccelredirect_header(self):
     response = real_sendfile(HttpRequest(), _get_readme())
     self.assertTrue(response is not None)
     self.assertEqual('/private/README.rst', response['X-Accel-Redirect'])
コード例 #18
0
 def test_xaccelredirect_header_containing_unicode(self):
     filepath = self.ensure_file(u'péter_là_gueule.txt')
     response = real_sendfile(HttpRequest(), filepath)
     self.assertTrue(response is not None)
     self.assertEqual(u'/private/péter_là_gueule.txt'.encode('utf-8'),
                      response['X-Accel-Redirect'])
コード例 #19
0
 def test_sendfile(self):
     response = real_sendfile(HttpRequest(), _get_readme())
     self.assertTrue(response is not None)
     self.assertEqual('application/octet-stream', response['Content-Type'])
     self.assertEqual(_get_readme(), response.content)
コード例 #20
0
 def test_404(self):
     try:
         real_sendfile(HttpRequest(), 'fhdsjfhjk.txt')
     except Http404:
         pass
コード例 #21
0
ファイル: tests.py プロジェクト: xenups/django-sendfile
 def test_location_header_containing_unicode(self):
     filepath = self.ensure_file(u'péter_là_gueule.txt')
     response = real_sendfile(HttpRequest(), filepath)
     self.assertTrue(response is not None)
     self.assertEqual(u'/private/péter_là_gueule.txt'.encode('utf-8'), unquote(response['Location']))
コード例 #22
0
 def test_set_mimetype(self):
     response = real_sendfile(HttpRequest(),
                              self._get_readme(),
                              mimetype='text/plain')
     self.assertTrue(response is not None)
     self.assertEqual('text/plain', response['Content-Type'])
コード例 #23
0
ファイル: tests.py プロジェクト: Engage/django-sendfile
 def test_attachment_filename_unicode(self):
     response = real_sendfile(HttpRequest(), self._get_readme(), attachment=True, attachment_filename='test’s.txt')
     self.assertTrue(response is not None)
     self.assertEqual('attachment; filename="test\'s.txt"; filename*=UTF-8\'\'test%E2%80%99s.txt', response['Content-Disposition'])
コード例 #24
0
ファイル: tests.py プロジェクト: Engage/django-sendfile
 def test_set_encoding(self):
     response = real_sendfile(HttpRequest(), self._get_readme(), encoding='utf8')
     self.assertTrue(response is not None)
     self.assertEqual('utf8', response['Content-Encoding'])
コード例 #25
0
ファイル: tests.py プロジェクト: hzlf/openbroadcast.org
 def test_attachment(self):
     response = real_sendfile(HttpRequest(), _get_readme(), attachment=True)
     self.assertTrue(response is not None)
     self.assertEqual('attachment; filename="README.rst"', response['Content-Disposition'])
コード例 #26
0
ファイル: tests.py プロジェクト: Engage/django-sendfile
 def test_attachment_filename(self):
     response = real_sendfile(HttpRequest(), self._get_readme(), attachment=True, attachment_filename='tests.txt')
     self.assertTrue(response is not None)
     self.assertEqual('attachment; filename="tests.txt"', response['Content-Disposition'])
コード例 #27
0
ファイル: tests.py プロジェクト: xenups/django-sendfile
 def test_correct_url_in_location_header(self):
     filepath = self.ensure_file('readme.txt')
     response = real_sendfile(HttpRequest(), filepath)
     self.assertTrue(response is not None)
     self.assertEqual('/private/readme.txt', response['Location'])