From 282682a64687daab30cd4b3307c70796b694c470 Mon Sep 17 00:00:00 2001 From: Marica Odagaki Date: Tue, 15 Nov 2016 19:25:53 -0800 Subject: [PATCH] Fix: don't fetch already installed package --- native_package_install.py | 2 +- tests/test_native_package_install.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/native_package_install.py b/native_package_install.py index fc8fd97..547b64d 100755 --- a/native_package_install.py +++ b/native_package_install.py @@ -213,7 +213,7 @@ def update_elm_package(vendor_dir, configs, packages): def exclude_downloaded_packages(vendor_dir, packages): - return [x for x in packages if not os.path.isdir(format_tar_path(vendor_dir, x))] + return [x for x in packages if not os.path.isfile(format_tar_path(vendor_dir, x))] def main(native_elm_package, configs, vendor_dir): diff --git a/tests/test_native_package_install.py b/tests/test_native_package_install.py index 19acd15..191924c 100644 --- a/tests/test_native_package_install.py +++ b/tests/test_native_package_install.py @@ -6,7 +6,7 @@ -def test_main(tmpdir, mocker): +def test_main_does_not_download_twice(tmpdir, mocker): native_elm_package = {'elm-lang/core': '1.0.0'} native_elm_package_path = tmpdir.join('elm-native-package.json') native_elm_package_path.write(json.dumps(native_elm_package)) @@ -43,5 +43,12 @@ def test_main(tmpdir, mocker): list(map(str, (elm_package_one_path, elm_package_two_path))), str(vendor)) - # mvp is to test that main runs without raising an exception; - # not asserting anything for now + with open(str(fake_native_tarball_path)) as f: + urlopen.return_value = f + + native_package_install.main( + str(native_elm_package_path), + list(map(str, (elm_package_one_path, elm_package_two_path))), + str(vendor)) + + assert urlopen.call_count == 1