code: def test_register_new_trials():
      """Test new trials are properly registered"""
      with create_producer() as (producer, storage):
          trials_in_db_before = len(storage._fetch_trials({}))
          new_trials_in_db_before = len(
              storage._fetch_trials({"status": "new"})
          )
  
          algorithm = producer.experiment.algorithm
          possible_values = [(1,)]
          algorithm.unwrapped.possible_values = possible_values
  
          assert producer.produce(1) == 1
  
          # Algorithm was ordered to suggest some trials
          num_new_points = algorithm.unwrapped._num
          assert num_new_points == 1  # pool size
  
          assert (
              algorithm.unwrapped._suggested[0].params["x"]
              == possible_values[0][0]
          )
  
          # `num_new_points` new trials were registered at database
          assert (
              len(storage._fetch_trials({})) == trials_in_db_before + 1
          )
          assert (
              len(storage._fetch_trials({"status": "new"}))
              == new_trials_in_db_before + 1
          )
          new_trials = list(storage._fetch_trials({"status": "new"}))
          assert new_trials[0].experiment == producer.experiment.id
          assert new_trials[0].start_time is None
          assert new_trials[0].end_time is None
          assert new_trials[0].results == []
          assert new_trials[0].params == {
              "x": 1,
          }
  
file_path: orion/tests/unittests/core/worker/test_producer.py
imports: import contextlib
  import copy
  import threading
  import time
  import pytest
  from orion.core.io.experiment_builder import build
  from orion.core.worker.producer import Producer
  from orion.testing import OrionState, generate_trials
label_desc: Use image node_id 5 for calling a global function with example usage: test_register_new_trials() without return types