code: def hook_conn(request):
      """
      Patch ``BaseHook.get_connection()`` by mock value.
  
      This fixture optionally parametrized, if ``param`` not set or empty it just mock method.
      If param is dictionary or :class:`~airflow.models.Connection` than return it,
      If param is exception than add side effect.
      Otherwise, it raises an error
      """
      try:
          conn = request.param
      except AttributeError:
          conn = None
  
      with mock.patch(
          "airflow.hooks.base.BaseHook.get_connection"
      ) as m:
          if not conn:
              pass  # Don't do anything if param not specified or empty
          elif isinstance(conn, dict):
              m.return_value = Connection(**conn)
          elif not isinstance(conn, Connection):
              m.return_value = conn
          elif isinstance(conn, Exception):
              m.side_effect = conn
          else:
              raise TypeError(
                  f"{request.node.name!r}: expected dict, Connection object or Exception, "
                  f"but got {type(conn).__name__}"
              )
  
          yield m
  
imports: from __future__ import annotations
  from unittest import mock
  import pytest
  from airflow.models import Connection
label_desc: Use image node_id 1 for calling a global function with example usage: hook_conn(request) without return types