code: def test_staging_file(tmp_dir, dvc):
      from dvc_data.hashfile import check
      from dvc_data.hashfile.build import build
      from dvc_data.hashfile.transfer import transfer
  
      tmp_dir.gen("foo", "foo")
      fs = LocalFileSystem()
  
      local_odb = dvc.cache.local
      staging_odb, _, obj = build(
          local_odb, (tmp_dir / "foo").fs_path, fs, "md5"
      )
  
      assert not local_odb.exists(obj.hash_info.value)
      assert staging_odb.exists(obj.hash_info.value)
  
      with pytest.raises(FileNotFoundError):
          check(local_odb, obj)
      check(staging_odb, obj)
  
      transfer(staging_odb, local_odb, {obj.hash_info}, hardlink=True)
      check(local_odb, obj)
      check(staging_odb, obj)
  
      path = local_odb.oid_to_path(obj.hash_info.value)
      assert fs.exists(path)
  
file_path: dvc/tests/unit/data/db/test_local.py
imports: import errno
  import os
  import pytest
  from dvc.fs import LocalFileSystem
  from dvc_data.hashfile.db.local import LocalHashFileDB
  from dvc_data.hashfile.hash_info import HashInfo
label_desc: Use image node_id 5 for calling a global function with example usage: test_staging_file(tmp_dir, dvc) without return types