def startSession(self, user): # Log the session being ended if the id is changing. if self.currentSession is not None and self.currentSession.getUser( ).getId() != user.getId(): DatabaseManager.sessionEnded(self.currentSession) # Set the session. newSession = Session.startSession(user) self.currentSession = newSession self.notify(newSession) DatabaseManager.sessionStarted(newSession) # Start a thread to expire the session. sessionThread = SessionThread(self) sessionThread.daemon = True sessionThread.start()
def test_startSession(self): CuT = Session.startSession(self.testUser) self.assertEqual(CuT.getUser(),self.testUser,"User is incorrect.") self.assertNotEqual(CuT.getStartTime(),0,"Start time is incorrect.") self.assertAlmostEqual(CuT.getEndTime() - CuT.getStartTime(),20,"Delta time is incorrect.",0.1)