aboutsummaryrefslogtreecommitdiff
path: root/tests/generators/pdf
diff options
context:
space:
mode:
Diffstat (limited to 'tests/generators/pdf')
-rw-r--r--tests/generators/pdf/test_generate_pdf.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/generators/pdf/test_generate_pdf.py b/tests/generators/pdf/test_generate_pdf.py
new file mode 100644
index 0000000..738508c
--- /dev/null
+++ b/tests/generators/pdf/test_generate_pdf.py
@@ -0,0 +1,55 @@
+import pytest
+import os
+from pathlib import Path
+
+import resumejson_converter
+
+from jinja2.exceptions import TemplateSyntaxError
+
+from resumejson_converter.generators.html import generate as generate_html
+from resumejson_converter.generators.pdf import generate as generate_pdf
+from resumejson_converter.utils import json as ujson
+
+
+@pytest.fixture(scope="session")
+def gen_template_html(tmpdir_factory):
+ tmp_file = tmpdir_factory.mktemp(
+ "resumejson_converter_test"
+ ).join("template.html")
+
+ with open(tmp_file, "w") as f:
+ f.write("<p>{{ resume.basics.name }}</p>")
+ return tmp_file
+
+
+@pytest.fixture(scope="session")
+def gen_incorrect_template_html(tmpdir_factory):
+ tmp_file = tmpdir_factory.mktemp(
+ "resumejson_converter_test"
+ ).join("template.html")
+
+ with open(tmp_file, "w") as f:
+ f.write("<p>{{ resume.basics.name }</p>")
+ return tmp_file
+
+
+@pytest.fixture(scope="session")
+def gen_dest_path(tmpdir_factory):
+ return tmpdir_factory.mktemp("out").join("out.pdf")
+
+
+def test_generate_pdf():
+ with pytest.raises(TypeError):
+ generate_html()
+
+
+def test_generate_pdf_generated(
+ gen_template_html,
+ gen_incorrect_template_html):
+ resume_path = "{}/example/resume.json".format(
+ os.path.dirname(resumejson_converter.__file__))
+ template_path = gen_template_html
+ resume = ujson.load(resume_path)
+ html = generate_html(resume, template_path)
+ generate_pdf(html, gen_incorrect_template_html)
+ assert Path(gen_incorrect_template_html).is_file