hurry.yui basic tests
=====================

Here are some basic tests for hurry.yui.

Let's set up a way to render URLs; typically the framework has already
done this::

  >>> class Plugin(object):
  ...   def get_library_url(self, library):
  ...     return 'http://localhost/static/%s' % (
  ...       library.name)
  >>> from hurry.resource import register_plugin
  >>> register_plugin(Plugin())

Let's check the YUI structure by picking out a resource in it::

  >>> from hurry import yui
  >>> from hurry.resource import NeededInclusions
  >>> needed = NeededInclusions()
  >>> needed.need(yui.fonts)
  >>> print needed.render()
  <link rel="stylesheet" type="text/css" href="http://localhost/static/yui/fonts/fonts.css" />

Let's try a resource that has a dependency on fonts, namely
``grids``::

  >>> needed = NeededInclusions()
  >>> needed.need(yui.grids)
  >>> print needed.render()
  <link rel="stylesheet" type="text/css" href="http://localhost/static/yui/fonts/fonts.css" />
  <link rel="stylesheet" type="text/css" href="http://localhost/static/yui/grids/grids.css" />

Let's need two resources at the same time::

  >>> needed = NeededInclusions()
  >>> needed.need(yui.grids)
  >>> needed.need(yui.reset)
  >>> print needed.render()
  <link rel="stylesheet" type="text/css" href="http://localhost/static/yui/fonts/fonts.css" />
  <link rel="stylesheet" type="text/css" href="http://localhost/static/yui/grids/grids.css" />
  <link rel="stylesheet" type="text/css" href="http://localhost/static/yui/reset/reset.css" />

Let's get the same, minified::

  >>> needed.mode('minified')
  >>> print needed.render()
  <link rel="stylesheet" type="text/css" href="http://localhost/static/yui/fonts/fonts-min.css" />
  <link rel="stylesheet" type="text/css" href="http://localhost/static/yui/grids/grids-min.css" />
  <link rel="stylesheet" type="text/css" href="http://localhost/static/yui/reset/reset-min.css" />

Now let's try to see consolidation: we include grids and reset at the
same time. Since this time we enable rolling up, we expect to see the
rollup ``reset-fonts-grids``::

  >>> needed = NeededInclusions()
  >>> needed.rollup()
  >>> needed.need(yui.grids)
  >>> needed.need(yui.reset)
  >>> print needed.render()
  <link rel="stylesheet" type="text/css" href="http://localhost/static/yui/reset-fonts-grids/reset-fonts-grids.css" />

Requesting minification has no effect on rollups, as the original
rollup is already minified::

  >>> needed = NeededInclusions()
  >>> needed.rollup()
  >>> needed.mode('minified')
  >>> needed.need(yui.grids)
  >>> needed.need(yui.reset)
  >>> print needed.render()
  <link rel="stylesheet" type="text/css" href="http://localhost/static/yui/reset-fonts-grids/reset-fonts-grids.css" />

