本文整理汇总了Python中djangorecipe.recipe.Recipe.version_to_svn方法的典型用法代码示例。如果您正苦于以下问题:Python Recipe.version_to_svn方法的具体用法?Python Recipe.version_to_svn怎么用?Python Recipe.version_to_svn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类djangorecipe.recipe.Recipe
的用法示例。
在下文中一共展示了Recipe.version_to_svn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestRecipe
# 需要导入模块: from djangorecipe.recipe import Recipe [as 别名]
# 或者: from djangorecipe.recipe.Recipe import version_to_svn [as 别名]
#.........这里部分代码省略.........
self.recipe.command('silly-command')
self.assertEqual(
popen.call_args,
(('silly-command',), {'shell': True, 'stdout': None}))
def test_create_file(self):
# The create file helper should create a file at a certain
# location unless it already exists. We will need a
# non-existing file first.
f, name = tempfile.mkstemp()
# To show the function in action we need to delete the file
# before testing.
os.remove(name)
# The method accepts a template argument which it will use
# with the options argument for string substitution.
self.recipe.create_file(name, 'Spam %s', 'eggs')
# Let's check the contents of the file
self.assertEqual(open(name).read(), 'Spam eggs')
# If we try to write it again it will just ignore our request
self.recipe.create_file(name, 'Spam spam spam %s', 'eggs')
# The content of the file should therefore be the same
self.assertEqual(open(name).read(), 'Spam eggs')
# Now remove our temp file
os.remove(name)
def test_generate_secret(self):
# To create a basic skeleton the recipe also generates a
# random secret for the settings file. Since it should very
# unlikely that it will generate the same key a few times in a
# row we will test it with letting it generate a few keys.
self.assert_(len(set(
[self.recipe.generate_secret() for i in xrange(10)])) > 1)
def test_version_to_svn(self):
# Version specification that lead to a svn repository can be
# specified in different ways. Just specifying `trunk` should
# be enough to get the full url to the Django trunk.
self.assertEqual(self.recipe.version_to_svn('trunk'),
'http://code.djangoproject.com/svn/django/trunk/')
# Any other specification should lead to the url it is given
self.assertEqual(self.recipe.version_to_svn('svn://somehost/trunk'),
'svn://somehost/trunk')
def test_version_to_download_suffic(self):
# To create standard names for the download directory a method
# is provided which converts a version to a dir suffix. A
# simple pointer to trunk should return svn.
self.assertEqual(self.recipe.version_to_download_suffix('trunk'),
'svn')
# Any other url should return the last path component. This
# works out nicely for branches or version pinned url's.
self.assertEqual(self.recipe.version_to_download_suffix(
'http://monty/branches/python'), 'python')
def test_make_protocol_scripts(self):
# To ease deployment a WSGI script can be generated. The
# script adds any paths from the `extra_paths` option to the
# Python path.
self.recipe.options['wsgi'] = 'true'
self.recipe.options['fcgi'] = 'true'
self.recipe.make_scripts([], [])
# This should have created a script in the bin dir
wsgi_script = os.path.join(self.bin_dir, 'django.wsgi')
self.assert_(os.path.exists(wsgi_script))
# The contents should list our paths
contents = open(wsgi_script).read()