Grokproject with alternative release URL
========================================

Providing an alternative release URL for grokproject is useful if you need to
have your own local mirror for grok.

In this test we will use an alternative release URL for grokproject. It is a
"file:///" URL pointing to a directory with a fake set of grok release
information files:

    >>> testdir = tempfile.mkdtemp() # can be removed when tempdir becomes really temporary
    >>> fake_release = os.path.join(testdir, 'fake_release')
    >>> os.mkdir(fake_release)
    >>> touch(fake_release, 'current', data='grok-0.555.cfg')
    >>> touch(fake_release, 'grok-0.555.cfg',
    ...       data='[versions]\ngrok = 0.555\n')
    >>> ls(fake_release)
    current
    grok-0.555.cfg
    >>> cat(fake_release, 'current')
    grok-0.555.cfg
    >>> cat(fake_release, 'grok-0.555.cfg')
    [versions]
    grok = 0.555
    <BLANKLINE>
    >>> alt_url = 'file://' + os.path.join(fake_release, '')

Let's use paster, with a "file:///" url pointing to the fake grok release. We
won't run buildout because the version file is not actually valid::

    >>> paster = current_dir + '/bin/paster'
    >>> paster_params = ('create -t grok --no-interactive -o'.split() +
    ...                  [testdir])
    >>> grok_params = ('grokexample user=a passwd=a run_buildout=false '
    ...                'grok_release_url=' + alt_url).split()
    >>> sh([paster] + paster_params + grok_params)
    ['/.../bin/paster', 'create', '-t', 'grok', '--no-interactive',
     '-o', ... 'grokexample', 'user=a', 'passwd=a', 'run_buildout=false',
     'grok_release_url=file:///.../fake_release/']
    ...

Let's check the contents::

    >>> package_dir = os.path.join(testdir, 'grokexample')
    >>> ls(package_dir)
    bootstrap.py
    buildout.cfg
    etc
    setup.py
    src
    versions.cfg

    >>> software_dir = os.path.join(package_dir, 'src', 'grokexample')
    >>> ls(software_dir)
    __init__.py
    app.py
    app.txt
    app_templates
    configure.zcml
    ftesting.zcml
    static
    tests.py

Let's see if the information in our fake release URL was correctly propagated.

    >>> cat(package_dir, 'versions.cfg')
    # This file contains a list of versions of the various grok modules that
    # belong together.
    # It was downloaded from file://.../fake_release/grok-0.555.cfg
    # when this project was created.
    <BLANKLINE>
    [versions]
    grok = 0.555
    <BLANKLINE>
    ...

    >>> cat(package_dir, 'buildout.cfg')
    [buildout]
    ...
    [eggbasket]
    recipe = z3c.recipe.eggbasket
    eggs = grok
    url = file:///.../grok-eggs-0.555.tgz...

Cleanup:

    >>> rmdir(package_dir)

The "zopectl" version of the template should behave similarly:

    >>> paster = current_dir + '/bin/paster'
    >>> paster_params = ('create -t grok --no-interactive -o'.split() +
    ...                  [testdir])
    >>> grok_params = ('grokexample user=a passwd=a run_buildout=false '
    ...                'zopectl=True grok_release_url=' + alt_url).split()
    >>> sh([paster] + paster_params + grok_params)
    ['/.../bin/paster', 'create', '-t', 'grok', '--no-interactive',
     '-o', ... 'grokexample', 'user=a', 'passwd=a', 'run_buildout=false',
     'zopectl=True', 'grok_release_url=.../fake_release/']
    ...

Let's check the contents::

    >>> package_dir = os.path.join(testdir, 'grokexample')
    >>> ls(package_dir)
    bootstrap.py
    buildout.cfg
    setup.py
    src
    versions.cfg

    >>> software_dir = os.path.join(package_dir, 'src', 'grokexample')
    >>> ls(software_dir)
    __init__.py
    app.py
    app.txt
    app_templates
    configure.zcml
    ftesting.zcml
    static
    tests.py

Let's see if the information in our fake release URL was correctly propagated.

    >>> cat(package_dir, 'versions.cfg')
    # This file contains a list of versions of the various grok modules that
    # belong together.
    # It was downloaded from file://.../fake_release/grok-0.555.cfg
    # when this project was created.
    <BLANKLINE>
    [versions]
    grok = 0.555
    <BLANKLINE>
    ...

    >>> cat(package_dir, 'buildout.cfg')
    [buildout]
    ...
    [eggbasket]
    recipe = z3c.recipe.eggbasket
    eggs = grok
    url = file:///.../grok-eggs-0.555.tgz...

Cleanup (remove this after tempdir is really fixed):

    >>> rmdir(testdir)
