web/test/unittest_application.py
changeset 9065 b1cad8e4557f
parent 9064 2e64254548ca
child 9069 aff871b58ba0
equal deleted inserted replaced
9064:2e64254548ca 9065:b1cad8e4557f
    28 from cubicweb.devtools.testlib import CubicWebTC
    28 from cubicweb.devtools.testlib import CubicWebTC
    29 from cubicweb.devtools.fake import FakeRequest
    29 from cubicweb.devtools.fake import FakeRequest
    30 from cubicweb.web import LogOut, Redirect, INTERNAL_FIELD_VALUE
    30 from cubicweb.web import LogOut, Redirect, INTERNAL_FIELD_VALUE
    31 from cubicweb.web.views.basecontrollers import ViewController
    31 from cubicweb.web.views.basecontrollers import ViewController
    32 from cubicweb.web.application import anonymized_request
    32 from cubicweb.web.application import anonymized_request
       
    33 from cubicweb.dbapi import DBAPISession, _NeedAuthAccessMock
    33 
    34 
    34 class FakeMapping:
    35 class FakeMapping:
    35     """emulates a mapping module"""
    36     """emulates a mapping module"""
    36     def __init__(self):
    37     def __init__(self):
    37         self.ENTITIES_MAP = {}
    38         self.ENTITIES_MAP = {}
   364         cookie[sessioncookie] = req.session.sessionid
   365         cookie[sessioncookie] = req.session.sessionid
   365         req.set_request_header('Cookie', cookie[sessioncookie].OutputString(),
   366         req.set_request_header('Cookie', cookie[sessioncookie].OutputString(),
   366                                raw=True)
   367                                raw=True)
   367         clear_cache(req, 'get_authorization')
   368         clear_cache(req, 'get_authorization')
   368         # reset session as if it was a new incoming request
   369         # reset session as if it was a new incoming request
   369         req.session = req.cnx = None
   370         req.session = DBAPISession(None)
       
   371         req.user = req.cnx = _NeedAuthAccessMock
       
   372         
   370 
   373 
   371     def _test_auth_anon(self, req):
   374     def _test_auth_anon(self, req):
   372         asession = self.app.get_session(req)
   375         asession = self.app.get_session(req)
   373         req.set_session(asession)
   376         req.set_session(asession)
   374         self.assertEqual(len(self.open_sessions), 1)
   377         self.assertEqual(len(self.open_sessions), 1)