code: def test_delete_jobs(
      existing_jobs: list[JobSpec],
      expected_create_job: bool,
      expected_delete_jobs: bool,
      expected_jobs_after_backfill: list[JobSpec],
  ) -> None:
      processing_graph = PROCESSING_GRAPH_ONE_STEP
  
      queue = Queue()
      for job_spec in existing_jobs:
          (priority, status, created_at) = job_spec
          job = queue.add_job(
              job_type=STEP_DA,
              dataset="dataset",
              revision="revision",
              priority=priority,
              difficulty=DIFFICULTY,
          )
          if created_at is not None:
              job.created_at = created_at
              job.save()
          if status is Status.STARTED:
              job.status = Status.STARTED
              job.started_at = datetime.now()
              job.save()
  
      dataset_backfill_plan = get_dataset_backfill_plan(
          processing_graph=processing_graph
      )
      expected_in_process = [ARTIFACT_DA] if existing_jobs else []
      if expected_create_job:
          if expected_delete_jobs:
              raise NotImplementedError()
          expected_tasks = ["CreateJobs,1"]
      elif expected_delete_jobs:
          expected_tasks = [f"DeleteJobs,{len(existing_jobs) - 1}"]
      else:
          expected_tasks = []
  
      assert_dataset_backfill_plan(
          dataset_backfill_plan=dataset_backfill_plan,
          config_names=[],
          split_names_in_first_config=[],
          cache_status={
              "cache_has_different_git_revision": [],
              "cache_is_outdated_by_parent": [],
              "cache_is_empty": [ARTIFACT_DA],
              "cache_is_error_to_retry": [],
              "cache_is_job_runner_obsolete": [],
              "up_to_date": [],
          },
          queue_status={"in_process": expected_in_process},
          tasks=expected_tasks,
      )
  
      dataset_backfill_plan.run()
  
      job_dicts = queue.get_dataset_pending_jobs_for_type(
          dataset=DATASET_NAME, job_type=STEP_DA
      )
      assert len(job_dicts) == len(expected_jobs_after_backfill)
      for job_dict, expected_job_spec in zip(
          job_dicts, expected_jobs_after_backfill
      ):
          (priority, status, created_at) = expected_job_spec
          assert job_dict["priority"] == priority.value
          assert job_dict["status"] == status.value
          if created_at is not None:
              assert job_dict["created_at"] == created_at
  
imports: from datetime import datetime
  from typing import Optional
  from unittest.mock import patch
  import pytest
  from libcommon.constants import ERROR_CODES_TO_RETRY
  from libcommon.processing_graph import ProcessingGraph
  from libcommon.queue import Queue
  from libcommon.resources import CacheMongoResource, QueueMongoResource
  from libcommon.utils import Priority, Status
  from .utils import ARTIFACT_CA_1, ARTIFACT_CA_2, ARTIFACT_CB_1, ARTIFACT_CB_2, ARTIFACT_DA, ARTIFACT_DA_OTHER_REVISION, ARTIFACT_DB, ARTIFACT_DC, ARTIFACT_DD, ARTIFACT_DE, ARTIFACT_DF, ARTIFACT_DG, ARTIFACT_DH, ARTIFACT_DI, ARTIFACT_SA_1_1, ARTIFACT_SA_1_2, ARTIFACT_SA_2_1, ARTIFACT_SA_2_2, CONFIG_NAME_1, CONFIG_NAMES, DATASET_NAME, DIFFICULTY, OTHER_REVISION_NAME, PROCESSING_GRAPH_FAN_IN_OUT, PROCESSING_GRAPH_GENEALOGY, PROCESSING_GRAPH_ONE_STEP, PROCESSING_GRAPH_PARALLEL, REVISION_NAME, SPLIT_NAME_1, SPLIT_NAMES, STEP_CA, STEP_DA, STEP_DD, STEP_DI, STEP_SA, assert_dataset_backfill_plan, compute_all, get_dataset_backfill_plan, process_all_jobs, process_next_job, put_cache
label_desc: Use image node_id 16 for calling a global function with example usage: test_delete_jobs(existing_jobs, expected_create_job, expected_delete_jobs, expected_jobs_after_backfill) without return types