# -*- coding: iso-8859-1 -*-"""unit tests for cubicweb.web.application:organization: Logilab:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses"""fromcubicweb.devtools.testlibimportCubicWebTCclassSessionTC(CubicWebTC):deftest_auto_reconnection(self):sm=self.app.session_handler.session_manager# make is if the web session has been opened by the session managersm._sessions[self.cnx.sessionid]=self.websessionsessionid=self.websession.sessionidself.assertEqual(len(sm._sessions),1)self.assertEqual(self.websession.sessionid,self.websession.cnx.sessionid)# fake the repo session is expiringself.repo.close(sessionid)try:# fake an incoming http query with sessionid in session cookie# don't use self.request() which try to call req.set_sessionreq=self.requestcls(self.vreg)websession=sm.get_session(req,sessionid)self.assertEqual(len(sm._sessions),1)self.assertIs(websession,self.websession)self.assertEqual(websession.sessionid,sessionid)self.assertNotEquals(websession.sessionid,websession.cnx.sessionid)finally:# avoid error in tearDown by telling this connection is closed...self.cnx._closed=Trueif__name__=='__main__':fromlogilab.common.testlibimportunittest_mainunittest_main()