def testGetSessionWithTicket(self):
     ## Create a new session
     self.cfg._authenticated_session = "email"
     # BUG?
     # pourquoi un ticket n'est cree que dans le cas self.cfg._authenticated_session = 'email'
     # et pas quand self.cfg._authenticated_session = 'yes' ????
     session1 = AuthenticatedSession(self.cfg, self.email, passwd=self.passwd)
     ## Fetch an existing session
     session2 = AuthenticatedSession(self.cfg, self.email, ticket_id=session1.ticket_id)
     self.assertEqual(session1.getDir(), session2.getDir())
     self.assertRaises(SessionError, AuthenticatedSession, self.cfg, self.email, ticket_id=session1.ticket_id + "1")
 def testGetSessionWithPasswd(self):
     ## Create a new session
     session1 = AuthenticatedSession(self.cfg, self.email, passwd=self.passwd)
     ## Fetch an existing session
     session2 = AuthenticatedSession(self.cfg, self.email, passwd=self.passwd)
     self.assertEqual(session1.getDir(), session2.getDir())
     self.assertRaises(AuthenticationError, AuthenticatedSession, self.cfg, self.email, passwd="bad_" + self.passwd)
     ## Creation should fail if disabled
     self.cfg._authenticated_session = "no"
     self.assertRaises(SessionError, AuthenticatedSession, self.cfg, self.email, passwd=self.passwd)
     self.cfg._authenticated_session = "yes"
     ##try to authenticated with an invalid email
     session1._AuthenticatedSession__userEmail.check = lambda x: False
     session2 = AuthenticatedSession(self.cfg, self.email, passwd=self.passwd)