code: def test_query(
      return_last,
      split_statements,
      sql,
      cursor_calls,
      cursor_descriptions,
      cursor_results,
      hook_descriptions,
      hook_results,
  ):
      modified_descriptions = [
          get_cursor_descriptions(cursor_description)
          for cursor_description in cursor_descriptions
      ]
      dbapi_hook = DBApiHookForTests()
      dbapi_hook.get_conn.return_value.cursor.return_value.rowcount = 2
      dbapi_hook.get_conn.return_value.cursor.return_value._description_index = (
          0
      )
  
      def mock_execute(*args, **kwargs):
          # the run method accesses description property directly, and we need to modify it after
          # every execute, to make sure that different descriptions are returned. I could not find easier
          # method with mocking
          dbapi_hook.get_conn.return_value.cursor.return_value.description = modified_descriptions[
              dbapi_hook.get_conn.return_value.cursor.return_value._description_index
          ]
          dbapi_hook.get_conn.return_value.cursor.return_value._description_index += (
              1
          )
  
      dbapi_hook.get_conn.return_value.cursor.return_value.execute = (
          mock_execute
      )
      dbapi_hook.get_conn.return_value.cursor.return_value.fetchall.side_effect = (
          cursor_results
      )
      results = dbapi_hook.run(
          sql=sql,
          handler=fetch_all_handler,
          return_last=return_last,
          split_statements=split_statements,
      )
  
      assert dbapi_hook.descriptions == hook_descriptions
      assert dbapi_hook.last_description == hook_descriptions[-1]
      assert results == hook_results
  
      dbapi_hook.get_conn.return_value.cursor.return_value.close.assert_called()
  
file_path: airflow/tests/providers/common/sql/hooks/test_sql.py
imports: from __future__ import annotations
  from unittest.mock import MagicMock
  import pytest
  from airflow.models import Connection
  from airflow.providers.common.sql.hooks.sql import DbApiHook, fetch_all_handler
  from airflow.utils.session import provide_session
label_desc: Use image node_id 3 for calling a global function with example usage: test_query(return_last, split_statements, sql, cursor_calls, cursor_descriptions, cursor_results, hook_descriptions, hook_results) without return types