code: def dag_test(
      args, dag: DAG | None = None, session: Session = NEW_SESSION
  ) -> None:
      """Execute one single DagRun for a given DAG and execution date."""
      run_conf = None
      if args.conf:
          try:
              run_conf = json.loads(args.conf)
          except ValueError as e:
              raise SystemExit(
                  f"Configuration {args.conf!r} is not valid JSON. Error: {e}"
              )
      execution_date = args.execution_date or timezone.utcnow()
      dag = dag or get_dag(subdir=args.subdir, dag_id=args.dag_id)
      dr: DagRun = dag.test(
          execution_date=execution_date,
          run_conf=run_conf,
          session=session,
      )
      show_dagrun = args.show_dagrun
      imgcat = args.imgcat_dagrun
      filename = args.save_dagrun
      if show_dagrun or imgcat or filename:
          tis = session.scalars(
              select(TaskInstance).where(
                  TaskInstance.dag_id == args.dag_id,
                  TaskInstance.execution_date == execution_date,
              )
          ).all()
  
          dot_graph = render_dag(dag, tis=tis)
          print()
          if filename:
              _save_dot_to_file(dot_graph, filename)
          if imgcat:
              _display_dot_via_imgcat(dot_graph)
          if show_dagrun:
              print(dot_graph.source)
  
      if dr and dr.state == DagRunState.FAILED:
          raise SystemExit("DagRun failed")
  
imports: from __future__ import annotations
  import ast
  import errno
  import json
  import logging
  import operator
  import signal
  import subprocess
  import sys
  import warnings
  from typing import TYPE_CHECKING
  from sqlalchemy import delete, select
  from airflow import settings
  from airflow.api.client import get_current_api_client
  from airflow.api_connexion.schemas.dag_schema import dag_schema
  from airflow.cli.simple_table import AirflowConsole
  from airflow.configuration import conf
  from airflow.exceptions import AirflowException, RemovedInAirflow3Warning
  from airflow.jobs.job import Job
  from airflow.models import DagBag, DagModel, DagRun, TaskInstance
  from airflow.models.dag import DAG
  from airflow.models.serialized_dag import SerializedDagModel
  from airflow.utils import cli, timezone
  from airflow.utils.cli import get_dag, get_dags, process_subdir, sigint_handler, suppress_logs_and_warning
  from airflow.utils.dot_renderer import render_dag, render_dag_dependencies
  from airflow.utils.providers_configuration_loader import providers_configuration_loaded
  from airflow.utils.session import NEW_SESSION, create_session, provide_session
  from airflow.utils.state import DagRunState
label_desc: Use image node_id 21 for calling a global function with example usage: dag_test(args, dag, session) without return types