def get_resolvable_backends_for_uri( uri: str) -> Generator[Type[BaseURIBackend], None, None]: # special case the default IPFS backend to the first slot. default_ipfs = get_ipfs_backend_class() if default_ipfs in URI_BACKENDS and default_ipfs().can_resolve_uri(uri): yield default_ipfs else: for backend_class in URI_BACKENDS: if backend_class is default_ipfs: continue # type ignored because of conflict with instantiating BaseURIBackend else: try: if backend_class().can_resolve_uri(uri): # type: ignore yield backend_class except ConnectionError: logger.debug("No local IPFS node available on port 5001.", exc_info=True)
def test_get_ipfs_backend_class_with_default_backend(): backend = get_ipfs_backend_class() assert issubclass(backend, InfuraIPFSBackend)