code: def test_hook_is_called(tmp_dir, erepo_dir, mocker):
      subrepo_paths = [
          "subrepo1",
          "subrepo2",
          os.path.join("dir", "subrepo3"),
          os.path.join("dir", "subrepo4"),
          "subrepo5",
          os.path.join("subrepo5", "subrepo6"),
      ]
      subrepos = [erepo_dir / path for path in subrepo_paths]
      for repo in subrepos:
          make_subrepo(repo, erepo_dir.scm)
  
      for repo in [*subrepos, erepo_dir]:
          with repo.chdir():
              repo.scm_gen("foo", "foo", commit=f"git add {repo}/foo")
              repo.dvc_gen("bar", "bar", commit=f"dvc add {repo}/bar")
  
      with external_repo(
          str(erepo_dir), subrepos=True, uninitialized=True
      ) as repo:
          spy = mocker.spy(repo.dvcfs.fs, "repo_factory")
  
          list(repo.dvcfs.walk("", ignore_subrepos=False))  # drain
          assert spy.call_count == len(subrepos)
  
          paths = [
              "/" + path.replace("\\", "/") for path in subrepo_paths
          ]
          spy.assert_has_calls(
              [
                  mocker.call(
                      path,
                      fs=repo.fs,
                      scm=repo.scm,
                      repo_factory=repo.dvcfs.fs.repo_factory,
                  )
                  for path in paths
              ],
              any_order=True,
          )
  
imports: import os
  import pytest
  from dvc.repo.open_repo import _external_repo
  from dvc.testing.tmp_dir import make_subrepo
label_desc: Use image node_id 1 for calling a global function with example usage: test_hook_is_called(tmp_dir, erepo_dir, mocker) without return types