code: def test_cache_reused(erepo_dir, mocker, local_cloud):
      from dvc_objects.fs import generic
  
      erepo_dir.add_remote(config=local_cloud.config)
      with erepo_dir.chdir():
          erepo_dir.dvc_gen("file", "text", commit="add file")
      erepo_dir.dvc.push()
  
      download_spy = mocker.spy(generic, "transfer")
  
      # Use URL to prevent any fishy optimizations
      url = f"file://{erepo_dir.as_posix()}"
      with external_repo(url) as repo:
          repo.fetch()
          assert download_spy.mock.call_count == 1
  
      # Should not download second time
      erepo_dir.scm.branch("branch")
      with external_repo(url, "branch") as repo:
          repo.fetch()
          assert download_spy.mock.call_count == 1
  
file_path: dvc/tests/func/test_external_repo.py
imports: import os
  from dvc.repo.open_repo import CLONES
  from dvc.repo.open_repo import _external_repo
  from dvc.scm import Git
  from dvc.testing.tmp_dir import make_subrepo
  from dvc.utils import relpath
  from dvc.utils.fs import remove
  from dvc_data.hashfile.build import build
  from dvc_data.hashfile.transfer import transfer
label_desc: Use image node_id 3 for calling a global function with example usage: test_cache_reused(erepo_dir, mocker, local_cloud) without return types