def test_fetch_missing_cache(tmpdir): """Ensure raise a missing cache file.""" testpath = str(tmpdir) fetcher = CacheURLFetchStrategy(url='file:///not-a-real-cache-file') with Stage(fetcher, path=testpath): with pytest.raises(NoCacheError, match=r'No cache'): fetcher.fetch()
def test_fetch_missing_cache(tmpdir, use_curl): """Ensure raise a missing cache file.""" testpath = str(tmpdir) with spack.config.override('config:use_curl', use_curl): fetcher = CacheURLFetchStrategy(url='file:///not-a-real-cache-file') with Stage(fetcher, path=testpath): with pytest.raises(NoCacheError, match=r'No cache'): fetcher.fetch()
def test_fetch_missing_cache(tmpdir, _fetch_method): """Ensure raise a missing cache file.""" testpath = str(tmpdir) with spack.config.override('config:url_fetch_method', _fetch_method): abs_pref = '' if is_windows else '/' url = 'file://' + abs_pref + 'not-a-real-cache-file' fetcher = CacheURLFetchStrategy(url=url) with Stage(fetcher, path=testpath): with pytest.raises(NoCacheError, match=r'No cache'): fetcher.fetch()
def test_fetch(tmpdir): """Ensure a fetch after expanding is effectively a no-op.""" testpath = str(tmpdir) cache = os.path.join(testpath, 'cache.tar.gz') touch(cache) url = 'file:///{0}'.format(cache) fetcher = CacheURLFetchStrategy(url=url) with Stage(fetcher, path=testpath) as stage: source_path = stage.source_path mkdirp(source_path) fetcher.fetch()
def test_fetch(tmpdir, _fetch_method): """Ensure a fetch after expanding is effectively a no-op.""" testpath = str(tmpdir) cache = os.path.join(testpath, 'cache.tar.gz') touch(cache) if is_windows: url_stub = '{0}' else: url_stub = '/{0}' url = 'file://' + url_stub.format(cache) with spack.config.override('config:url_fetch_method', _fetch_method): fetcher = CacheURLFetchStrategy(url=url) with Stage(fetcher, path=testpath) as stage: source_path = stage.source_path mkdirp(source_path) fetcher.fetch()