[devtools/repotest] use the RepoAccess object
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Thu, 12 Jun 2014 18:37:29 +0200
changeset 11203 e5d065f612e8
parent 11202 c8b80abab369
child 11204 71057a8bb19a
[devtools/repotest] use the RepoAccess object Quite better than playing tricks with the Repo._sessions. Related to #1381328.
cubicweb/devtools/repotest.py
--- a/cubicweb/devtools/repotest.py	Tue Jul 01 18:25:20 2014 +0200
+++ b/cubicweb/devtools/repotest.py	Thu Jun 12 18:37:29 2014 +0200
@@ -25,8 +25,11 @@
 
 from pprint import pprint
 
+from logilab.common.decorators import cachedproperty
 from logilab.common.testlib import SkipTest
 
+from cubicweb.devtools.testlib import RepoAccess
+
 def tuplify(mylist):
     return [tuple(item) for item in mylist]
 
@@ -138,7 +141,7 @@
 from rql import RQLHelper
 
 from cubicweb.devtools.testlib import BaseTestCase
-from cubicweb.devtools.fake import FakeRepo, FakeConfig, FakeSession
+from cubicweb.devtools.fake import FakeRepo, FakeConfig, FakeSession, FakeRequest
 from cubicweb.server import set_debug, debugged
 from cubicweb.server.querier import QuerierHelper
 from cubicweb.server.session import Session
@@ -196,9 +199,13 @@
 class BaseQuerierTC(TestCase):
     repo = None # set this in concrete class
 
+    @cachedproperty
+    def session(self):
+        return self._access._session
+
     def setUp(self):
         self.o = self.repo.querier
-        self.session = next(iter(self.repo._sessions.values()))
+        self._access = RepoAccess(self.repo, 'admin', FakeRequest)
         self.ueid = self.session.user.eid
         assert self.ueid != -1
         self.repo._type_source_cache = {} # clear cache