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.
 
 
 

67 lines
2.3 KiB

  1. # -*- coding: utf-8 -*-
  2. """
  3. Use nose
  4. `$ pip install nose`
  5. `$ nosetests`
  6. """
  7. from hyde.model import Expando
  8. from hyde.generator import Generator
  9. from hyde.site import Site
  10. from fswrap import File, Folder
  11. STYLUS_SOURCE = File(__file__).parent.child_folder('stylus')
  12. TEST_SITE = File(__file__).parent.parent.child_folder('_test')
  13. class TestStylus(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. STYLUS_SOURCE.copy_contents_to(TEST_SITE.child('content/media/css'))
  19. File(TEST_SITE.child('content/media/css/site.css')).delete()
  20. def tearDown(self):
  21. TEST_SITE.delete()
  22. def test_can_execute_stylus(self):
  23. s = Site(TEST_SITE)
  24. s.config.plugins = ['hyde.ext.plugins.css.StylusPlugin']
  25. paths = ['/usr/local/bin/stylus', '/usr/local/share/npm/bin/stylus']
  26. for path in paths:
  27. if File(path).exists:
  28. s.config.stylus = Expando(dict(app=path))
  29. source = TEST_SITE.child('content/media/css/site.styl')
  30. target = File(
  31. Folder(s.config.deploy_root_path).child('media/css/site.css'))
  32. gen = Generator(s)
  33. gen.generate_resource_at_path(source)
  34. assert target.exists
  35. text = target.read_all()
  36. expected_text = File(
  37. STYLUS_SOURCE.child('expected-site.css')).read_all()
  38. assert text.strip() == expected_text.strip()
  39. def test_can_compress_with_stylus(self):
  40. s = Site(TEST_SITE)
  41. s.config.mode = "production"
  42. s.config.plugins = ['hyde.ext.plugins.css.StylusPlugin']
  43. paths = ['/usr/local/bin/stylus', '/usr/local/share/npm/bin/stylus']
  44. for path in paths:
  45. if File(path).exists:
  46. s.config.stylus = Expando(dict(app=path))
  47. source = TEST_SITE.child('content/media/css/site.styl')
  48. target = File(
  49. Folder(s.config.deploy_root_path).child('media/css/site.css'))
  50. gen = Generator(s)
  51. gen.generate_resource_at_path(source)
  52. assert target.exists
  53. text = target.read_all()
  54. expected_text = File(
  55. STYLUS_SOURCE.child('expected-site-compressed.css')).read_all()
  56. assert text.strip() == expected_text.strip()