test_pdf.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import unittest
  2. import os
  3. import locale
  4. import logging
  5. import pdf
  6. from tempfile import mkdtemp
  7. from pelican import Pelican
  8. from pelican.settings import read_settings
  9. from shutil import rmtree
  10. CUR_DIR = os.path.dirname(__file__)
  11. class TestPdfGeneration(unittest.TestCase):
  12. def setUp(self, override=None):
  13. import pdf
  14. self.temp_path = mkdtemp(prefix='pelicantests.')
  15. settings = {
  16. 'PATH': os.path.join(os.path.dirname(CUR_DIR), '..', 'test_data', 'content'),
  17. 'OUTPUT_PATH': self.temp_path,
  18. 'PLUGINS': [pdf],
  19. 'LOCALE': locale.normalize('en_US'),
  20. }
  21. if override:
  22. settings.update(override)
  23. self.settings = read_settings(override=settings)
  24. pelican = Pelican(settings=self.settings)
  25. try:
  26. pelican.run()
  27. except ValueError:
  28. logging.warn('Relative links in the form of |filename|images/test.png are not yet handled by the pdf generator')
  29. pass
  30. def tearDown(self):
  31. rmtree(self.temp_path)
  32. def test_existence(self):
  33. assert os.path.exists(os.path.join(self.temp_path, 'pdf', 'this-is-a-super-article.pdf'))