A fork of hyde, the static site generation. Some patches will be pushed upstream.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

72 lines
2.1 KiB

  1. # -*- coding: utf-8 -*-
  2. """
  3. Use nose
  4. `$ pip install nose`
  5. `$ nosetests`
  6. """
  7. from hyde.generator import Generator
  8. from hyde.site import Site
  9. from fswrap import File
  10. from nose.tools import nottest
  11. from pyquery import PyQuery
  12. TEST_SITE = File(__file__).parent.parent.child_folder('_test')
  13. class TestAutoExtend(object):
  14. def setUp(self):
  15. TEST_SITE.make()
  16. TEST_SITE.parent.child_folder(
  17. 'sites/test_jinja').copy_contents_to(TEST_SITE)
  18. def tearDown(self):
  19. TEST_SITE.delete()
  20. @nottest
  21. def assert_extended(self, s, txt, templ):
  22. content = (templ.strip() % txt).strip()
  23. bd = File(TEST_SITE.child('content/auto_extend.html'))
  24. bd.write(content)
  25. gen = Generator(s)
  26. gen.generate_resource_at_path(bd.path)
  27. res = s.content.resource_from_path(bd.path)
  28. target = File(s.config.deploy_root_path.child(res.relative_deploy_path))
  29. assert target.exists
  30. text = target.read_all()
  31. q = PyQuery(text)
  32. assert q('title').text().strip() == txt.strip()
  33. def test_can_auto_extend(self):
  34. s = Site(TEST_SITE)
  35. s.config.plugins = ['hyde.ext.plugins.meta.MetaPlugin',
  36. 'hyde.ext.plugins.auto_extend.AutoExtendPlugin',
  37. 'hyde.ext.plugins.blockdown.BlockdownPlugin']
  38. txt ="This template tests to make sure blocks can be replaced with markdownish syntax."
  39. templ = """
  40. ---
  41. extends: base.html
  42. ---
  43. =====title========
  44. %s
  45. ====/title========"""
  46. self.assert_extended(s, txt, templ)
  47. def test_can_auto_extend_with_default_blocks(self):
  48. s = Site(TEST_SITE)
  49. s.config.plugins = ['hyde.ext.plugins.meta.MetaPlugin',
  50. 'hyde.ext.plugins.auto_extend.AutoExtendPlugin',
  51. 'hyde.ext.plugins.blockdown.BlockdownPlugin']
  52. txt ="This template tests to make sure blocks can be replaced with markdownish syntax."
  53. templ = """
  54. ---
  55. extends: base.html
  56. default_block: title
  57. ---
  58. %s
  59. """
  60. self.assert_extended(s, txt, templ)