======
Deploy
======

With buildout.cfg
-----------------

Test with default config file::

  >>> from iw.releaser.testing import clearRepository
  >>> clearRepository(test)

Deploy::

  >>> url = svn_url + '/sample-buildout/trunk'
  >>> from iw.releaser.project import deploy_release
  >>> deploy_release(url, sample_buildout, 'full')
  Checking python version ...
  ...

Check tarball::

  >>> parent_dir = os.path.split(sample_buildout)[0]

  >>> ls(parent_dir)
  -  release-trunk-buildout.tgz
  d  sample-buildout

Let's unarchive the tarball to check its content::

  >>> from iw.releaser.base import TarFile
  >>> tarfile = os.path.join(parent_dir, 
  ...                        'release-trunk-buildout.tgz') 
  >>> tar = TarFile.open(tarfile, 'r:gz')
  >>> files = sorted([fileinfo.name for fileinfo in tar.getmembers()])
  >>> for file_ in files:
  ...     print file_
  bin/activate
  ...
  bootstrap.py
  buildout.cfg
  downloads/dist/
  ...
  eggs/setuptools-...
  ...

Noticed that we removed .svn directories, and .installed.cfg.

A deploy from an existing buildout
----------------------------------

Let's remove the tarfile::

  >>> os.remove(tarfile)

Let's checkout the buildout::

  >>> deploy_release(sample_buildout)
  Checking python version ...
  ...

Check tarball::

  >>> parent_dir = os.path.split(sample_buildout)[0]

  >>> ls(parent_dir)
  -  release-sample-buildout-buildout.tgz
  d  sample-buildout

Let's unarchive the tarball to check its content::

  >>> tarfile = join(parent_dir, 'release-sample-buildout-buildout.tgz')
  >>> tar = TarFile.open(tarfile, 'r:gz')
  >>> files = sorted([fileinfo.name for fileinfo in tar.getmembers()])
  >>> for file_ in files:
  ...     print file_
  bin/activate
  ...
  bootstrap.py
  buildout.cfg
  downloads/dist/
  ...
  eggs/setuptools-...
  ...

Noticed that we removed .svn directories, and .installed.cfg.


With sample.cfg
-----------------

Test with default config file::

  >>> from iw.releaser.testing import clearBuildout
  >>> clearBuildout(test)
  >>> write(sample_buildout, 'buildout.cfg','''
  ... [buildout]
  ... parts=
  ... download-cache = downloads
  ... ''')

  >>> write(sample_buildout, 'sample.cfg','''
  ... [buildout]
  ... parts=
  ... download-cache = downloads
  ... ''')

Deploy::

  >>> from iw.releaser.project import deploy_release
  >>> deploy_release(join(sample_buildout, 'sample.cfg'),
  ...                archiving='full')
  Checking python version ...
  ...
  Calling bin/buildout -c sample.cfg -v
  ...


Check tarball::

  >>> parent_dir = os.path.split(sample_buildout)[0]

  >>> ls(parent_dir)
  - release-sample-buildout-sample.tgz
  d sample-buildout

With developer.cfg
------------------

Making sure download-cache stops the release if it 
is not there:

Test with default config file::

  >>> from iw.releaser.testing import clearBuildout
  >>> clearBuildout(test)
  >>> write(sample_buildout, 'buildout.cfg','''
  ... [buildout]
  ... parts=
  ... download-cache = downloads
  ... ''')

  >>> write(sample_buildout, 'developer.cfg','''
  ... [buildout]
  ... parts=
  ...
  ... ''')

Deploy::

  #>> from iw.releaser.project import deploy_release
  #>> deploy_release(join(sample_buildout, 'developer.cfg'),
  #...                archiving='full')
  #Traceback (most recent call last):
  #...
  #ReleaseError: You need to add 'download-cache = downloads'' in the [buildout] section

With developer.cfg
------------------

Making sure a missing download-cache stops the release.

Test with default config file::

  >>> from iw.releaser.testing import clearBuildout
  >>> clearBuildout(test)
  >>> write(sample_buildout, 'buildout.cfg','''
  ... [buildout]
  ... parts=
  ... download-cache = downloads
  ... ''')

  >>> write(sample_buildout, 'developer.cfg','''
  ... [buildout]
  ... parts=
  ...
  ... ''')

Deploy::

  #>> from iw.releaser.project import deploy_release
  #>> deploy_release(join(sample_buildout, 'developer.cfg'),
  #...                archiving='full')
  #Traceback (most recent call last):
  #...
  #ReleaseError: You need to add 'download-cache = downloads'' in the [buildout] section

Various tests
-------------

Making sure a missing download-cache stops the release.

Test with default config file::

  >>> from iw.releaser.testing import clearBuildout
  >>> clearBuildout(test)
  >>> write(sample_buildout, 'buildout.cfg','''
  ... [buildout]
  ... parts=
  ... download-cache = downloads
  ... ''')

  >>> write(sample_buildout, 'developer.cfg','''
  ... [buildout]
  ... parts=
  ... download-cache = downloads
  ... ''')

Deploy::

  >>> from iw.releaser.project import deploy_release
  >>> deploy_release(join(sample_buildout, 'developer.cfg'),
  ...                archiving=url)
  Checking python version ...
  2.4 ok.
  Using local directory /... with developer.cfg
  New python executable in ./bin/python
  Installing setuptools.............................done.
  ...
  release-sample-buildout-developer.tgz ok.

