From 6bdb5041f612c5d3551cd916129428301474822b Mon Sep 17 00:00:00 2001 From: Andrey Bulgakov Date: Sun, 9 Sep 2012 17:14:05 +0400 Subject: [PATCH] test for check-already-downloaded feature --- tests/test_download.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/test_download.py b/tests/test_download.py index 829d4495e..a75c46e23 100644 --- a/tests/test_download.py +++ b/tests/test_download.py @@ -39,3 +39,31 @@ def test_download_should_download_dependencies(): openid_tarball_prefix = str(Path('scratch')/ 'python-openid-') assert any(path.startswith(openid_tarball_prefix) for path in result.files_created) assert env.site_packages/ 'openid' not in result.files_created + + +def test_download_should_skip_existing_files(): + """ + It should not download files already existing in the scratch dir + """ + env = reset_env() + + write_file('test-req.txt', textwrap.dedent(""" + INITools==0.1 + """)) + + result = run_pip('install', '-r', env.scratch_path/ 'test-req.txt', '-d', '.', expect_error=True) + assert Path('scratch')/ 'INITools-0.1.tar.gz' in result.files_created + assert env.site_packages/ 'initools' not in result.files_created + + # adding second package to test-req.txt + write_file('test-req.txt', textwrap.dedent(""" + INITools==0.1 + python-openid==2.2.5 + """)) + + # only the second package should be downloaded + result = run_pip('install', '-r', env.scratch_path/ 'test-req.txt', '-d', '.', expect_error=True) + assert Path('scratch')/ 'python-openid-2.2.5.zip' in result.files_created + assert Path('scratch')/ 'INITools-0.1.tar.gz' not in result.files_created + assert env.site_packages/ 'initools' not in result.files_created + assert env.site_packages/ 'openid' not in result.files_created