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.
 
 
 

43 lines
1.2 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. OPTIPNG_SOURCE = File(__file__).parent.child_folder('optipng')
  12. TEST_SITE = File(__file__).parent.parent.child_folder('_test')
  13. class TestOptipng(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. IMAGES = TEST_SITE.child_folder('content/media/images')
  19. IMAGES.make()
  20. OPTIPNG_SOURCE.copy_contents_to(IMAGES)
  21. def tearDown(self):
  22. TEST_SITE.delete()
  23. def test_can_execute_optipng(self):
  24. s = Site(TEST_SITE)
  25. s.config.mode = "production"
  26. s.config.plugins = ['hyde.ext.plugins.images.OptiPNGPlugin']
  27. s.config.optipng = Expando(dict(args=dict(quiet="")))
  28. source = File(TEST_SITE.child('content/media/images/hyde-lt-b.png'))
  29. target = File(
  30. Folder(s.config.deploy_root_path).child(
  31. 'media/images/hyde-lt-b.png'))
  32. gen = Generator(s)
  33. gen.generate_resource_at_path(source)
  34. assert target.exists
  35. assert target.size < source.size