Base Interpolation Tests
========================

Basics
------

plone.stringinterp.Interpolate will do ${id} style interpolation
using string substitutions provided by named adapters.

Let's test basic interpolation using the homepage::

    >>> from plone.app.testing import SITE_OWNER_NAME
    >>> from plone.app.testing import login
    >>> from plone.stringinterp import Interpolator
    >>> app = layer['app']
    >>> portal = layer['portal']
    >>> login(app, SITE_OWNER_NAME)
    >>> oid = portal.invokeFactory('Document', 'front-page')
    >>> apage = portal[oid]
    >>> apage.setTitle('Welcome to Plone')
    >>> s = """one two three ${title} ${url} ${nonesuch}"""

    >>> apage = portal['front-page']

    >>> Interpolator(apage)(s)
    'one two three Welcome to Plone http://nohost/plone/front-page ${nonesuch}'


That was a direct call. Let's do it by adapter, too, proving this
may be swapped out.

    >>> from plone.stringinterp.interfaces import IStringInterpolator
    >>> IStringInterpolator(apage)(s)
    'one two three Welcome to Plone http://nohost/plone/front-page ${nonesuch}'


Test caching scheme

    >>> interpolator = IStringInterpolator(apage)
    >>> interpolator(s)
    'one two three Welcome to Plone http://nohost/plone/front-page ${nonesuch}'

    >>> expected = {'url': 'http://nohost/plone/front-page', 'nonesuch': '_bad_', 'title': 'Welcome to Plone'}
    >>> interpolator._ldict._cache == expected
    True


Directly change cache

    >>> interpolator._ldict._cache['nonesuch'] = u'nothing much here'

And prove that the interpolator is using the cache

    >>> interpolator(s)
    'one two three Welcome to Plone http://nohost/plone/front-page nothing much here'
