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. """
  2. Use nose
  3. `$ pip install nose`
  4. `$ nosetests`
  5. """
  6. from hyde._compat import quote
  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 TestTextlinks(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. def tearDown(self):
  17. TEST_SITE.delete()
  18. def test_textlinks(self):
  19. d = {
  20. 'objects': 'template/variables',
  21. 'plugins': 'plugins/metadata',
  22. 'sorter': 'plugins/sorter'
  23. }
  24. text = u"""
  25. {%% markdown %%}
  26. [[!!img/hyde-logo.png]]
  27. * [Rich object model][hyde objects] and
  28. [overridable hierarchical metadata]([[ %(plugins)s ]]) thats available
  29. for use in templates.
  30. * Configurable [sorting][], filtering and grouping support.
  31. [hyde objects]: [[ %(objects)s ]]
  32. [sorting]: [[%(sorter)s]]
  33. {%% endmarkdown %%}
  34. """
  35. site = Site(TEST_SITE)
  36. site.config.plugins = ['hyde.ext.plugins.text.TextlinksPlugin']
  37. site.config.base_url = 'http://example.com/'
  38. site.config.media_url = '/media'
  39. tlink = File(site.content.source_folder.child('tlink.html'))
  40. tlink.write(text % d)
  41. print(tlink.read_all())
  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 + quote(path) in html
  50. assert '/media/img/hyde-logo.png' in html