code: def test_shared_stage_cache(tmp_dir, dvc, run_copy):
      import stat
  
      from dvc.cachemgr import CacheManager
  
      tmp_dir.gen("foo", "foo")
  
      with dvc.config.edit() as config:
          config["cache"]["shared"] = "group"
  
      dvc.cache = CacheManager(dvc)
  
      assert not os.path.exists(dvc.cache.local.path)
  
      run_copy("foo", "bar", name="copy-foo-bar")
  
      parent_cache_dir = os.path.join(dvc.stage_cache.cache_dir, "6d")
      cache_dir = os.path.join(
          parent_cache_dir,
          "6d4c6de74e7c0d60d2122e2063b4724a8c78a6799def6c7cf5093f45e7f2f3b7",
      )
      cache_file = os.path.join(
          cache_dir,
          "435e34f80692059e79ec53346cbfe29fd9ee65b62f5f06f17f5950ce5a7408ea",
      )
  
      # sanity check
      assert os.path.isdir(cache_dir)
      assert os.listdir(cache_dir) == [os.path.basename(cache_file)]
      assert os.path.isfile(cache_file)
  
      def _mode(path):
          return stat.S_IMODE(os.stat(path).st_mode)
  
      if os.name == "nt":
          dir_mode = 0o777
          file_mode = 0o666
      else:
          dir_mode = 0o2775
          file_mode = 0o664
  
      assert _mode(dvc.cache.local.path) == dir_mode
      assert _mode(dvc.stage_cache.cache_dir) == dir_mode
      assert _mode(parent_cache_dir) == dir_mode
      assert _mode(cache_dir) == dir_mode
      assert _mode(cache_file) == file_mode
  
file_path: dvc/tests/unit/stage/test_cache.py
imports: import os
  import pytest
  import dvc.output
label_desc: Use image node_id 4 for calling a global function with example usage: test_shared_stage_cache(tmp_dir, dvc, run_copy) and returns: stat