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.
 
 
 

56 lines
1.4 KiB

  1. # -*- coding: utf-8 -*-
  2. """
  3. Use nose
  4. `$ pip install nose`
  5. `$ nosetests`
  6. """
  7. from hyde.ext.plugins.meta import MetaPlugin
  8. from hyde.fs import File, Folder
  9. from hyde.generator import Generator
  10. from hyde.site import Site
  11. import yaml
  12. TEST_SITE = File(__file__).parent.parent.child_folder('_test')
  13. class TestMeta(object):
  14. def setUp(self):
  15. TEST_SITE.make()
  16. TEST_SITE.parent.child_folder('sites/test_jinja').copy_contents_to(TEST_SITE)
  17. def tearDown(self):
  18. TEST_SITE.delete()
  19. def test_can_load_front_matter(self):
  20. front_matter = """
  21. ---
  22. title: A nice title
  23. author: Lakshmi Vyas
  24. twitter: lakshmivyas
  25. ---
  26. """
  27. about1 = File(TEST_SITE.child('content/about.html'))
  28. about2 = File(TEST_SITE.child('content/about2.html'))
  29. text = front_matter
  30. text += "\n"
  31. text += about1.read_all()
  32. about2.write(text)
  33. s = Site(TEST_SITE)
  34. s.config.plugins = ['hyde.ext.plugins.meta.MetaPlugin']
  35. gen = Generator(s)
  36. gen.generate_all()
  37. res = s.content.resource_from_path(about2.path)
  38. assert hasattr(res, 'meta')
  39. assert hasattr(res.meta, 'title')
  40. assert hasattr(res.meta, 'author')
  41. assert hasattr(res.meta, 'twitter')
  42. assert res.meta.title == "A nice title"
  43. assert res.meta.author == "Lakshmi Vyas"
  44. assert res.meta.twitter == "lakshmivyas"