def resolve(context: DependencyContext, dependency: Dependency) -> Optional[DependencyPathSet]: """ A function to resolve dependencies in Java-land. :param context: the current dependency context in play. :param dependency: the dependency we are to resolve. :return: the appropriate dependency path set or ``None``. """ remote_resolver, classified_name, base_name = build_names(dependency) context.set_remote_resolver(remote_resolver) module_path = context.to_local_path(dependency, f'{base_name}.module') return _use_module_resolution(context, dependency, module_path) if module_path else \ _use_pom_resolution(context, dependency, classified_name, base_name)
def test_remote_info(self): path = Path('.') context = DependencyContext([], Language({}, 'lang'), Configuration({}, [], None)) resolver = RemoteResolver('the url', path) assert context._remote_resolver is None context.set_remote_resolver(resolver) assert context._remote_resolver is resolver resolver = RemoteResolver('http://server/path/', path) context.set_remote_resolver(resolver) assert context._remote_resolver is resolver
def test_handle_remote_resolution(self): name = 'file.txt' parent_url = 'http://server/path/to' url = parent_url + '/' + name parent_path = Path('path/to') file = parent_path / name return_value = Path('/resolved/path/to/' + name) context = DependencyContext([], Language({}, 'lang'), Configuration({}, [], None)) resolver = RemoteResolver(parent_url, parent_path) resolver._resolve_remotely = MagicMock(return_value=return_value) context.set_remote_resolver(resolver) rv = context._handle_remote_resolution(name) resolver._resolve_remotely.assert_called_once_with(url, file) assert rv is return_value