def setUp(self): """Setup test fixture for each model test method.""" try: new_attrs = {} new_attrs.update(self.attrs) new_attrs.update(self.do_get_dependencies()) self.obj = self.klass(**new_attrs) DBSession.add(self.obj) DBSession.flush() return self.obj except: DBSession.rollback() raise
def test_query_obj(self): """Model objects can be queried""" obj = DBSession.query(self.klass).one() for key, value in self.attrs.items(): eq_(getattr(obj, key), value)
def tearDown(self): """Tear down test fixture for each model test method.""" DBSession.rollback()
def by_user_name(cls, username): """Return the user object whose user name is ``username``.""" return DBSession.query(cls).filter_by(user_name=username).first()
def by_email_address(cls, email): """Return the user object whose email address is ``email``.""" return DBSession.query(cls).filter_by(email_address=email).first()
def pageTest(self): pages = [ page.pagename for page in DBSession.query(Page).order_by(Page.pagename) ] return dict(pages=pages)
def save(self, pagename, data, submit): page = DBSession.query(Page).filter_by(pagename=pagename).one() page.data = data redirect("/" + pagename)
def edit(self, pagename): page = DBSession.query(Page).filter_by(pagename=pagename).one() return dict(wikipage=page)
def _default(self, pagename="FrontPage"): """Handle the front-page.""" page = DBSession.query(Page).filter_by(pagename=pagename).one() return dict(wikipage=page)