code: def test_duplicate_only_once(storage, monkeypatch):
      """Test that trials may not be duplicated twice"""
      with disable_duplication(monkeypatch):
          build_evc_tree(list(range(5)))
  
      for exp in [
          "root",
          "parent",
          "experiment",
          "child",
          "grand-child",
      ]:
          assert len(
              get_experiment(name=exp).fetch_trials(with_evc_tree=False)
          ) == len(Trial.allowed_stati)
  
      experiment = build_experiment(name="experiment")
      experiment._experiment.duplicate_pending_trials()
  
      for exp in ["root", "parent", "child", "grand-child"]:
          assert len(
              get_experiment(name=exp).fetch_trials(with_evc_tree=False)
          ) == len(Trial.allowed_stati)
  
      assert (
          len(experiment.fetch_trials(with_evc_tree=False))
          == len(Trial.allowed_stati) + N_PENDING * 4
      )
  
      experiment._experiment.duplicate_pending_trials()
  
      for exp in ["root", "parent", "child", "grand-child"]:
          assert len(
              get_experiment(name=exp).fetch_trials(with_evc_tree=False)
          ) == len(Trial.allowed_stati)
  
      assert (
          len(experiment.fetch_trials(with_evc_tree=False))
          == len(Trial.allowed_stati) + N_PENDING * 4
      )
  
file_path: orion/tests/functional/core/worker/test_experiment_functional.py
imports: import logging
  from orion.client import build_experiment, get_experiment
  from orion.core.io.database import DuplicateKeyError
  from orion.core.worker.trial import Trial
  from orion.testing import mocked_datetime
  from orion.testing.evc import build_child_experiment, build_root_experiment, disable_duplication
label_desc: Use image node_id 5 for calling a global function with example usage: test_duplicate_only_once(storage, monkeypatch) without return types