diff options
author | Simon Law <simon.law@ecometrica.com> | 2012-07-20 14:30:13 -0400 |
---|---|---|
committer | Simon Law <simon.law@ecometrica.com> | 2012-07-20 14:30:13 -0400 |
commit | df83b5a8045d1fe69b3ae4d5ffdc5f98069862dc (patch) | |
tree | 4fd04e0396effa6e9dfb6716728e35fd8f88674b /wkhtmltopdf | |
parent | 10680259b0843d3688dbae241f8abb5c366ea4c5 (diff) | |
download | django-wkhtmltopdf-df83b5a8045d1fe69b3ae4d5ffdc5f98069862dc.tar.gz django-wkhtmltopdf-df83b5a8045d1fe69b3ae4d5ffdc5f98069862dc.tar.bz2 django-wkhtmltopdf-df83b5a8045d1fe69b3ae4d5ffdc5f98069862dc.zip |
test_wkhtmltopdf tests that wkhtmltopdf generates a PDF.
Diffstat (limited to 'wkhtmltopdf')
-rw-r--r-- | wkhtmltopdf/tests.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/wkhtmltopdf/tests.py b/wkhtmltopdf/tests.py index 0249cb5..f50d8f2 100644 --- a/wkhtmltopdf/tests.py +++ b/wkhtmltopdf/tests.py @@ -4,10 +4,22 @@ import os from django.test import TestCase -from .utils import template_to_temp_file +from .utils import template_to_temp_file, wkhtmltopdf class TestUtils(TestCase): + def test_wkhtmltopdf(self): + """Should run wkhtmltopdf to generate a PDF""" + title = 'A test template.' + temp_file = template_to_temp_file('sample.html', {'title': title}) + pdf_output = None + try: + pdf_output = wkhtmltopdf(pages=[temp_file]) + finally: + if os.path.exists(temp_file): + os.remove(temp_file) + self.assertTrue(pdf_output.startswith('%PDF'), pdf_output) + def test_template_to_temp_file(self): """Should render a template to a temporary file.""" title = 'A test template.' |