code: def test_chart_digest(
      chart_overrides: dict[str, Any] | None,
      execute_as: list[ExecutorType],
      has_current_user: bool,
      use_custom_digest: bool,
      expected_result: str | Exception,
  ) -> None:
      from superset import app
      from superset.models.slice import Slice
      from superset.thumbnails.digest import get_chart_digest
  
      kwargs = {
          **_DEFAULT_CHART_KWARGS,
          **(chart_overrides or {}),
      }
      chart = Slice(**kwargs)
      user: User | None = None
      if has_current_user:
          user = User(id=1, username="1")
      func = CUSTOM_CHART_FUNC if use_custom_digest else None
  
      with patch.dict(
          app.config,
          {
              "THUMBNAIL_EXECUTE_AS": execute_as,
              "THUMBNAIL_CHART_DIGEST_FUNC": func,
          },
      ), override_user(user):
          cm = (
              pytest.raises(type(expected_result))
              if isinstance(expected_result, Exception)
              else nullcontext()
          )
          with cm:
              assert get_chart_digest(chart=chart) == expected_result
  
file_path: superset/tests/unit_tests/thumbnails/test_digest.py
imports: from __future__ import annotations
  from contextlib import nullcontext
  from typing import Any, TYPE_CHECKING
  from unittest.mock import patch
  import pytest
  from flask_appbuilder.security.sqla.models import User
  from superset.tasks.exceptions import ExecutorNotFoundError
  from superset.tasks.types import ExecutorType
  from superset.utils.core import override_user
label_desc: Use image node_id 4 for calling a global function with example usage: test_chart_digest(chart_overrides, execute_as, has_current_user, use_custom_digest, expected_result) without return types