Commit 08cdccef authored by Jason R. Coombs's avatar Jason R. Coombs

Call index.download, covering more code. Split test into two.

parent 9fad9937
...@@ -224,40 +224,43 @@ class TestPackageIndex: ...@@ -224,40 +224,43 @@ class TestPackageIndex:
assert dists[0].version == '' assert dists[0].version == ''
assert dists[1].version == vc assert dists[1].version == vc
def test_download_git_with_rev(self, tmpdir):
def test_download_git(self): url = 'git+https://github.example/group/project@master#egg=foo'
index = setuptools.package_index.PackageIndex( index = setuptools.package_index.PackageIndex()
hosts=('www.example.com',)
)
index._vcs_split_rev_from_url = mock.Mock()
url = 'https://example.com/bar'
rev = '2995'
index._vcs_split_rev_from_url.return_value = (url, rev)
filename = "somefile.py"
with mock.patch("os.system") as os_system_mock: with mock.patch("os.system") as os_system_mock:
result = index.download(url, str(tmpdir))
result = index._download_git(url, filename)
os_system_mock.assert_called() os_system_mock.assert_called()
assert os_system_mock.call_args_list[0][0] \ expected_dir = str(tmpdir / 'project@master')
== ("git clone --quiet %s %s" % (url, filename), ) expected = (
'git clone --quiet '
assert os_system_mock.call_args_list[1][0] \ 'https://github.example/group/project {expected_dir}'
== ("(cd %s && git checkout --quiet %s)" % (filename, rev), ) ).format(**locals())
assert result == filename first_call_args = os_system_mock.call_args_list[0][0]
assert first_call_args == (expected,)
index._vcs_split_rev_from_url.return_value = (url, None)
tmpl = '(cd {expected_dir} && git checkout --quiet master)'
expected = tmpl.format(**locals())
assert os_system_mock.call_args_list[1][0] == (expected,)
assert result == expected_dir
def test_download_git_no_rev(self, tmpdir):
url = 'git+https://github.example/group/project#egg=foo'
index = setuptools.package_index.PackageIndex()
with mock.patch("os.system") as os_system_mock: with mock.patch("os.system") as os_system_mock:
result = index.download(url, str(tmpdir))
index._download_git(url, filename) os_system_mock.assert_called()
os_system_mock.assert_called_once_with("git clone --quiet %s %s" % (url, filename)) expected_dir = str(tmpdir / 'project')
expected = (
'git clone --quiet '
'https://github.example/group/project {expected_dir}'
).format(**locals())
os_system_mock.assert_called_once_with(expected)
class TestContentCheckers: class TestContentCheckers:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment