class_docstr: Test all storage backend
class_docstr_tok: ["Test","all","storage","backend"]
docstr: Test update heartbeat
code: def test_update_heartbeat(self, storage):
      """Test update heartbeat"""
      with OrionState(
          experiments=[base_experiment],
          trials=generate_trials(),
          storage=storage,
      ) as cfg:
          storage_name = storage
          storage = cfg.storage
  
          exp = cfg.get_experiment("default_name")
          trial1 = storage.fetch_trials_by_status(
              exp, status="reserved"
          )[0]
          trial1b = copy.deepcopy(trial1)
  
          storage.update_heartbeat(trial1)
  
          trial2 = storage.get_trial(trial1)
  
          # this check that heartbeat is the correct type and that it was updated prior to now
          assert trial1b.heartbeat is None
          assert trial1.heartbeat is None
          assert trial2.heartbeat is not None
  
          # Sleep a bit, because fast CPUs make this test fail
          time.sleep(0.1)
          assert trial2.heartbeat < datetime.datetime.utcnow()
  
          if storage_name is None:
              trial3 = storage.fetch_trials_by_status(
                  exp, status="completed"
              )[0]
              storage.update_heartbeat(trial3)
  
              assert (
                  trial3.heartbeat is None
              ), "Legacy does not update trials with a status different from reserved"
  
imports: import copy
  import datetime
  import logging
  import os
  import pickle
  import time
  import pytest
  import orion.core
  from orion.core.io.database import DuplicateKeyError
  from orion.core.io.database.pickleddb import PickledDB
  from orion.core.worker.trial import Trial
  from orion.storage.base import FailedUpdate, LockAcquisitionTimeout, LockedAlgorithmState, MissingArguments, setup_storage
  from orion.storage.legacy import Legacy
  from orion.storage.track import HAS_TRACK, REASON
  from orion.testing import OrionState, base_experiment
label_desc: Use image node_id 27 for calling the TestStorage obj's underlying member method code with example usage: obj.test_update_heartbeat(storage) without return types