/hyde/tests/ext/test_blockdown.py

http://github.com/hyde/hyde · Python · 46 lines · 32 code · 8 blank · 6 comment · 0 complexity · 8f2689f50d026558ad1f91359a6f7b4e MD5 · raw file

  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 pyquery import PyQuery
  11. TEST_SITE = File(__file__).parent.parent.child_folder('_test')
  12. class TestBlockdown(object):
  13. def setUp(self):
  14. TEST_SITE.make()
  15. TEST_SITE.parent.child_folder(
  16. 'sites/test_jinja').copy_contents_to(TEST_SITE)
  17. def tearDown(self):
  18. TEST_SITE.delete()
  19. def test_can_parse_blockdown(self):
  20. s = Site(TEST_SITE)
  21. s.config.plugins = ['hyde.ext.plugins.text.BlockdownPlugin']
  22. txt ="This template tests to make sure blocks can be replaced with markdownish syntax."
  23. templ = """
  24. {%% extends "base.html" %%}
  25. =====title========
  26. %s
  27. ====/title========"""
  28. content = (templ.strip() % txt).strip()
  29. bd = File(TEST_SITE.child('content/blockdown.html'))
  30. bd.write(content)
  31. gen = Generator(s)
  32. gen.generate_resource_at_path(bd.path)
  33. res = s.content.resource_from_path(bd.path)
  34. target = File(s.config.deploy_root_path.child(res.relative_deploy_path))
  35. assert target.exists
  36. text = target.read_all()
  37. q = PyQuery(text)
  38. assert q('title').text().strip() == txt.strip()