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.
 
 
 

74 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(
  29. s.config.deploy_root_path.child(res.relative_deploy_path))
  30. assert target.exists
  31. text = target.read_all()
  32. q = PyQuery(text)
  33. assert q('title').text().strip() == txt.strip()
  34. def test_can_auto_extend(self):
  35. s = Site(TEST_SITE)
  36. s.config.plugins = ['hyde.ext.plugins.meta.MetaPlugin',
  37. 'hyde.ext.plugins.meta.AutoExtendPlugin',
  38. 'hyde.ext.plugins.text.BlockdownPlugin']
  39. txt = ("This template tests to make sure blocks can be replaced with"
  40. "markdownish syntax.")
  41. templ = """
  42. ---
  43. extends: base.html
  44. ---
  45. =====title========
  46. %s
  47. ====/title========"""
  48. self.assert_extended(s, txt, templ)
  49. def test_can_auto_extend_with_default_blocks(self):
  50. s = Site(TEST_SITE)
  51. s.config.plugins = ['hyde.ext.plugins.meta.MetaPlugin',
  52. 'hyde.ext.plugins.meta.AutoExtendPlugin',
  53. 'hyde.ext.plugins.text.BlockdownPlugin']
  54. txt = ("This template tests to make sure blocks can be replaced with"
  55. "markdownish syntax.")
  56. templ = """
  57. ---
  58. extends: base.html
  59. default_block: title
  60. ---
  61. %s
  62. """
  63. self.assert_extended(s, txt, templ)