|
1 # -*- coding: iso-8859-1 -*- |
|
2 """unit tests for cubicweb.web.application |
|
3 |
|
4 :organization: Logilab |
|
5 :copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
|
6 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
|
7 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
|
8 """ |
|
9 from cubicweb.devtools.testlib import CubicWebTC |
|
10 |
|
11 class SessionTC(CubicWebTC): |
|
12 |
|
13 def test_auto_reconnection(self): |
|
14 sm = self.app.session_handler.session_manager |
|
15 # make is if the web session has been opened by the session manager |
|
16 sm._sessions[self.cnx.sessionid] = self.websession |
|
17 sessionid = self.websession.sessionid |
|
18 self.assertEquals(len(sm._sessions), 1) |
|
19 self.assertEquals(self.websession.sessionid, self.websession.cnx.sessionid) |
|
20 # fake the repo session is expiring |
|
21 self.repo.close(sessionid) |
|
22 # fake an incoming http query with sessionid in session cookie |
|
23 # don't use self.request() which try to call req.set_session |
|
24 req = self.requestcls(self.vreg) |
|
25 websession = sm.get_session(req, sessionid) |
|
26 self.assertEquals(len(sm._sessions), 1) |
|
27 self.assertIs(websession, self.websession) |
|
28 self.assertEquals(websession.sessionid, sessionid) |
|
29 self.assertNotEquals(websession.sessionid, websession.cnx.sessionid) |
|
30 |
|
31 if __name__ == '__main__': |
|
32 from logilab.common.testlib import unittest_main |
|
33 unittest_main() |