From 6bb9775b7c118f2270daafb42824002e3827f7fd Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 5 Dec 2010 19:48:22 +0000 Subject: [PATCH] Added test for helpers.ensure_cached, and fixed it --- tests/testdownload.py | 11 +++++++++++ zeroinstall/helpers.py | 7 +++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/testdownload.py b/tests/testdownload.py index 598185a..88ab0b4 100755 --- a/tests/testdownload.py +++ b/tests/testdownload.py @@ -179,6 +179,17 @@ class TestDownload(BaseTest): assert sels.download_missing(iface_cache.iface_cache, None) is None + def testHelpers(self): + from zeroinstall import helpers + + with output_suppressed(): + self.child = server.handle_requests('Hello.xml', '6FCF121BE2390E0B.gpg', '/key-info/key/DE937DD411906ACF7C263B396FCF121BE2390E0B', 'HelloWorld.tgz') + sys.stdin = Reply("Y\n") + sels = helpers.ensure_cached('http://example.com:8000/Hello.xml') + path = iface_cache.iface_cache.stores.lookup_any(sels.selections['http://example.com:8000/Hello.xml'].digests) + assert os.path.exists(os.path.join(path, 'HelloWorld', 'main')) + assert sels.download_missing(iface_cache.iface_cache, None) is None + def testSelectionsWithFeed(self): from zeroinstall.injector.cli import _download_missing_selections root = qdom.parse(file("selections.xml")) diff --git a/zeroinstall/helpers.py b/zeroinstall/helpers.py index 82b91f6..c3814ba 100644 --- a/zeroinstall/helpers.py +++ b/zeroinstall/helpers.py @@ -105,7 +105,7 @@ def ensure_cached(uri, command = 'run'): available, or the console otherwise. @param uri: the required interface @type uri: str - @return: a new policy for this program, or None if the user cancelled + @return: the selected implementations, or None if the user cancelled @rtype: L{zeroinstall.injector.selections.Selections} """ from zeroinstall.injector import autopolicy, selections @@ -117,8 +117,7 @@ def ensure_cached(uri, command = 'run'): if os.environ.get('DISPLAY', None): return get_selections_gui(uri, ['--command', command]) else: - p.recalculate_with_dl() - p.start_downloading_impls() - p.handler.wait_for_downloads() + done = p.solve_and_download_impls() + p.handler.wait_for_blocker(done) return selections.Selections(p) -- 2.11.4.GIT