- def test_gen_pdf_child(self):
- input = open(path.dirname(__file__) + "/fraszka-do-anusie.xml")
- book = models.Book.from_text_and_meta(File(input), self.book_info, overwrite=True)
- book.build_pdf()
- self.assertTrue(path.exists(book.pdf_file.path))
+ def test_gen_pdf_parent(self):
+ """This book contains a child."""
+ xml = path.join(path.dirname(__file__), "files/fraszki.xml")
+ parent = models.Book.from_xml_file(xml)
+ parent.build_pdf()
+ parent = models.Book.objects.get(pk=parent.pk)
+ self.assertTrue(path.exists(parent.pdf_file.path))
+
+ def test_custom_pdf(self):
+ from catalogue.utils import build_custom_pdf
+ out = models.get_dynamic_path(None, 'test-custom', ext='pdf')
+ absoulute_path = path.join(settings.MEDIA_ROOT, out)
+
+ if not path.exists(path.dirname(absoulute_path)):
+ makedirs(path.dirname(absoulute_path))
+
+ build_custom_pdf(self.book.id,
+ customizations=['nofootnotes', '13pt', 'a4paper'], file_name=out)
+ self.assertTrue(path.exists(absoulute_path))