devtools/testlib.py
changeset 9667 4714d4afd4ea
parent 9635 aaf099172bb9
child 9757 6eb7f361fba0
equal deleted inserted replaced
9666:9a40a62d54bf 9667:4714d4afd4ea
   246     def close(self):
   246     def close(self):
   247         """Close the session associated to the RepoAccess"""
   247         """Close the session associated to the RepoAccess"""
   248         if self._session is not None:
   248         if self._session is not None:
   249             self._repo.close(self._session.sessionid)
   249             self._repo.close(self._session.sessionid)
   250         self._session = None
   250         self._session = None
       
   251 
       
   252     @contextmanager
       
   253     def shell(self):
       
   254         from cubicweb.server.migractions import ServerMigrationHelper
       
   255         with repoapi.ClientConnection(self._session) as cnx:
       
   256             mih = ServerMigrationHelper(None, repo=self._repo, cnx=cnx,
       
   257                                         interactive=False,
       
   258                                         # hack so it don't try to load fs schema
       
   259                                         schema=1)
       
   260             yield mih
       
   261             cnx.commit()
   251 
   262 
   252 
   263 
   253 
   264 
   254 # base class for cubicweb tests requiring a full cw environments ###############
   265 # base class for cubicweb tests requiring a full cw environments ###############
   255 
   266 
   522     @property
   533     @property
   523     def schema(self):
   534     def schema(self):
   524         """return the application schema"""
   535         """return the application schema"""
   525         return self.vreg.schema
   536         return self.vreg.schema
   526 
   537 
       
   538     @deprecated('[3.19] explicitly use RepoAccess object in test instead')
   527     def shell(self):
   539     def shell(self):
   528         """return a shell session object"""
   540         """return a shell session object"""
   529         from cubicweb.server.migractions import ServerMigrationHelper
   541         from cubicweb.server.migractions import ServerMigrationHelper
   530         return ServerMigrationHelper(None, repo=self.repo, cnx=self.cnx,
   542         return ServerMigrationHelper(None, repo=self.repo, cnx=self.cnx,
   531                                      interactive=False,
   543                                      interactive=False,