title: Insert ObjectId into mongodb
body: <p>I'm working on a mongo database which, for some reason, has the user id stored as <code>ObjectId</code>.</p>
  
  <p>In order to test some functions, I'd like to be able to populate a test database - for example, as follows:</p>
  
  <pre><code>import mongomock
  from bson import ObjectId
  
  client = mongomock.MongoClient("mongodb://localhost:27017/test-database")
  database = client.get_default_database()
  database.test_collection.insert({'_id': ObjectId('my_user_id'), 'value': 'my_value'})
  </code></pre>
  
  <p>However, running this returns</p>
  
  <blockquote>
    <p>InvalidId: 'my_user_id' is not a valid ObjectId, it must be a 12-byte
    input or a 24-character hex string</p>
  </blockquote>
  
  <p>How can I correctly insert an ObjectId object into my test database, so I can test querying it using</p>
  
  <pre><code>database.test_collection.find_one({'user': ObjectId('my_user_id')})
  </code></pre>
  
  <p>(which works fine when I query the real database)?</p>