code: def test_delete_dataset_jobs(
      queue_mongo_resource: QueueMongoResource,
  ) -> None:
      """
      Test that delete_dataset_jobs deletes all jobs for a dataset
  
      -> deletes at several levels (dataset, config, split)
      -> deletes started and waiting jobs
      -> remove locks
      -> does not cancel, and does not remove locks, for other datasets
      """
      dataset = "dataset"
      other_dataset = "other_dataset"
      job_type_1 = "job_type_1"
      job_type_2 = "job_type_2"
      job_type_3 = "job_type_3"
      job_type_4 = "job_type_4"
      revision = "dataset_git_revision"
      difficulty = 50
      queue = Queue()
      queue.add_job(
          job_type=job_type_1,
          dataset=dataset,
          revision=revision,
          config=None,
          split=None,
          difficulty=difficulty,
      )
      queue.add_job(
          job_type=job_type_1,
          dataset=other_dataset,
          revision=revision,
          config=None,
          split=None,
          difficulty=difficulty,
      )
      queue.add_job(
          job_type=job_type_2,
          dataset=dataset,
          revision=revision,
          config=None,
          split=None,
          difficulty=difficulty,
      )
      queue.add_job(
          job_type=job_type_3,
          dataset=dataset,
          revision=revision,
          config="config",
          split=None,
          difficulty=difficulty,
      )
      queue.add_job(
          job_type=job_type_4,
          dataset=dataset,
          revision=revision,
          config="config",
          split="split",
          difficulty=difficulty,
      )
      queue.add_job(
          job_type=job_type_2,
          dataset=other_dataset,
          revision=revision,
          config=None,
          split=None,
          difficulty=difficulty,
      )
      started_job_info_1 = queue.start_job()
      assert started_job_info_1["params"]["dataset"] == dataset
      assert started_job_info_1["type"] == job_type_1
      started_job_info_2 = queue.start_job()
      assert started_job_info_2["params"]["dataset"] == other_dataset
      assert started_job_info_2["type"] == job_type_1
  
      assert queue.delete_dataset_jobs(dataset=dataset) == 4
  
      assert JobDocument.objects().count() == 2
      assert JobDocument.objects(dataset=dataset).count() == 0
      assert JobDocument.objects(dataset=other_dataset).count() == 2
      assert (
          JobDocument.objects(
              dataset=other_dataset, status=Status.STARTED
          ).count()
          == 1
      )
      assert (
          JobDocument.objects(
              dataset=other_dataset, status=Status.WAITING
          ).count()
          == 1
      )
  
      assert len(Lock.objects()) == 2
      assert (
          len(
              Lock.objects(
                  key=f"{job_type_1},{dataset},{revision}", owner=None
              )
          )
          == 1
      )
      assert (
          len(
              Lock.objects(
                  key=f"{job_type_1},{dataset},{revision}",
                  owner__ne=None,
              )
          )
          == 0
      )
  
imports: import json
  import os
  import random
  import time
  from datetime import datetime, timedelta
  from multiprocessing import Pool
  from pathlib import Path
  from typing import Optional
  from unittest.mock import patch
  import pytest
  import pytz
  from libcommon.constants import QUEUE_TTL_SECONDS
  from libcommon.queue import EmptyQueueError, JobDocument, JobTotalMetricDocument, Lock, Queue, lock
  from libcommon.resources import QueueMongoResource
  from libcommon.utils import Priority, Status, get_datetime
  from .utils import assert_metric
label_desc: Use image node_id 23 for calling a global function with example usage: test_delete_dataset_jobs(queue_mongo_resource) without return types