devtools/testlib.py
changeset 10335 88a4e4a60fce
parent 10301 729f36a1bcfa
child 10346 b926ff4ef4a8
equal deleted inserted replaced
10334:3f6702218bac 10335:88a4e4a60fce
   428         self._admin_session = self.admin_access._session
   428         self._admin_session = self.admin_access._session
   429         self._admin_clt_cnx = repoapi.ClientConnection(self._admin_session)
   429         self._admin_clt_cnx = repoapi.ClientConnection(self._admin_session)
   430         self._cnxs.add(self._admin_clt_cnx)
   430         self._cnxs.add(self._admin_clt_cnx)
   431         self._admin_clt_cnx.__enter__()
   431         self._admin_clt_cnx.__enter__()
   432         self.config.repository = lambda x=None: self.repo
   432         self.config.repository = lambda x=None: self.repo
   433 
       
   434     # db api ##################################################################
       
   435 
       
   436     @nocoverage
       
   437     @deprecated('[3.19] explicitly use RepoAccess object in test instead')
       
   438     def cursor(self, req=None):
       
   439         if req is not None:
       
   440             return req.cnx
       
   441         else:
       
   442             return self.cnx
       
   443 
       
   444     @nocoverage
       
   445     @deprecated('[3.19] explicitly use RepoAccess object in test instead')
       
   446     def execute(self, rql, args=None, req=None):
       
   447         """executes <rql>, builds a resultset, and returns a couple (rset, req)
       
   448         where req is a FakeRequest
       
   449         """
       
   450         req = req or self.request(rql=rql)
       
   451         return req.execute(unicode(rql), args)
       
   452 
       
   453     @nocoverage
       
   454     @deprecated('[3.19] explicitly use RepoAccess object in test instead')
       
   455     def commit(self):
       
   456         try:
       
   457             return self.cnx.commit()
       
   458         finally:
       
   459             self.session.set_cnxset() # ensure cnxset still set after commit
       
   460 
       
   461     @nocoverage
       
   462     @deprecated('[3.19] explicitly use RepoAccess object in test instead')
       
   463     def rollback(self):
       
   464         try:
       
   465             self.cnx.rollback()
       
   466         except ProgrammingError:
       
   467             pass # connection closed
       
   468         finally:
       
   469             self.session.set_cnxset() # ensure cnxset still set after commit
       
   470 
       
   471     @deprecated('[3.19] explicitly use RepoAccess object in test instead')
       
   472     def request(self, rollbackfirst=False, url=None, headers={}, **kwargs):
       
   473         """return a web ui request"""
       
   474         if rollbackfirst:
       
   475             self.cnx.rollback()
       
   476         req = self.requestcls(self.vreg, url=url, headers=headers, form=kwargs)
       
   477         req.set_cnx(self.cnx)
       
   478         return req
       
   479 
       
   480     # server side db api #######################################################
       
   481 
       
   482     @deprecated('[3.19] explicitly use RepoAccess object in test instead')
       
   483     def sexecute(self, rql, args=None):
       
   484         self.session.set_cnxset()
       
   485         return self.session.execute(rql, args)
       
   486 
   433 
   487 
   434 
   488     # config management ########################################################
   435     # config management ########################################################
   489 
   436 
   490     @classproperty
   437     @classproperty