本文整理汇总了Python中djangorecipe.recipe.Recipe.update方法的典型用法代码示例。如果您正苦于以下问题:Python Recipe.update方法的具体用法?Python Recipe.update怎么用?Python Recipe.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类djangorecipe.recipe.Recipe
的用法示例。
在下文中一共展示了Recipe.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestRecipe
# 需要导入模块: from djangorecipe.recipe import Recipe [as 别名]
# 或者: from djangorecipe.recipe.Recipe import update [as 别名]
#.........这里部分代码省略.........
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
# The line above should indicate a failure (non-zero exit
# code)
self.assertRaises(UserError, self.recipe.install_svn_version,
'trunk', 'downloads', 'parts/django', False)
@mock.patch('shutil', 'copytree')
@mock.patch(Recipe, 'command')
def test_svn_install_from_cache(self, copytree, command):
# If the buildout is told to install from cache it will not do
# a checkout but instead an existing checkout
self.recipe.buildout['buildout']['install-from-cache'] = 'true'
# Now we can run the installation method
self.recipe.install_svn_version('trunk', 'downloads',
'parts/django', True)
# This should not have called the recipe's command method
self.failIf(command.called)
示例2: TestRecipe
# 需要导入模块: from djangorecipe.recipe import Recipe [as 别名]
# 或者: from djangorecipe.recipe.Recipe import update [as 别名]
#.........这里部分代码省略.........
def test_create_wsgi_script_projectegg(self):
# When a projectegg is specified, then the egg specified
# should get used as the project in the wsgi script.
wsgi = os.path.join(self.bin_dir, 'django.wsgi')
recipe_dir = os.path.abspath(
os.path.join(os.path.dirname(__file__), '..'))
self.recipe.options['projectegg'] = 'spameggs'
self.recipe.options['wsgi'] = 'true'
self.recipe.make_scripts([recipe_dir], [])
self.assert_(os.path.exists(wsgi))
# Check that we have 'spameggs' as the project
self.assert_('spameggs.development' in open(wsgi).read())
def test_settings_option(self):
# The settings option can be used to specify the settings file
# for Django to use. By default it uses `development`.
self.assertEqual(self.recipe.options['settings'], 'development')
# When we change it an generate a manage script it will use
# this var.
self.recipe.options['settings'] = 'spameggs'
self.recipe.create_manage_script([], [])
manage = os.path.join(self.bin_dir, 'django')
self.assert_("djangorecipe.manage.main('project.spameggs')"
in open(manage).read())
@mock.patch('shutil', 'rmtree')
@mock.patch('os.path', 'exists')
@mock.patch('urllib', 'urlretrieve')
@mock.patch('shutil', 'copytree')
@mock.patch(ZCRecipeEggScripts, 'working_set')
@mock.patch('zc.buildout.easy_install', 'scripts')
@mock.patch('subprocess', 'call')
def test_update_with_cache(self, rmtree, path_exists, urlretrieve,
copytree, working_set, scripts,
call_process):
path_exists.return_value = True
working_set.return_value = (None, [])
# When the recipe is asked to do an update whilst in install
# from cache mode it just ignores it
self.recipe.install_from_cache = True
self.recipe.update()
self.failIf(call_process.called)
@mock.patch('shutil', 'rmtree')
@mock.patch('os.path', 'exists')
@mock.patch('urllib', 'urlretrieve')
@mock.patch('shutil', 'copytree')
@mock.patch(ZCRecipeEggScripts, 'working_set')
@mock.patch('zc.buildout.easy_install', 'scripts')
@mock.patch('subprocess', 'call')
def test_update_with_newest_false(self, rmtree, path_exists, urlretrieve,
copytree, working_set, scripts,
call_process):
path_exists.return_value = True
working_set.return_value = (None, [])
# When the recipe is asked to do an update whilst in install
# from cache mode it just ignores it
self.recipe.buildout['buildout']['newest'] = 'false'
self.recipe.update()
self.assertFalse(call_process.called)
def test_python_option(self):
# The python option makes it possible to specify a specific Python
# executable which is to be used for the generated scripts.
recipe = Recipe({