title: How to implement pytest for FastAPI with MongoDB(Motor)
body: <p>I want to write tests for my FastAPI endpoints</p>
  <p>example for my code:</p>
  <pre class="lang-py prettyprint-override"><code>from fastapi import FastAPI
  from fastapi.testclient import TestClient
  
  app = FastAPI()
  
  @app.get(&quot;/todos&quot;)
  async def get_todo_by_title(title: str,current_user: User = Depends(get_current_user))
      document = await collection.find_one({&quot;title&quot;: title})
      return document
  
  client = TestClient(app)
  
  def test_get_todo_by_title():
      response = client.get(&quot;/todos&quot;)
      assert response.status_code == 200
  </code></pre>
  <p>What the best way to test my endpoints?</p>
  <p>I want to use fake DB for testing, something like json file</p>
  <pre class="lang-json prettyprint-override"><code>db = {
  todos: [...]
  }
  </code></pre>