本文整理汇总了Python中djangorecipe.recipe.Recipe.install_svn_version方法的典型用法代码示例。如果您正苦于以下问题:Python Recipe.install_svn_version方法的具体用法?Python Recipe.install_svn_version怎么用?Python Recipe.install_svn_version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类djangorecipe.recipe.Recipe
的用法示例。
在下文中一共展示了Recipe.install_svn_version方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestRecipe
# 需要导入模块: from djangorecipe.recipe import Recipe [as 别名]
# 或者: from djangorecipe.recipe.Recipe import install_svn_version [as 别名]
#.........这里部分代码省略.........
'http://www.djangoproject.com/download/0.96.2/tarball/')
# The file should have been filled with the contents from the
# handle it got.
self.assertEqual(open(filename).read(), 'Django tarball')
finally:
shutil.rmtree(tmp)
@mock.patch('setuptools.archive_util', 'unpack_archive')
@mock.patch('shutil', 'move')
@mock.patch('shutil', 'rmtree')
@mock.patch('os', 'listdir')
def test_install_release(self, unpack, move, rmtree, listdir):
# To install a release the recipe uses a specific method. We
# have have mocked all the calls which interact with the
# filesystem.
listdir.return_value = ('Django-0.96-2',)
self.recipe.install_release('0.96.2', 'downloads',
'downloads/django-0.96.2.tar.gz',
'parts/django')
# Let's see what the mock's have been called with
self.assertEqual(listdir.call_args,
(('downloads/django-archive',), {}))
self.assertEqual(unpack.call_args,
(('downloads/django-0.96.2.tar.gz',
'downloads/django-archive'), {}))
self.assertEqual(move.call_args,
(('downloads/django-archive/Django-0.96-2',
'parts/django'), {}))
self.assertEqual(rmtree.call_args,
(('downloads/django-archive',), {}))
@mock.patch('shutil', 'copytree')
@mock.patch(Recipe, 'command')
def test_install_svn_version(self, copytree, command):
# Installation from svn is handled by a method. We have mocked
# the command method to avoid actual checkouts of Django.
self.recipe.install_svn_version('trunk', 'downloads',
'parts/django', False)
# This should have tried to do a checkout of the Django trunk
self.assertEqual(command.call_args,
(('svn co http://code.djangoproject.com/svn/django/trunk/ downloads/django-svn -q',), {}))
# A copy command to the parts directory should also have been
# issued
self.assertEqual(copytree.call_args,
(('downloads/django-svn', 'parts/django'), {}))
@mock.patch('shutil', 'copytree')
@mock.patch('os.path', 'exists')
@mock.patch(Recipe, 'command')
def test_install_and_update_svn_version(self, copytree, exists, command):
# When an checkout has been done of a svn based installation
# is already done the recipe should just update it.
exists.return_value = True
self.recipe.install_svn_version('trunk', 'downloads',
'parts/django', False)
self.assertEqual(exists.call_args, (('downloads/django-svn',), {}))
self.assertEqual(command.call_args,
(('svn up -q',), {'cwd': 'downloads/django-svn'}))
@mock.patch(Recipe, 'command')
def test_install_broken_svn(self, command):
# When the checkout from svn fails during a svn build the
# installation method raises an error. We will simulate this
# failure by telling our mock what to do.
command.return_value = 1