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.
 
 
 

58 lines
1.6 KiB

  1. # -*- coding: utf-8 -*-
  2. """
  3. Use nose
  4. `$ pip install nose`
  5. `$ nosetests`
  6. """
  7. from hyde.fs import File, Folder
  8. from hyde.generator import Generator
  9. from hyde.site import Site
  10. from pyquery import PyQuery
  11. from nose.tools import nottest
  12. TEST_SITE = File(__file__).parent.parent.child_folder('_test')
  13. class TestDepends(object):
  14. def setUp(self):
  15. TEST_SITE.make()
  16. TEST_SITE.parent.child_folder(
  17. 'sites/test_jinja').copy_contents_to(TEST_SITE)
  18. TEST_SITE.parent.child_folder(
  19. 'templates/jinja2').copy_contents_to(
  20. TEST_SITE.child_folder('content'))
  21. def tearDown(self):
  22. TEST_SITE.delete()
  23. def test_depends(self):
  24. s = Site(TEST_SITE)
  25. s.config.plugins = ['hyde.ext.plugins.meta.MetaPlugin',
  26. 'hyde.ext.plugins.depends.DependsPlugin']
  27. text = """
  28. ===
  29. depends: index.html
  30. ===
  31. """
  32. inc = File(TEST_SITE.child('content/inc.md'))
  33. inc.write(text)
  34. gen = Generator(s)
  35. gen.load_site_if_needed()
  36. gen.load_template_if_needed()
  37. def dateformat(x):
  38. return x.strftime('%Y-%m-%d')
  39. gen.template.env.filters['dateformat'] = dateformat
  40. gen.generate_resource_at_path(inc.name)
  41. res = s.content.resource_from_relative_path(inc.name)
  42. assert len(res.depends) == 1
  43. assert 'index.html' in res.depends
  44. deps = list(gen.get_dependencies(res))
  45. assert len(deps) == 3
  46. assert 'helpers.html' in deps
  47. assert 'layout.html' in deps
  48. assert 'index.html' in deps