Test for infrae.subversion
~~~~~~~~~~~~~~~~~~~~~~~~~~

This test suite works for the Native (with pysvn) implementation.

Export
------

The recipe support export feature, in this case, we got an export::

  >>> cd(sample_buildout)
  >>> write('buildout.cfg','''
  ... [buildout]
  ... parts = svnpart
  ...
  ... [svnpart]
  ... recipe = infrae.subversion
  ... export = true
  ... urls = 
  ...    %s/my.testing/trunk my.testing
  ... ''' % repository)

Re-run buildout, and check the output::

  >>> print system(buildout)
  Installing svnpart.
  >>> ls('parts/svnpart')
  d  my.testing
  >>> ls('parts/svnpart/my.testing')
  -  LICENSE
  d  my
  -  setup.py

(There is no ``.svn`` directory in the parts).

If I delete the directory, it's recreated::

  >>> rmdir('parts/svnpart/my.testing')
  >>> print system(buildout)
  Updating svnpart.
  -------- WARNING --------
  Directory /.../sample-buildout/parts/svnpart/my.testing have been removed.
  Changes might be lost.
  -------- WARNING --------
  >>> ls('parts/svnpart')
  d  my.testing
  >>> ls('parts/svnpart/my.testing')
  -  LICENSE
  d  my
  -  setup.py


Export and Information
----------------------

You can't collect revision information from a svn export. So we're
going to readd a test recipe to look at revisions, and do a svn export
to check that this break nothing:

  >>> mkdir('recipe')
  >>> mkdir('recipe/test_export')
  >>> write('recipe/test_export/__init__.py', '''
  ... class TestExport(object):
  ...     def __init__(self, buildout, name, options):
  ...         self.buildout = buildout
  ...         print '__init__ phase: ', buildout['svnpart']['revisions']
  ...     def install(self):
  ...         print 'install phase: ', self.buildout['svnpart']['revisions']
  ...         return []
  ...     def update(self):
  ...         print 'update phase: ', self.buildout['svnpart']['revisions']
  ...         return []
  ... ''')

  >>> write('recipe/setup.py', '''
  ... from setuptools import setup, find_packages
  ... setup(name='test_export', version='dev',
  ...       packages=find_packages(),
  ...       entry_points={'zc.buildout': ['default=test_export:TestExport']})
  ... ''')

  >>> write('buildout.cfg', '''
  ... [buildout]
  ... develop = recipe
  ... parts = svnpart testexport
  ...
  ... [svnpart]
  ... recipe = infrae.subversion
  ... urls =
  ...    %s/my.testing/trunk my.testing
  ...    %s/infrae.subversion/trunk infrae.subversion
  ... export_info = true
  ... export = true
  ...
  ... [testexport]
  ... recipe = test_export
  ... ''' % (repository, repository))

When running this buildout for the first time, the test recipe sees how
revisions for the two URLs get checked out:

  >>> rmdir('parts/svnpart')
  >>> print system(buildout)
  Develop: '.../sample-buildout/recipe'
  __init__ phase:
  Uninstalling svnpart.
  Running uninstall recipe.
  Installing svnpart.
  Installing testexport.
  install phase:  .../test_repos/infrae.subversion/trunk 2
                  .../test_repos/my.testing/trunk 2

Running the buildout again immediately, the test recipe will see that the
current revisions are the same before and after the update:

  >>> print system(buildout)
  Develop: '.../sample-buildout/recipe'
  __init__ phase:
  Updating svnpart.
  Updating testexport.
  update phase:
