class_docstr: Calls to :meth:`orion.core.io.database.AbstractDB.ensure_index`.
docstr: Index should be added to database and reattempt should do nothing
docstr_tok: ["Index","should","be","added","to","database","and","reattempt","should","do","nothing"]
code: def test_existing_index(self, orion_db):
      """Index should be added to database and reattempt should do nothing"""
      assert (
          "new_field_1"
          not in get_db(orion_db)["new_collection"].index_information()
      )
  
      orion_db.ensure_index("new_collection", "new_field", unique=True)
      assert (
          "new_field_1"
          in get_db(orion_db)["new_collection"].index_information()
      )
  
      # reattempt
      orion_db.ensure_index("new_collection", "new_field", unique=True)
      assert (
          "new_field_1"
          in get_db(orion_db)["new_collection"].index_information()
      )
  
imports: import os
  from datetime import datetime
  import pytest
  from orion.core.io.database import Database
  from orion.core.io.database.ephemeraldb import EphemeralDB
  from orion.core.io.database.mongodb import MongoDB
  from orion.core.io.database.pickleddb import PickledDB
label_desc: Use image node_id 2 for calling the TestEnsureIndex obj's underlying member method code with example usage: obj.test_existing_index(orion_db) without return types