title: Mock out database layer in SQLAlchemy
body: <p>I am working on writing some unit tests around an application which uses SQLAlchemy. I would like to abstract/mock away the database layer and just test the object.</p>
  
  <p>For example classes:</p>
  
  <pre><code>class Parent(Base):
      __tablename__ = 'parent'
      id = Column(Integer, primary_key=True)
      children = relationship("Child")
  
  class Child(Base):
      __tablename__ = 'child'
      id = Column(Integer, primary_key=True)
      parent_id = Column(Integer, ForeignKey('parent.id'))
      parent = relationship("Parent", backref=backref('children', order_by=id))
  </code></pre>
  
  <p>What I would like to achieve while unit testing is something like follows:</p>
  
  <pre><code>parent = Mock()
  child = Child(parent)
  assertTrue(someMethod(child))
  </code></pre>
  
  <p>Any ideas on how to accomplish something along those lines?</p>