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.
 
 
 

68 lines
1.6 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 hyde.model import Config
  10. from fswrap import File
  11. TEST_SITE = File(__file__).parent.parent.child_folder('_test')
  12. class TestFlattner(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_flatten(self):
  20. s = Site(TEST_SITE)
  21. cfg = """
  22. plugins:
  23. - hyde.ext.plugins.structure.FlattenerPlugin
  24. flattener:
  25. items:
  26. -
  27. source: blog
  28. target: ''
  29. """
  30. import yaml
  31. s.config = Config(TEST_SITE, config_dict=yaml.load(cfg))
  32. s.load()
  33. gen = Generator(s)
  34. gen.generate_all()
  35. assert not s.config.deploy_root_path.child_folder('blog').exists
  36. assert File(
  37. s.config.deploy_root_path.child('merry-christmas.html')).exists
  38. def test_flattener_fixes_nodes(self):
  39. s = Site(TEST_SITE)
  40. cfg = """
  41. plugins:
  42. - hyde.ext.plugins.structure.FlattenerPlugin
  43. flattener:
  44. items:
  45. -
  46. source: blog
  47. target: ''
  48. """
  49. import yaml
  50. s.config = Config(TEST_SITE, config_dict=yaml.load(cfg))
  51. s.load()
  52. gen = Generator(s)
  53. gen.generate_all()
  54. blog_node = s.content.node_from_relative_path('blog')
  55. assert blog_node
  56. assert blog_node.url == '/'