class_docstr: Unit tests for DagCode.
class_docstr_tok: ["Unit","tests","for","DagCode","."]
docstr: Dag code detects duplicate key.
docstr_tok: ["Dag","code","detects","duplicate","key","."]
code: def test_detecting_duplicate_key(self, mock_hash):
      """Dag code detects duplicate key."""
      mock_hash.return_value = 0
  
      with pytest.raises(AirflowException):
          self._write_two_example_dags()
  
imports: from __future__ import annotations
  from datetime import timedelta
  from unittest.mock import patch
  import pytest
  import airflow.example_dags
  from airflow.exceptions import AirflowException
  from airflow.models import DagBag
  from airflow.models.dagcode import DagCode
  from airflow.utils.file import open_maybe_zipped
  from airflow.utils.session import create_session
  from tests.test_utils.db import clear_db_dag_code
label_desc: Use image node_id 8 for calling the TestDagCode obj's underlying member method code with example usage: obj.test_detecting_duplicate_key(mock_hash) without return types