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.
 
 
 

57 lines
1.5 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. TEST_SITE = File(__file__).parent.parent.child_folder('_test')
  11. class TestDepends(object):
  12. def setUp(self):
  13. TEST_SITE.make()
  14. TEST_SITE.parent.child_folder(
  15. 'sites/test_jinja').copy_contents_to(TEST_SITE)
  16. TEST_SITE.parent.child_folder(
  17. 'templates/jinja2').copy_contents_to(
  18. TEST_SITE.child_folder('content'))
  19. def tearDown(self):
  20. TEST_SITE.delete()
  21. def test_depends(self):
  22. s = Site(TEST_SITE)
  23. s.config.plugins = ['hyde.ext.plugins.meta.MetaPlugin',
  24. 'hyde.ext.plugins.depends.DependsPlugin']
  25. text = """
  26. ===
  27. depends: index.html
  28. ===
  29. """
  30. inc = File(TEST_SITE.child('content/inc.md'))
  31. inc.write(text)
  32. gen = Generator(s)
  33. gen.load_site_if_needed()
  34. gen.load_template_if_needed()
  35. def dateformat(x):
  36. return x.strftime('%Y-%m-%d')
  37. gen.template.env.filters['dateformat'] = dateformat
  38. gen.generate_resource_at_path(inc.name)
  39. res = s.content.resource_from_relative_path(inc.name)
  40. assert len(res.depends) == 1
  41. assert 'index.html' in res.depends
  42. deps = list(gen.get_dependencies(res))
  43. assert len(deps) == 3
  44. assert 'helpers.html' in deps
  45. assert 'layout.html' in deps
  46. assert 'index.html' in deps