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.
 
 
 

71 lines
2.5 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.model import Expando
  9. from hyde.generator import Generator
  10. from hyde.site import Site
  11. STYLUS_SOURCE = File(__file__).parent.child_folder('stylus')
  12. TEST_SITE = File(__file__).parent.parent.child_folder('_test')
  13. class TestLess(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.stylus.StylusPlugin']
  25. paths = ['/usr/local/share/npm/bin/stylus', '~/local/bin/stylus',
  26. '~/bin/stylus']
  27. stylus = [path for path in paths if File(path).exists]
  28. if not stylus:
  29. assert False, "Cannot find the stylus executable"
  30. stylus = stylus[0]
  31. s.config.stylus = Expando(dict(app=stylus))
  32. source = TEST_SITE.child('content/media/css/site.styl')
  33. target = File(Folder(s.config.deploy_root_path).child('media/css/site.css'))
  34. gen = Generator(s)
  35. gen.generate_resource_at_path(source)
  36. assert target.exists
  37. text = target.read_all()
  38. expected_text = File(STYLUS_SOURCE.child('expected-site.css')).read_all()
  39. assert text.strip() == expected_text.strip()
  40. def test_can_compress_with_stylus(self):
  41. s = Site(TEST_SITE)
  42. s.config.mode = "production"
  43. s.config.plugins = ['hyde.ext.plugins.stylus.StylusPlugin']
  44. paths = ['/usr/local/share/npm/bin/stylus', '~/local/bin/stylus',
  45. '~/bin/stylus']
  46. stylus = [path for path in paths if File(path).exists]
  47. if not stylus:
  48. assert False, "Cannot find the stylus executable"
  49. stylus = stylus[0]
  50. s.config.stylus = Expando(dict(app=stylus))
  51. source = TEST_SITE.child('content/media/css/site.styl')
  52. target = File(Folder(s.config.deploy_root_path).child('media/css/site.css'))
  53. gen = Generator(s)
  54. gen.generate_resource_at_path(source)
  55. assert target.exists
  56. text = target.read_all()
  57. expected_text = File(STYLUS_SOURCE.child('expected-site-compressed.css')).read_all()
  58. assert text.strip() == expected_text.strip()