code: def test_heartbeat_failed(self):
      when = timezone.utcnow() - datetime.timedelta(seconds=60)
      mock_session = Mock(name="MockSession")
      mock_session.commit.side_effect = OperationalError(
          "Force fail", {}, None
      )
      job = Job(heartrate=10, state=State.RUNNING)
      job.latest_heartbeat = when
  
      job.heartbeat(
          heartbeat_callback=lambda: None, session=mock_session
      )
  
      assert (
          job.latest_heartbeat == when
      ), "attribute not updated when heartbeat fails"
  
imports: from __future__ import annotations
  import datetime
  import sys
  from unittest.mock import ANY, Mock, patch
  import pytest
  from sqlalchemy.exc import OperationalError
  from airflow.executors.sequential_executor import SequentialExecutor
  from airflow.jobs.job import Job, most_recent_job, perform_heartbeat, run_job
  from airflow.listeners.listener import get_listener_manager
  from airflow.utils import timezone
  from airflow.utils.session import create_session
  from airflow.utils.state import State
  from tests.listeners import lifecycle_listener
  from tests.test_utils.config import conf_vars
  from tests.utils.test_helpers import MockJobRunner, SchedulerJobRunner, TriggererJobRunner
label_desc: Use image node_id 12 for calling the TestJob obj's underlying member method code with example usage: obj.test_heartbeat_failed() without return types