From 63684d7e4d034cf2165417b822dcf91f5b414e7e Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Thu, 19 Jul 2018 21:31:43 -0700 Subject: [PATCH] Add failing test. --- tests/functional/test_install_vcs.py | 59 +++++++++++++++++++++------- 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/tests/functional/test_install_vcs.py b/tests/functional/test_install_vcs.py index 5737a3e2e..9b6c7f75b 100644 --- a/tests/functional/test_install_vcs.py +++ b/tests/functional/test_install_vcs.py @@ -180,23 +180,52 @@ def test_git_with_tag_name_as_revision(script): assert '0.1' in version.stdout -@pytest.mark.network -def test_git_with_ref_as_revision(script): +def _add_ref(script, path, ref): """ - Git backend should be able to install from a ref + Add a new ref to a repository at the given path. """ - version_pkg_path = _create_test_package(script) - script.run( - 'git', 'update-ref', 'refs/foo/bar', 'HEAD', - expect_stderr=True, - cwd=version_pkg_path, - ) - _change_test_package_version(script, version_pkg_path) - script.pip( - 'install', '-e', '%s@refs/foo/bar#egg=version_pkg' % - ('git+file://' + version_pkg_path.abspath.replace('\\', '/')), - expect_stderr=True - ) + script.run('git', 'update-ref', ref, 'HEAD', expect_stderr=True, cwd=path) + + +def make_version_pkg_url(path, revision=None): + path = path.abspath.replace('\\', '/') + url_rev = '' if revision is None else '@' + revision + url = 'git+file://{}{}#egg=version_pkg'.format(path, url_rev) + + return url + + +def test_git_install_ref(script): + """ + The Git backend should be able to install a ref with the first install. + """ + package_path = _create_test_package(script) + _add_ref(script, package_path, 'refs/foo/bar') + _change_test_package_version(script, package_path) + + package_url = make_version_pkg_url(package_path, revision='refs/foo/bar') + script.pip('install', '-e', package_url, expect_stderr=True) + version = script.run('version_pkg') + assert '0.1' in version.stdout + + +def test_git_install_then_install_ref(script): + """ + The Git backend should be able to install a ref after a package has + already been installed. + """ + package_path = _create_test_package(script) + _add_ref(script, package_path, 'refs/foo/bar') + _change_test_package_version(script, package_path) + + package_url = make_version_pkg_url(package_path) + script.pip('install', '-e', package_url, expect_stderr=True) + version = script.run('version_pkg') + assert 'some different version' in version.stdout + + # Now install the ref. + package_url = make_version_pkg_url(package_path, revision='refs/foo/bar') + script.pip('install', '-e', package_url, expect_stderr=True) version = script.run('version_pkg') assert '0.1' in version.stdout