code: def test_dump_stage(tmp_dir, dvc):
      stage = PipelineStage(
          dvc, cmd="command", name="stage_name", path="dvc.yaml"
      )
      dvcfile = load_file(dvc, "dvc.yaml")
  
      dvcfile.dump(stage, update_lock=False, update_pipeline=False)
      assert not (tmp_dir / PROJECT_FILE).exists()
      assert not (tmp_dir / LOCK_FILE).exists()
  
      dvcfile.dump(stage, update_pipeline=False)
      assert not (tmp_dir / PROJECT_FILE).exists()
      assert (tmp_dir / LOCK_FILE).exists()
      assert dvcfile._lockfile.load()
  
      remove(tmp_dir / LOCK_FILE)
  
      dvcfile.dump(stage)
      assert (tmp_dir / PROJECT_FILE).exists()
      assert (tmp_dir / LOCK_FILE).exists()
      assert list(dvcfile.stages.values()) == [stage]
  
file_path: dvc/tests/unit/test_dvcfile.py
imports: import pytest
  from dvc.dvcfile import LOCK_FILE, PROJECT_FILE, FileIsGitIgnored, ProjectFile, SingleStageFile, load_file
  from dvc.stage import PipelineStage
  from dvc.stage.exceptions import StageFileDoesNotExistError, StageFileIsNotDvcFileError
  from dvc.utils.fs import remove
  from dvc.utils.serialize import EncodingError
  from dvc.utils.strictyaml import YAMLValidationError
label_desc: Use image node_id 6 for calling a global function with example usage: test_dump_stage(tmp_dir, dvc) without return types