code: def _postclonetest_prepare(lcl, storepath, storepath2, link):
      from datalad.customremotes.ria_utils import (
          create_ds_in_store,
          create_store,
          get_layout_locations,
      )
      from datalad.distributed.ora_remote import LocalIO
  
      create_tree(
          lcl,
          tree={
              "ds": {
                  "test.txt": "some",
                  "subdir": {
                      "subds": {"testsub.txt": "somemore"},
                      "subgit": {"testgit.txt": "even more"},
                  },
              },
          },
      )
  
      lcl = Path(lcl)
      storepath = Path(storepath)
      storepath2 = Path(storepath2)
      link = Path(link)
      link.symlink_to(storepath)
  
      # create a local dataset with a subdataset
      subds = Dataset(lcl / "ds" / "subdir" / "subds").create(
          force=True
      )
      subds.save()
      # add a plain git dataset as well
      subgit = Dataset(lcl / "ds" / "subdir" / "subgit").create(
          force=True, annex=False
      )
      subgit.save()
      ds = Dataset(lcl / "ds").create(force=True)
      ds.save(version_tag="original")
      assert_repo_status(ds.path)
  
      io = LocalIO()
  
      # Have a second store with valid ORA remote. This should not interfere with
      # reconfiguration of the first one, when that second store is not the one we
      # clone from. However, don't push data into it for easier get-based testing
      # later on.
      # Doing this first, so datasets in "first"/primary store know about this.
      create_store(io, storepath2, "1")
      url2 = "ria+{}".format(get_local_file_url(str(storepath2)))
      for d in (ds, subds, subgit):
          create_ds_in_store(io, storepath2, d.id, "2", "1")
          d.create_sibling_ria(url2, "anotherstore", new_store_ok=True)
          d.push(".", to="anotherstore", data="nothing")
          store2_loc, _, _ = get_layout_locations(1, storepath2, d.id)
          Runner(cwd=str(store2_loc)).run(["git", "update-server-info"])
  
      # Now the store to clone from:
      create_store(io, storepath, "1")
  
      # URL to use for upload. Point is, that this should be invalid for the clone
      # so that autoenable would fail. Therefore let it be based on a to be
      # deleted symlink
      upl_url = "ria+{}".format(get_local_file_url(str(link)))
  
      for d in (ds, subds, subgit):
          # TODO: create-sibling-ria required for config! => adapt to RF'd
          #       creation (missed on rebase?)
          create_ds_in_store(io, storepath, d.id, "2", "1")
          d.create_sibling_ria(upl_url, "store", new_store_ok=True)
  
          if d is not subgit:
              # Now, simulate the problem by reconfiguring the special remote to
              # not be autoenabled.
              # Note, however, that the actual intention is a URL, that isn't
              # valid from the point of view of the clone (doesn't resolve, no
              # credentials, etc.) and therefore autoenabling on git-annex-init
              # when datalad-cloning would fail to succeed.
              Runner(cwd=d.path).run(
                  [
                      "git",
                      "annex",
                      "enableremote",
                      "store-storage",
                      "autoenable=false",
                  ]
              )
          d.push(".", to="store")
          store_loc, _, _ = get_layout_locations(1, storepath, d.id)
          Runner(cwd=str(store_loc)).run(["git", "update-server-info"])
  
      link.unlink()
      # We should now have a store with datasets that have an autoenabled ORA
      # remote relying on an inaccessible URL.
      # datalad-clone is supposed to reconfigure based on the URL we cloned from.
      # Test this feature for cloning via HTTP, SSH and FILE URLs.
  
      return ds.id
  
imports: import logging
  import os.path
  import stat
  from unittest.mock import patch
  import pytest
  from datalad import consts
  from datalad.api import clone, create, remove
  from datalad.cmd import GitWitlessRunner
  from datalad.cmd import WitlessRunner
  from datalad.config import ConfigManager
  from datalad.core.distributed.clone_utils import _get_installationpath_from_url, decode_source_spec
  from datalad.distribution.dataset import Dataset
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.exceptions import IncompleteResultsError
  from datalad.support.external_versions import external_versions
  from datalad.support.gitrepo import GitRepo
  from datalad.support.network import get_local_file_url
  from datalad.tests.utils_pytest import DEFAULT_BRANCH, DEFAULT_REMOTE, SkipTest, assert_false, assert_in, assert_in_results, assert_message, assert_not_in, assert_not_is_instance, assert_raises, assert_repo_status, assert_result_count, assert_result_values_equal, assert_status, create_tree, eq_, get_datasets_topdir, has_symlink_capability, integration, known_failure, known_failure_githubci_win, known_failure_osx, known_failure_windows, neq_, nok_, ok_, ok_file_has_content, ok_startswith, on_github, on_osx, on_travis, patch_config, serve_path_via_http, set_date, skip_if, skip_if_adjusted_branch, skip_if_no_network, skip_if_on_windows, skip_ssh, slow, swallow_logs, with_sameas_remote, with_tempfile, with_tree, xfail_buggy_annex_info
  from datalad.utils import Path, chpwd, get_home_envvars, on_windows, rmtree
label_desc: Use image node_id 30 for calling a global function with example usage: _postclonetest_prepare(lcl, storepath, storepath2, link) and returns: ds