[test] fix tests broken by 7427:5338d895b891 stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 25 May 2011 12:35:33 +0200
branchstable
changeset 7434 17ef6f9efaa1
parent 7430 ef5165fa99e0
child 7435 a2c83140794e
[test] fix tests broken by 7427:5338d895b891
devtools/fake.py
devtools/httptest.py
devtools/testlib.py
--- a/devtools/fake.py	Wed May 25 11:39:54 2011 +0200
+++ b/devtools/fake.py	Wed May 25 12:35:33 2011 +0200
@@ -58,7 +58,7 @@
         if not (args or 'vreg' in kwargs):
             kwargs['vreg'] = CubicWebVRegistry(FakeConfig(), initlog=False)
         kwargs['https'] = False
-        self._url = kwargs.pop('url', 'view?rql=Blop&vid=blop')
+        self._url = kwargs.pop('url', None) or 'view?rql=Blop&vid=blop'
         super(FakeRequest, self).__init__(*args, **kwargs)
         self._session_data = {}
         self._headers_in = Headers()
--- a/devtools/httptest.py	Wed May 25 11:39:54 2011 +0200
+++ b/devtools/httptest.py	Wed May 25 12:35:33 2011 +0200
@@ -145,7 +145,7 @@
         if passwd is None:
             passwd = user
         self.login(user)
-        response = self.web_get("?__login=%s&__password=%s" %
+        response = self.web_get("login?__login=%s&__password=%s" %
                                 (user, passwd))
         assert response.status == httplib.SEE_OTHER, response.status
         self._ident_cookie = response.getheader('Set-Cookie')
--- a/devtools/testlib.py	Wed May 25 11:39:54 2011 +0200
+++ b/devtools/testlib.py	Wed May 25 12:35:33 2011 +0200
@@ -611,9 +611,9 @@
         return publisher
 
     requestcls = fake.FakeRequest
-    def request(self, rollbackfirst=False, **kwargs):
+    def request(self, rollbackfirst=False, url=None, **kwargs):
         """return a web ui request"""
-        req = self.requestcls(self.vreg, form=kwargs)
+        req = self.requestcls(self.vreg, url=url, form=kwargs)
         if rollbackfirst:
             self.websession.cnx.rollback()
         req.set_session(self.websession)
@@ -702,7 +702,7 @@
 
     def init_authentication(self, authmode, anonuser=None):
         self.set_auth_mode(authmode, anonuser)
-        req = self.request()
+        req = self.request(url='login')
         origsession = req.session
         req.session = req.cnx = None
         del req.execute # get back to class implementation
@@ -729,7 +729,8 @@
         self.assertIsInstance(req.session, dbapi.DBAPISession)
         self.assertEqual(req.session.cnx, None)
         self.assertIsInstance(req.cnx, (dbapi._NeedAuthAccessMock, NoneType))
-        self.assertEqual(len(self.open_sessions), nbsessions)
+        # + 1 since we should still have session without connection set
+        self.assertEqual(len(self.open_sessions), nbsessions + 1)
         clear_cache(req, 'get_authorization')
 
     # content validation #######################################################