title: unit testing in tornado
body: <p>I'm building a simple web application in tornado.web using mongodb as the backend. 90% of the server-side codebase lives in a set of RequestHandlers, and 90% of the data objects are json.  As a result, the basic use case for testing handlers is:</p>
  
  <pre><code>"Given Request Y and DB in state X,
   verify that handler method Z returns json object J"
  </code></pre>
  
  <p>How do I set up this kind of test?</p>
  
  <p>I've found a few blog posts and discussion threads on the topic, but they mainly focus on setting up asyncronous.  I can't find anything on setting up the right kind of DB state or GET/POST request arguments.</p>
  
  <ul>
  <li><a href="http://emptysquare.net/blog/tornado-unittesting-eventually-correct/">http://emptysquare.net/blog/tornado-unittesting-eventually-correct/</a></li>
  <li><a href="http://www.tornadoweb.org/documentation/testing.html">http://www.tornadoweb.org/documentation/testing.html</a></li>
  <li><a href="https://groups.google.com/group/python-tornado/browse_thread/thread/867cfb2665ea10a9/319555e619fe6c5c">https://groups.google.com/group/python-tornado/browse_thread/thread/867cfb2665ea10a9/319555e619fe6c5c</a></li>
  </ul>