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.
 
 
 

71 lines
1.7 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. DRAFT_POST = """
  13. ---
  14. is_draft: true
  15. ---
  16. A draft post.
  17. """
  18. class TestDrafts(object):
  19. def setUp(self):
  20. TEST_SITE.make()
  21. TEST_SITE.parent.child_folder(
  22. 'sites/test_jinja').copy_contents_to(TEST_SITE)
  23. draft = TEST_SITE.child_file('content/blog/2013/may/draft-post.html')
  24. draft.parent.make()
  25. draft.write(DRAFT_POST)
  26. def tearDown(self):
  27. TEST_SITE.delete()
  28. def test_drafts_are_skipped_in_production(self):
  29. s = Site(TEST_SITE)
  30. cfg = """
  31. mode: production
  32. plugins:
  33. - hyde.ext.plugins.meta.MetaPlugin
  34. - hyde.ext.plugins.blog.DraftsPlugin
  35. """
  36. import yaml
  37. s.config = Config(TEST_SITE, config_dict=yaml.load(cfg))
  38. s.load()
  39. gen = Generator(s)
  40. gen.generate_all()
  41. assert not s.config.deploy_root_path.child_file(
  42. 'blog/2013/may/draft-post.html').exists
  43. def test_drafts_are_published_in_development(self):
  44. s = Site(TEST_SITE)
  45. cfg = """
  46. mode: development
  47. plugins:
  48. - hyde.ext.plugins.meta.MetaPlugin
  49. - hyde.ext.plugins.blog.DraftsPlugin
  50. """
  51. import yaml
  52. s.config = Config(TEST_SITE, config_dict=yaml.load(cfg))
  53. s.load()
  54. gen = Generator(s)
  55. gen.generate_all()
  56. assert s.config.deploy_root_path.child_file(
  57. 'blog/2013/may/draft-post.html').exists