def test_url_extra_fetch(tmpdir, mock_archive): """Ensure a fetch after downloading is effectively a no-op.""" testpath = str(tmpdir) fetcher = URLFetchStrategy(mock_archive.url) with Stage(fetcher, path=testpath) as stage: assert fetcher.archive_file is None stage.fetch() assert fetcher.archive_file is not None fetcher.fetch()
def test_urlfetchstrategy_bad_url(tmpdir): """Ensure fetch with bad URL fails as expected.""" testpath = str(tmpdir) with pytest.raises(FailedDownloadError): fetcher = URLFetchStrategy(url='file:///does-not-exist') assert fetcher is not None with Stage(fetcher, path=testpath) as stage: assert stage is not None assert fetcher.archive_file is None fetcher.fetch()
def mock_fetch(mock_archive, monkeypatch): """Fake the URL for a package so it downloads from a file.""" mock_fetcher = FetchStrategyComposite() mock_fetcher.append(URLFetchStrategy(mock_archive.url)) monkeypatch.setattr( spack.package.PackageBase, 'fetcher', mock_fetcher)
def mock_fetch(mock_archive): """Fake the URL for a package so it downloads from a file.""" fetcher = FetchStrategyComposite() fetcher.append(URLFetchStrategy(mock_archive.url)) @property def fake_fn(self): return fetcher orig_fn = PackageBase.fetcher PackageBase.fetcher = fake_fn yield PackageBase.fetcher = orig_fn
def test_install_and_uninstall(self): # Get a basic concrete spec for the trivial install package. spec = Spec('trivial_install_test_package') spec.concretize() self.assertTrue(spec.concrete) # Get the package pkg = spack.db.get(spec) # Fake the URL for the package so it downloads from a file. pkg.fetcher = URLFetchStrategy(self.repo.url) try: pkg.do_install() pkg.do_uninstall() except Exception, e: pkg.remove_prefix() raise
def fake_fetchify(url, pkg): """Fake the URL for a package so it downloads from a file.""" fetcher = FetchStrategyComposite() fetcher.append(URLFetchStrategy(url)) pkg.fetcher = fetcher
def test_urlfetchstrategy_sans_url(): """Ensure constructor with no URL fails.""" with pytest.raises(ValueError): with URLFetchStrategy(None): pass