class_docstr: Calls to :meth:`orion.core.io.database.AbstractDB.write`.
docstr: Insert ``_id`` and test inserts without ids.
docstr_tok: ["Insert","``","_id","``","and","test","inserts","without","ids","."]
code: def test_insert_with_id_then_without_id(self, orion_db):
      """Insert ``_id`` and test inserts without ids."""
  
      # First check that custom id can be specified.
      item = {
          "exp_name": "supernaekei",
          "user": "tsirif",
          "_id": "my-custom-id",
      }
      count_before = orion_db.count("experiments")
      # call interface
      assert orion_db.write("experiments", item) == 1
      assert orion_db.count("experiments") == count_before + 1
      value = get_db(orion_db)["experiments"].find(
          {"exp_name": "supernaekei"}
      )[0]
      assert value == item
  
      # Now check that custom id will work properly with DB inferred next id.
      # (item2 does not have a _id specified, thus the DB must infer the id to use)
      item2 = dict(item)
      del item2["_id"]
      assert orion_db.write("experiments", item2) == 1
      assert orion_db.count("experiments") == count_before + 2
      values = get_db(orion_db)["experiments"].find(
          {"exp_name": "supernaekei"}
      )
      assert values[0] == item
      item2["_id"] = values[1]["_id"]
      assert values[1] == item2
  
imports: import pickle
  from datetime import datetime
  import pytest
  from orion.core.io.database import Database, DatabaseError, DuplicateKeyError
  from orion.core.io.database.ephemeraldb import EphemeralDB
  from orion.core.io.database.mongodb import MongoDB
  from orion.core.io.database.pickleddb import PickledDB
  from .conftest import insert_test_collection
label_desc: Use image node_id 5 for calling the TestWrite obj's underlying member method code with example usage: obj.test_insert_with_id_then_without_id(orion_db) without return types