diff options
author | Marc Tamlyn <marc.tamlyn@gmail.com> | 2012-08-31 11:51:23 +0100 |
---|---|---|
committer | Marc Tamlyn <marc.tamlyn@gmail.com> | 2012-08-31 11:51:23 +0100 |
commit | e876828399e06654d8a1c336fbde65477b3c27c4 (patch) | |
tree | 7c34158205eb9f2f209987a59a450719ece161bf /wkhtmltopdf/tests/tests.py | |
parent | ef5678ce4ff518b7e3dfbda87563b7ffac6d7816 (diff) | |
download | django-wkhtmltopdf-e876828399e06654d8a1c336fbde65477b3c27c4.tar.gz django-wkhtmltopdf-e876828399e06654d8a1c336fbde65477b3c27c4.tar.bz2 django-wkhtmltopdf-e876828399e06654d8a1c336fbde65477b3c27c4.zip |
Add a test for unicode.
This isn't great but better than nothing...
Diffstat (limited to 'wkhtmltopdf/tests/tests.py')
-rw-r--r-- | wkhtmltopdf/tests/tests.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/wkhtmltopdf/tests/tests.py b/wkhtmltopdf/tests/tests.py index 6d8f3ac..16e89ba 100644 --- a/wkhtmltopdf/tests/tests.py +++ b/wkhtmltopdf/tests/tests.py @@ -253,6 +253,39 @@ class TestViews(TestCase): response = view(request) self.assertEqual(response.status_code, 405) + def test_pdf_template_view_unicode(self): + """Test PDFTemplateView.""" + with override_settings( + MEDIA_URL='/media/', + STATIC_URL='/static/', + TEMPLATE_CONTEXT_PROCESSORS=[ + 'django.core.context_processors.media', + 'django.core.context_processors.static', + ], + TEMPLATE_LOADERS=['django.template.loaders.filesystem.Loader'], + TEMPLATE_DIRS=[os.path.join(os.path.dirname(__file__), + '_testproject', 'templates')], + WKHTMLTOPDF_DEBUG=False, + ): + # Setup sample.html + template = 'unicode.html' + filename = 'output.pdf' + view = PDFTemplateView.as_view(filename=filename, + template_name=template) + + # As PDF + request = RequestFactory().get('/') + response = view(request) + self.assertEqual(response.status_code, 200) + response.render() + self.assertEqual(response['Content-Disposition'], + 'attachment; filename="{0}"'.format(filename)) + # not sure how we can test this as the contents is all encoded... + # best we can do for the moment is check it's a pdf and it worked. + # self.assertTrue('☃' in response.content) + self.assertTrue(response.content.startswith('%PDF-')) + self.assertTrue(response.content.endswith('%%EOF\n')) + def test_get_cmd_options(self): # Default cmd_options view = PDFTemplateView() |