devtools/testlib.py
branchstable
changeset 6369 a151453dc564
parent 6346 1a968e545e4e
child 6370 8c3d6f739fa3
child 6398 ea26eb5fd388
equal deleted inserted replaced
6365:a15cc5e16178 6369:a151453dc564
   292 
   292 
   293     def setUp(self):
   293     def setUp(self):
   294         pause_tracing()
   294         pause_tracing()
   295         previous_failure = self.__class__.__dict__.get('_repo_init_failed')
   295         previous_failure = self.__class__.__dict__.get('_repo_init_failed')
   296         if previous_failure is not None:
   296         if previous_failure is not None:
   297             self.skip('repository is not initialised: %r' % previous_failure)
   297             self.skipTest('repository is not initialised: %r' % previous_failure)
   298         try:
   298         try:
   299             self._init_repo()
   299             self._init_repo()
   300         except Exception, ex:
   300         except Exception, ex:
   301             self.__class__._repo_init_failed = ex
   301             self.__class__._repo_init_failed = ex
   302             raise
   302             raise
   624 
   624 
   625     def assertAuthSuccess(self, req, origsession, nbsessions=1):
   625     def assertAuthSuccess(self, req, origsession, nbsessions=1):
   626         sh = self.app.session_handler
   626         sh = self.app.session_handler
   627         path, params = self.expect_redirect(lambda x: self.app.connect(x), req)
   627         path, params = self.expect_redirect(lambda x: self.app.connect(x), req)
   628         session = req.session
   628         session = req.session
   629         self.assertEquals(len(self.open_sessions), nbsessions, self.open_sessions)
   629         self.assertEqual(len(self.open_sessions), nbsessions, self.open_sessions)
   630         self.assertEquals(session.login, origsession.login)
   630         self.assertEqual(session.login, origsession.login)
   631         self.assertEquals(session.anonymous_session, False)
   631         self.assertEqual(session.anonymous_session, False)
   632         self.assertEquals(path, 'view')
   632         self.assertEqual(path, 'view')
   633         self.assertEquals(params, {'__message': 'welcome %s !' % req.user.login})
   633         self.assertEqual(params, {'__message': 'welcome %s !' % req.user.login})
   634 
   634 
   635     def assertAuthFailure(self, req, nbsessions=0):
   635     def assertAuthFailure(self, req, nbsessions=0):
   636         self.app.connect(req)
   636         self.app.connect(req)
   637         self.assertIsInstance(req.session, DBAPISession)
   637         self.assertIsInstance(req.session, DBAPISession)
   638         self.assertEquals(req.session.cnx, None)
   638         self.assertEqual(req.session.cnx, None)
   639         self.assertEquals(req.cnx, None)
   639         self.assertEqual(req.cnx, None)
   640         self.assertEquals(len(self.open_sessions), nbsessions)
   640         self.assertEqual(len(self.open_sessions), nbsessions)
   641         clear_cache(req, 'get_authorization')
   641         clear_cache(req, 'get_authorization')
   642 
   642 
   643     # content validation #######################################################
   643     # content validation #######################################################
   644 
   644 
   645     # validators are used to validate (XML, DTD, whatever) view's content
   645     # validators are used to validate (XML, DTD, whatever) view's content