From b1c6d2e4069ad466e8982236f4ca8611b24040cb Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Tue, 10 Apr 2012 12:37:29 +0100 Subject: Fix unit test failures: mark out-of-coverage, and use wrapper to allow tests The self._exists method needs to be used instead of raw os.path.exists, so that unit tests can override it easily. Also, a tiny clarification so that the caller of _clone_with_bundle decides whether it's OK to try to download a bundle. --- morphlib/localrepocache.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'morphlib/localrepocache.py') diff --git a/morphlib/localrepocache.py b/morphlib/localrepocache.py index 6587a0e5..9aef13e4 100644 --- a/morphlib/localrepocache.py +++ b/morphlib/localrepocache.py @@ -68,7 +68,7 @@ class LocalRepoCache(object): self._cachedir = cachedir self._baseurls = baseurls if bundle_base_url and not bundle_base_url.endswith('/'): - bundle_base_url += '/' + bundle_base_url += '/' # pragma: no cover self._bundle_base_url = bundle_base_url self._ex = morphlib.execute.Execute(cachedir, logging.debug) @@ -141,7 +141,7 @@ class LocalRepoCache(object): def _base_iterate(self, reponame): for baseurl in self._baseurls: if not baseurl.endswith('/'): - baseurl += '/' + baseurl += '/' # pragma: no cover repourl = urlparse.urljoin(baseurl, reponame) path = self._cache_name(repourl) yield repourl, path @@ -154,15 +154,13 @@ class LocalRepoCache(object): return False def _clone_with_bundle(self, repourl, path): - if not self._bundle_base_url: - return False escaped = self._escape(repourl) bundle_url = urlparse.urljoin(self._bundle_base_url, escaped) bundle_path = path + '.bundle' success = self._fetch(bundle_url, bundle_path) if success: self._git(['clone', bundle_path, path]) - if os.path.exists(bundle_path): + if self._exists(bundle_path): self._remove(bundle_path) return success @@ -177,7 +175,8 @@ class LocalRepoCache(object): if self._exists(path): break - if self._clone_with_bundle(repourl, path): + if (self._bundle_base_url and + self._clone_with_bundle(repourl, path)): break try: -- cgit v1.2.1