code: def test_tinydb_observer_started_event_saves_given_sources(
      tinydb_obs, sample_run
  ):
      filename = "setup.py"
      md5 = get_digest(filename)
  
      sample_run["ex_info"]["sources"] = [[filename, md5]]
      _id = tinydb_obs.started_event(**sample_run)
  
      assert _id is not None
      assert len(tinydb_obs.runs) == 1
      db_run = tinydb_obs.runs.get(doc_id=1)
  
      # Check all but the experiment section
      db_run_copy = db_run.copy()
      del db_run_copy["experiment"]
      assert db_run_copy == {
          "_id": _id,
          "format": tinydb_obs.VERSION,
          "command": sample_run["command"],
          "host": sample_run["host_info"],
          "start_time": sample_run["start_time"],
          "heartbeat": None,
          "info": {},
          "captured_out": "",
          "artifacts": [],
          "config": sample_run["config"],
          "meta": sample_run["meta_info"],
          "status": "RUNNING",
          "resources": [],
      }
  
      assert len(db_run["experiment"]["sources"]) == 1
      assert len(db_run["experiment"]["sources"][0]) == 3
      assert db_run["experiment"]["sources"][0][:2] == [filename, md5]
      assert isinstance(
          db_run["experiment"]["sources"][0][2], io.BufferedReader
      )
  
      # Check that duplicate source files are still listed in ex_info
      tinydb_obs.db_run_id = None
      tinydb_obs.started_event(**sample_run)
      assert len(tinydb_obs.runs) == 2
      db_run2 = tinydb_obs.runs.get(doc_id=2)
  
      assert (
          db_run["experiment"]["sources"][0][:2]
          == db_run2["experiment"]["sources"][0][:2]
      )
  
imports: from __future__ import division, print_function, unicode_literals, absolute_import
  import os
  import datetime
  import tempfile
  import io
  import pytest
  from tinydb import TinyDB
  from hashfs import HashFS
  from sacred.dependencies import get_digest
  from sacred.observers.tinydb_hashfs import TinyDbObserver, tiny_db_option
  from sacred.observers.tinydb_hashfs.bases import BufferedReaderWrapper
  from sacred import optional
  from sacred.experiment import Experiment
label_desc: Use image node_id 6 for calling a global function with example usage: test_tinydb_observer_started_event_saves_given_sources(tinydb_obs, sample_run) without return types