Example #1
0
def test_get_branch_revs_should_return_branch_name_and_commit_pair():
    env = reset_env()
    version_pkg_path = _create_test_package(env)
    env.run('git', 'branch', 'branch0.1', cwd=version_pkg_path)
    commit = env.run('git', 'rev-parse', 'HEAD',
                     cwd=version_pkg_path).stdout.strip()
    git = Git()
    result = git.get_branch_revs(version_pkg_path)
    assert result == {'master': commit, 'branch0.1': commit}
def test_get_branch_revs_should_return_branch_name_and_commit_pair():
    env = reset_env()
    version_pkg_path = _create_test_package(env)
    env.run('git', 'branch', 'branch0.1', cwd=version_pkg_path)
    commit = env.run('git', 'rev-parse', 'HEAD',
                     cwd=version_pkg_path).stdout.strip()
    git = Git()
    result = git.get_branch_revs(version_pkg_path)
    assert result == {'master': commit, 'branch0.1': commit}
Example #3
0
def test_git_works_with_editable_non_origin_repo():
    # set up, create a git repo and install it as editable from a local directory path
    env = reset_env()
    version_pkg_path = _create_test_package(env)
    run_pip("install", "-e", version_pkg_path.abspath)

    # 'freeze'ing this should not fall over, but should result in stderr output warning
    result = run_pip("freeze", expect_stderr=True)
    assert "Error when trying to get requirement" in result.stderr
    assert "Could not determine repository location" in result.stdout
    assert "version-pkg==0.1" in result.stdout
Example #4
0
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)
    run_pip('install', '-e', '%s@test_tag#egg=version_pkg' % ('git+file://' + version_pkg_path.abspath.replace('\\', '/')))
    version = env.run('version_pkg')
    assert '0.1' in version.stdout
Example #5
0
def test_git_works_with_editable_non_origin_repo():
    # set up, create a git repo and install it as editable from a local directory path
    env = reset_env()
    version_pkg_path = _create_test_package(env)
    run_pip('install', '-e', version_pkg_path.abspath)

    # 'freeze'ing this should not fall over, but should result in stderr output warning
    result = run_pip('freeze', expect_stderr=True)
    assert "Error when trying to get requirement" in result.stderr
    assert "Could not determine repository location" in result.stdout
    assert "version-pkg==0.1" in result.stdout
Example #6
0
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()
    run_pip('install', '-e', '%s@%s#egg=version_pkg' % ('git+file://' + version_pkg_path.abspath.replace('\\', '/'), sha1))
    version = env.run('version_pkg')
    assert '0.1' in version.stdout, version.stdout
def test_get_branch_revs_should_ignore_no_branch():
    env = reset_env()
    version_pkg_path = _create_test_package(env)
    env.run('git', 'branch', 'branch0.1', cwd=version_pkg_path)
    commit = env.run('git', 'rev-parse', 'HEAD',
                     cwd=version_pkg_path).stdout.strip()
    # current branch here is "* (nobranch)"
    env.run('git', 'checkout', commit,
            cwd=version_pkg_path, expect_stderr=True)
    git = Git()
    result = git.get_branch_revs(version_pkg_path)
    assert result == {'master': commit, 'branch0.1': commit}
Example #8
0
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://%[email protected]#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'])
Example #9
0
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)
    run_pip(
        'install', '-e', '%s@test_tag#egg=version_pkg' %
        ('git+file://' + version_pkg_path.abspath.replace('\\', '/')))
    version = env.run('version_pkg')
    assert '0.1' in version.stdout
Example #10
0
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://%[email protected]#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"])
Example #11
0
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)
    run_pip(
        "install", "-e", "%s@test_tag#egg=version_pkg" % ("git+file://" + version_pkg_path.abspath.replace("\\", "/"))
    )
    version = env.run("version_pkg")
    assert "0.1" in version.stdout
Example #12
0
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()
    run_pip(
        "install", "-e", "%s@%s#egg=version_pkg" % ("git+file://" + version_pkg_path.abspath.replace("\\", "/"), sha1)
    )
    version = env.run("version_pkg")
    assert "0.1" in version.stdout, version.stdout
Example #13
0
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()
    run_pip(
        'install', '-e', '%s@%s#egg=version_pkg' %
        ('git+file://' + version_pkg_path.abspath.replace('\\', '/'), sha1))
    version = env.run('version_pkg')
    assert '0.1' in version.stdout, version.stdout
Example #14
0
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://%[email protected]#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'])
Example #15
0
def test_editable_git_upgrade():
    """
    Test installing an editable git package from a repository, upgrading the repository,
    installing again, and check it gets the newer version
    """
    env = reset_env()
    version_pkg_path = _create_test_package(env)
    run_pip('install', '-e', '%s#egg=version_pkg' % ('git+file://' + version_pkg_path))
    version = env.run('version_pkg')
    assert '0.1' in version.stdout
    _change_test_package_version(env, version_pkg_path)
    run_pip('install', '-e', '%s#egg=version_pkg' % ('git+file://' + version_pkg_path))
    version2 = env.run('version_pkg')
    assert 'some different version' in version2.stdout, "Output: %s" % (version2.stdout)
Example #16
0
def test_editable_git_upgrade():
    """
    Test installing an editable git package from a repository, upgrading the repository,
    installing again, and check it gets the newer version
    """
    env = reset_env()
    version_pkg_path = _create_test_package(env)
    run_pip("install", "-e", "%s#egg=version_pkg" % ("git+file://" + version_pkg_path))
    version = env.run("version_pkg")
    assert "0.1" in version.stdout
    _change_test_package_version(env, version_pkg_path)
    run_pip("install", "-e", "%s#egg=version_pkg" % ("git+file://" + version_pkg_path))
    version2 = env.run("version_pkg")
    assert "some different version" in version2.stdout
Example #17
0
def test_get_branch_revs_should_ignore_no_branch():
    env = reset_env()
    version_pkg_path = _create_test_package(env)
    env.run('git', 'branch', 'branch0.1', cwd=version_pkg_path)
    commit = env.run('git', 'rev-parse', 'HEAD',
                     cwd=version_pkg_path).stdout.strip()
    # current branch here is "* (nobranch)"
    env.run('git',
            'checkout',
            commit,
            cwd=version_pkg_path,
            expect_stderr=True)
    git = Git()
    result = git.get_branch_revs(version_pkg_path)
    assert result == {'master': commit, 'branch0.1': commit}
Example #18
0
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)
    run_pip(
        "install",
        "-e",
        "%s@test_branch#egg=version_pkg" % ("git+file://" + version_pkg_path.abspath.replace("\\", "/")),
    )
    version = env.run("version_pkg")
    assert "some different version" in version.stdout