class_docstr: Calls to :meth:`orion.core.io.database.AbstractDB.ensure_index`.
class_docstr_tok: ["Calls","to",":","meth",":","`","orion.core.io.database.AbstractDB.ensure_index","`","."]
docstr: Index should be set as unique in mongo database's index information.
docstr_tok: ["Index","should","be","set","as","unique","in","mongo","database","'s","index","information","."]
code: def test_unique_index(self, orion_db):
      """Index should be set as unique in mongo database's index information."""
      assert (
          "name_1_metadata.user_1"
          not in get_db(orion_db)["experiments"].index_information()
      )
      orion_db.ensure_index(
          "experiments",
          [
              ("name", Database.ASCENDING),
              ("metadata.user", Database.ASCENDING),
          ],
          unique=True,
      )
      index_information = get_db(orion_db)[
          "experiments"
      ].index_information()
      assert "name_1_metadata.user_1" in index_information
      assert index_information["name_1_metadata.user_1"]["unique"]
  
imports: import functools
  from timeit import timeit
  import pymongo
  import pytest
  from pymongo import MongoClient
  from orion.core.io.database import Database, DatabaseError, DuplicateKeyError
  from orion.core.io.database.mongodb import AUTH_FAILED_MESSAGES, MongoDB
  from .conftest import insert_test_collection
  from .test_database import get_db
label_desc: Use image node_id 1 for calling the TestEnsureIndex obj's underlying member method code with example usage: obj.test_unique_index(orion_db) without return types