本文整理汇总了Python中djangorecipe.recipe.Recipe.install方法的典型用法代码示例。如果您正苦于以下问题:Python Recipe.install方法的具体用法?Python Recipe.install怎么用?Python Recipe.install使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类djangorecipe.recipe.Recipe
的用法示例。
在下文中一共展示了Recipe.install方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestRecipe
# 需要导入模块: from djangorecipe.recipe import Recipe [as 别名]
# 或者: from djangorecipe.recipe.Recipe import install [as 别名]
#.........这里部分代码省略.........
# and a line which set's up the WSGI app
self.assert_("application = "
"djangorecipe.wsgi.main('project.development', "
"logfile='')"
in contents)
self.assert_("class logger(object)" not in contents)
# Another deployment options is FCGI. The recipe supports an option to
# automatically create the required script.
fcgi_script = os.path.join(self.bin_dir, 'django.fcgi')
self.assert_(os.path.exists(fcgi_script))
# The contents should list our paths
contents = open(fcgi_script).read()
# It should also have a reference to our settings module
self.assert_('project.development' in contents)
# and a line which set's up the WSGI app
self.assert_("djangorecipe.fcgi.main('project.development', "
"logfile='')"
in contents)
self.assert_("class logger(object)" not in contents)
self.recipe.options['logfile'] = '/foo'
self.recipe.make_scripts([], [])
wsgi_script = os.path.join(self.bin_dir, 'django.wsgi')
contents = open(wsgi_script).read()
self.assert_("logfile='/foo'" in contents)
self.recipe.options['logfile'] = '/foo'
self.recipe.make_scripts([], [])
fcgi_script = os.path.join(self.bin_dir, 'django.fcgi')
contents = open(fcgi_script).read()
self.assert_("logfile='/foo'" in contents)
@mock.patch('zc.buildout.easy_install.scripts')
def test_make_protocol_scripts_return_value(self, scripts):
# The return value of make scripts lists the generated scripts.
self.recipe.options['wsgi'] = 'true'
self.recipe.options['fcgi'] = 'true'
scripts.return_value = ['some-path']
self.assertEqual(self.recipe.make_scripts([], []),
['some-path', 'some-path'])
def test_create_project(self):
# If a project does not exist already the recipe will create
# one.
project_dir = os.path.join(self.buildout_dir, 'project')
self.recipe.create_project(project_dir)
# This should have create a project directory
self.assert_(os.path.exists(project_dir))
# With this directory we should have __init__.py to make it a
# package
self.assert_(
os.path.exists(os.path.join(project_dir, '__init__.py')))
# There should also be a urls.py
self.assert_(
os.path.exists(os.path.join(project_dir, 'urls.py')))
# To make it easier to start using this project both a media
# and a templates folder are created
self.assert_(
os.path.exists(os.path.join(project_dir, 'media')))
self.assert_(
os.path.exists(os.path.join(project_dir, 'templates')))
# The project is ready to go since the recipe has generated a
# base settings, development and production file
for f in ('settings.py', 'development.py', 'production.py'):
self.assert_(
示例2: TestRecipe
# 需要导入模块: from djangorecipe.recipe import Recipe [as 别名]
# 或者: from djangorecipe.recipe.Recipe import install [as 别名]
#.........这里部分代码省略.........
self.failIf(os.path.exists(testrunner))
# When we specify an app to test it should create the the
# testrunner
self.recipe.options['test'] = 'knight'
self.recipe.create_test_runner([recipe_dir], [])
self.assert_(os.path.exists(testrunner))
def test_create_manage_script(self):
# This buildout recipe creates a alternative for the standard
# manage.py script. It has all the same functionality as the
# original one but it sits in the bin dir instead of within
# the project.
manage = os.path.join(self.bin_dir, 'django')
self.recipe.create_manage_script([], [])
self.assert_(os.path.exists(manage))
def test_create_manage_script_projectegg(self):
# When a projectegg is specified, then the egg specified
# should get used as the project file.
manage = os.path.join(self.bin_dir, 'django')
self.recipe.options['projectegg'] = 'spameggs'
self.recipe.create_manage_script([], [])
self.assert_(os.path.exists(manage))
# Check that we have 'spameggs' as the project
self.assert_("djangorecipe.manage.main('spameggs.development')"
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(Recipe, 'install_release')
@mock.patch(Recipe, 'create_manage_script')
@mock.patch(Recipe, 'create_test_runner')
def test_extra_paths(self, rmtree, path_exists, urlretrieve,
copytree, working_set, scripts,
install_release, manage, testrunner):
# The recipe allows extra-paths to be specified. It uses these to
# extend the Python path within it's generated scripts.
self.recipe.options['version'] = '1.0'
self.recipe.options['extra-paths'] = 'somepackage\nanotherpackage'
path_exists.return_value = True
working_set.return_value = (None, [])
self.recipe.install()
self.assertEqual(manage.call_args[0][0][-2:],
['somepackage', 'anotherpackage'])
@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(Recipe, 'install_release')
@mock.patch(Recipe, 'create_manage_script')
@mock.patch(Recipe, 'create_test_runner')
@mock.patch('site', 'addsitedir')
def test_pth_files(self, rmtree, path_exists, urlretrieve,
copytree, working_set, scripts,
install_release, manage, testrunner, addsitedir):
# When a pth-files option is set the recipe will use that to add more
# paths to extra-paths.
self.recipe.options['version'] = '1.0'