def test_editable_fetch_find(galaxy_context, mocker, tmpdir): name = 'mazer_fetch_test_editable' namespace_override = 'some_editable_namespace' tmp_path = tmpdir.mkdir(name) more_reqs = requirements.from_dependencies_dict( {tmp_path.strpath: '*'}, namespace_override=namespace_override, editable=True) import pprint log.debug('more_reqs: %s', pprint.pformat(more_reqs)) req_spec = more_reqs[0].requirement_spec fetcher = editable.EditableFetch(galaxy_context, req_spec) log.debug(fetcher) res = fetcher.find() log.debug('res: %s', res) assert isinstance(res, dict) assert res['content']['galaxy_namespace'] == namespace_override assert res['content']['repo_name'] == name assert res['custom']['real_path'] == tmp_path.strpath
def get(galaxy_context, repository_spec): """determine how to download a repo, builds a fetch instance, and returns the instance""" fetcher = None # FIXME: note that ignore_certs for the galaxy # server(galaxy_context.server['ignore_certs']) # does not really imply that the repo archive download should ignore certs as well # (galaxy api server vs cdn) but for now, we use the value for both if repository_spec.fetch_method == FetchMethods.EDITABLE: fetcher = editable.EditableFetch(repository_spec=repository_spec, galaxy_context=galaxy_context) elif repository_spec.fetch_method == FetchMethods.SCM_URL: fetcher = scm_url.ScmUrlFetch(repository_spec=repository_spec) elif repository_spec.fetch_method == FetchMethods.LOCAL_FILE: # the file is a tar, so open it that way and extract it # to the specified (or default) content directory fetcher = local_file.LocalFileFetch(repository_spec) elif repository_spec.fetch_method == FetchMethods.REMOTE_URL: fetcher = remote_url.RemoteUrlFetch( repository_spec=repository_spec, validate_certs=not galaxy_context.server['ignore_certs']) elif repository_spec.fetch_method == FetchMethods.GALAXY_URL: fetcher = galaxy_url.GalaxyUrlFetch(repository_spec=repository_spec, galaxy_context=galaxy_context) else: raise exceptions.GalaxyError( 'No approriate content fetcher found for %s %s', repository_spec.scm, repository_spec.src) log.debug('Using fetcher: %s for repository_spec: %r', fetcher, repository_spec) return fetcher
def test_editable_fetch_fetch(galaxy_context, mocker, tmpdir): name = 'mazer_fetch_test_editable' namespace_override = 'some_editable_namespace' tmp_working_path = tmpdir.mkdir('some_working_tree') dest_tmp_path = tmp_working_path.mkdir('some_checkout') req_spec = RequirementSpec(namespace=namespace_override, name=name, fetch_method='EDITABLE', src=dest_tmp_path, version_spec='*') # RepositorySpec(namespace='some_editable_namespace', name='some_checkout', # version=None, fetch_method='EDITABLE', scm=None, # spec_string='/tmp/pytest-of-adrian/pytest-79/test_editable_fetch_fetch0/some_checkout', # src='/tmp/pytest-of-adrian/pytest-79/test_editable_fetch_fetch0/some_checkout') log.debug('req_spec: %r', req_spec) fetcher = editable.EditableFetch(galaxy_context, req_spec) find_results = { 'custom': { 'real_path': dest_tmp_path.strpath }, 'content': [] } res = fetcher.fetch(find_results=find_results) log.debug('res: %s', res) expected_link_name = os.path.join(galaxy_context.collections_path, COLLECTIONS_PYTHON_NAMESPACE, namespace_override, name) log.debug('expected_link_name: %s', expected_link_name) assert isinstance(res, dict) assert res['archive_path'] == dest_tmp_path.strpath assert res['custom']['symlinked_repo_root'] == expected_link_name
def test_editable_fetch_find(galaxy_context, mocker, tmpdir): name = 'mazer_fetch_test_editable' namespace_override = 'some_editable_namespace' tmp_path = tmpdir.mkdir(name) more_reqs = requirements.from_requirement_spec_strings( [tmp_path.strpath], namespace_override=namespace_override, editable=True) repo_spec = more_reqs[0].requirement_spec fetcher = editable.EditableFetch(galaxy_context, repo_spec) log.debug(fetcher) res = fetcher.find() log.debug('res: %s', res) assert isinstance(res, dict) assert res['content']['galaxy_namespace'] == namespace_override assert res['content']['repo_name'] == name assert res['custom']['real_path'] == tmp_path.strpath