[devtools] add 'shell' method to RepoAccess, deprecate CubicWebTC's
authorJulien Cristau <julien.cristau@logilab.fr>
Mon, 07 Apr 2014 12:03:06 +0200
changeset 9667 4714d4afd4ea
parent 9666 9a40a62d54bf
child 9668 501f14e095d1
[devtools] add 'shell' method to RepoAccess, deprecate CubicWebTC's Lets us control the connection's lifetime.
devtools/testlib.py
--- a/devtools/testlib.py	Mon Apr 07 14:44:49 2014 +0200
+++ b/devtools/testlib.py	Mon Apr 07 12:03:06 2014 +0200
@@ -249,6 +249,17 @@
             self._repo.close(self._session.sessionid)
         self._session = None
 
+    @contextmanager
+    def shell(self):
+        from cubicweb.server.migractions import ServerMigrationHelper
+        with repoapi.ClientConnection(self._session) as cnx:
+            mih = ServerMigrationHelper(None, repo=self._repo, cnx=cnx,
+                                        interactive=False,
+                                        # hack so it don't try to load fs schema
+                                        schema=1)
+            yield mih
+            cnx.commit()
+
 
 
 # base class for cubicweb tests requiring a full cw environments ###############
@@ -524,6 +535,7 @@
         """return the application schema"""
         return self.vreg.schema
 
+    @deprecated('[3.19] explicitly use RepoAccess object in test instead')
     def shell(self):
         """return a shell session object"""
         from cubicweb.server.migractions import ServerMigrationHelper