2011-03-19 06:54:04 +01:00
|
|
|
from tests.test_pip import (reset_env, run_pip,
|
2010-08-05 16:09:40 +02:00
|
|
|
_create_test_package, _change_test_package_version)
|
2011-03-15 20:49:48 +01:00
|
|
|
from tests.local_repos import local_checkout
|
2010-11-21 19:31:15 +01:00
|
|
|
|
2011-05-04 09:44:02 +02:00
|
|
|
|
2010-11-05 21:24:17 +01:00
|
|
|
def test_install_editable_from_git_with_https():
|
|
|
|
"""
|
|
|
|
Test cloning from Git with https.
|
|
|
|
"""
|
2011-03-19 06:54:04 +01:00
|
|
|
reset_env()
|
2010-11-05 21:24:17 +01:00
|
|
|
result = run_pip('install', '-e',
|
2011-09-13 20:17:42 +02:00
|
|
|
'%s#egg=django-vcstorage' %
|
|
|
|
local_checkout('git+https://github.com/jezdez/django-vcstorage.git'),
|
2010-11-05 21:24:17 +01:00
|
|
|
expect_error=True)
|
2011-09-13 20:17:42 +02:00
|
|
|
result.assert_installed('django-vcstorage', with_files=['.git'])
|
2010-11-05 21:24:17 +01:00
|
|
|
|
2010-08-05 16:09:40 +02:00
|
|
|
|
|
|
|
def test_git_with_sha1_revisions():
|
|
|
|
"""
|
|
|
|
Git backend should be able to install from SHA1 revisions
|
|
|
|
"""
|
|
|
|
env = reset_env()
|
|
|
|
version_pkg_path = _create_test_package(env)
|
|
|
|
_change_test_package_version(env, version_pkg_path)
|
|
|
|
sha1 = env.run('git', 'rev-parse', 'HEAD~1', cwd=version_pkg_path).stdout.strip()
|
2010-08-06 20:10:16 +02:00
|
|
|
run_pip('install', '-e', '%s@%s#egg=version_pkg' % ('git+file://' + version_pkg_path.abspath.replace('\\', '/'), sha1))
|
2010-08-05 16:09:40 +02:00
|
|
|
version = env.run('version_pkg')
|
|
|
|
assert '0.1' in version.stdout, version.stdout
|
|
|
|
|
2010-08-05 16:35:05 +02:00
|
|
|
|
|
|
|
def test_git_with_branch_name_as_revision():
|
|
|
|
"""
|
|
|
|
Git backend should be able to install from branch names
|
|
|
|
"""
|
|
|
|
env = reset_env()
|
|
|
|
version_pkg_path = _create_test_package(env)
|
|
|
|
env.run('git', 'checkout', '-b', 'test_branch', expect_stderr=True, cwd=version_pkg_path)
|
|
|
|
_change_test_package_version(env, version_pkg_path)
|
2010-08-06 20:10:16 +02:00
|
|
|
run_pip('install', '-e', '%s@test_branch#egg=version_pkg' % ('git+file://' + version_pkg_path.abspath.replace('\\', '/')))
|
2010-08-05 16:35:05 +02:00
|
|
|
version = env.run('version_pkg')
|
|
|
|
assert 'some different version' in version.stdout
|
|
|
|
|
2010-08-19 15:39:50 +02:00
|
|
|
|
2010-08-05 16:35:05 +02:00
|
|
|
def test_git_with_tag_name_as_revision():
|
|
|
|
"""
|
|
|
|
Git backend should be able to install from tag names
|
|
|
|
"""
|
|
|
|
env = reset_env()
|
|
|
|
version_pkg_path = _create_test_package(env)
|
|
|
|
env.run('git', 'tag', 'test_tag', expect_stderr=True, cwd=version_pkg_path)
|
|
|
|
_change_test_package_version(env, version_pkg_path)
|
2010-08-06 20:05:00 +02:00
|
|
|
run_pip('install', '-e', '%s@test_tag#egg=version_pkg' % ('git+file://' + version_pkg_path.abspath.replace('\\', '/')))
|
2010-08-05 16:35:05 +02:00
|
|
|
version = env.run('version_pkg')
|
|
|
|
assert '0.1' in version.stdout
|
|
|
|
|
2010-11-20 19:44:08 +01:00
|
|
|
|
|
|
|
def test_git_with_tag_name_and_update():
|
|
|
|
"""
|
|
|
|
Test cloning a git repository and updating to a different version.
|
|
|
|
"""
|
|
|
|
reset_env()
|
2011-09-13 20:17:42 +02:00
|
|
|
result = run_pip('install', '-e', '%s#egg=django-vcstorage' %
|
|
|
|
local_checkout('git+http://github.com/jezdez/django-vcstorage.git'),
|
2010-11-20 19:44:08 +01:00
|
|
|
expect_error=True)
|
2011-09-13 20:17:42 +02:00
|
|
|
result.assert_installed('django-vcstorage', with_files=['.git'])
|
2010-11-20 19:44:08 +01:00
|
|
|
result = run_pip('install', '--global-option=--version', '-e',
|
2011-09-13 20:17:42 +02:00
|
|
|
'%s@0.1.1#egg=django-vcstorage' %
|
|
|
|
local_checkout('git+http://github.com/jezdez/django-vcstorage.git'),
|
2010-11-20 19:44:08 +01:00
|
|
|
expect_error=True)
|
2011-09-13 20:17:42 +02:00
|
|
|
assert '0.1.1\n' in result.stdout
|
2010-11-20 19:44:08 +01:00
|
|
|
|
2010-11-21 19:31:15 +01:00
|
|
|
|
|
|
|
def test_git_branch_should_not_be_changed():
|
|
|
|
"""
|
|
|
|
Editable installations should not change branch
|
|
|
|
related to issue #32 and #161
|
|
|
|
"""
|
|
|
|
env = reset_env()
|
2011-09-13 20:17:42 +02:00
|
|
|
run_pip('install', '-e', '%s#egg=django-vcstorage' %
|
|
|
|
local_checkout('git+http://github.com/jezdez/django-vcstorage.git'),
|
2010-11-21 19:31:15 +01:00
|
|
|
expect_error=True)
|
2011-09-13 20:17:42 +02:00
|
|
|
source_dir = env.venv_path/'src'/'django-vcstorage'
|
2010-11-21 19:31:15 +01:00
|
|
|
result = env.run('git', 'branch', cwd=source_dir)
|
2010-11-22 20:34:31 +01:00
|
|
|
assert '* master' in result.stdout
|
|
|
|
|
2011-05-04 09:44:02 +02:00
|
|
|
|
2010-11-22 20:34:31 +01:00
|
|
|
def test_git_with_non_editable_unpacking():
|
|
|
|
"""
|
|
|
|
Test cloning a git repository from a non-editable URL with a given tag.
|
|
|
|
"""
|
|
|
|
reset_env()
|
|
|
|
result = run_pip('install', '--global-option=--version', local_checkout(
|
2011-09-13 20:17:42 +02:00
|
|
|
'git+http://github.com/jezdez/django-vcstorage.git@0.1.1#egg=django-staticfiles'
|
2010-11-22 20:34:31 +01:00
|
|
|
), expect_error=True)
|
2011-09-13 20:17:42 +02:00
|
|
|
assert '0.1.1\n' in result.stdout
|
2010-12-09 03:34:14 +01:00
|
|
|
|
2011-05-04 09:44:02 +02:00
|
|
|
|
2010-12-09 03:34:14 +01:00
|
|
|
def test_git_with_editable_where_egg_contains_dev_string():
|
|
|
|
"""
|
2011-03-19 06:54:04 +01:00
|
|
|
Test cloning a git repository from an editable url which contains "dev" string
|
2010-12-09 03:34:14 +01:00
|
|
|
"""
|
|
|
|
reset_env()
|
|
|
|
result = run_pip('install', '-e', '%s#egg=django-devserver' %
|
|
|
|
local_checkout('git+git://github.com/dcramer/django-devserver.git'))
|
|
|
|
result.assert_installed('django-devserver', with_files=['.git'])
|
|
|
|
|
2011-05-04 09:44:02 +02:00
|
|
|
|
2010-12-09 03:34:14 +01:00
|
|
|
def test_git_with_non_editable_where_egg_contains_dev_string():
|
|
|
|
"""
|
2011-03-19 06:54:04 +01:00
|
|
|
Test cloning a git repository from a non-editable url which contains "dev" string
|
2010-12-09 03:34:14 +01:00
|
|
|
"""
|
|
|
|
env = reset_env()
|
|
|
|
result = run_pip('install', '%s#egg=django-devserver' %
|
|
|
|
local_checkout('git+git://github.com/dcramer/django-devserver.git'))
|
|
|
|
devserver_folder = env.site_packages/'devserver'
|
|
|
|
assert devserver_folder in result.files_created, str(result)
|
2011-05-15 17:47:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_git_with_ambiguous_revs():
|
|
|
|
"""
|
|
|
|
Test git with two "names" (tag/branch) pointing to the same commit
|
|
|
|
"""
|
|
|
|
env = reset_env()
|
|
|
|
version_pkg_path = _create_test_package(env)
|
|
|
|
package_url = 'git+file://%s@0.1#egg=version_pkg' % (version_pkg_path.abspath.replace('\\', '/'))
|
|
|
|
env.run('git', 'tag', '0.1', cwd=version_pkg_path)
|
|
|
|
result = run_pip('install', '-e', package_url)
|
|
|
|
assert 'Could not find a tag or branch' not in result.stdout
|
|
|
|
# it is 'version-pkg' instead of 'version_pkg' because
|
|
|
|
# egg-link name is version-pkg.egg-link because it is a single .py module
|
|
|
|
result.assert_installed('version-pkg', with_files=['.git'])
|