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.
 
 
 

60 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. TEST_SITE = File(__file__).parent.parent.child_folder('_test')
  12. class TestTextlinks(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_textlinks(self):
  20. d = {
  21. 'objects': 'template/variables',
  22. 'plugins': 'plugins/metadata',
  23. 'sorter': 'plugins/sorter'
  24. }
  25. text = u"""
  26. {%% markdown %%}
  27. [[!!img/hyde-logo.png]]
  28. * [Rich object model][hyde objects] and
  29. [overridable hierarchical metadata]([[ %(plugins)s ]]) thats available for use in
  30. templates.
  31. * Configurable [sorting][], filtering and grouping support.
  32. [hyde objects]: [[ %(objects)s ]]
  33. [sorting]: [[%(sorter)s]]
  34. {%% endmarkdown %%}
  35. """
  36. site = Site(TEST_SITE)
  37. site.config.plugins = ['hyde.ext.plugins.textlinks.TextlinksPlugin']
  38. site.config.base_url = 'http://example.com/'
  39. site.config.media_url = '/media'
  40. tlink = File(site.content.source_folder.child('tlink.html'))
  41. tlink.write(text % d)
  42. gen = Generator(site)
  43. gen.generate_all()
  44. f = File(site.config.deploy_root_path.child(tlink.name))
  45. assert f.exists
  46. html = f.read_all()
  47. assert html
  48. for name, path in d.items():
  49. assert site.config.base_url + path in html
  50. assert '/media/img/hyde-logo.png' in html