def test_session(self): system.setup(os.path.expanduser('~')) db = system.db session = Session(system) #Create new session id = session.new_session() self.assert_(id!='Session error') session.MyName = 'Test' session.Message = 'This is a test session' session.Number = 123 session.save_session(id) try: cmd = 'select * from dz_sessions where sesskey=%s' q = db(cmd, id) self.assertEqual(len(list(q)), 1) # Create new session object session2 = Session(system) # Load previously created session request.session_token = id session2.load_session() self.assertEqual(session2.Number,123) self.assertEqual(session2.MyName,'Test') self.assertEqual(session2.Message,'This is a test session') finally: session.destroy_session(id) cmd = 'select * from dz_sessions where sesskey=%s' q = db(cmd, id) self.assertEqual(len(list(q)), 0)
def test_session(self): system.setup(os.path.expanduser('~')) db = system.db session = Session(system) #Create new session id = session.new_session() self.assert_(id != 'Session error') session.MyName = 'Test' session.Message = 'This is a test session' session.Number = 123 session.save_session(id) try: cmd = 'select * from dz_sessions where sesskey=%s' q = db(cmd, id) self.assertEqual(len(list(q)), 1) # Create new session object session2 = Session(system) # Load previously created session request.session_token = id session2.load_session() self.assertEqual(session2.Number, 123) self.assertEqual(session2.MyName, 'Test') self.assertEqual(session2.Message, 'This is a test session') finally: session.destroy_session(id) cmd = 'select * from dz_sessions where sesskey=%s' q = db(cmd, id) self.assertEqual(len(list(q)), 0)
def test_session(self): db = self.request.site.db session = Session(self.request) #Create new session # id = session.new(db) id = session._token logger.debug('created session %r', id) # logger.debug('session._token is %r', session._token) self.assert_(id != 'Session error') session.MyName = 'Test' session.Message = 'This is a test session' session.Number = 123 session.save(db) try: cmd = 'select * from sessions where id=%s' q = db(cmd, id) self.assertEqual(len(list(q)), 1) # Create new session object session2 = Session(self.request) # Load previously created session self.request.session_token = id session2.load(db, id) self.assertEqual(session2.Number, 123) self.assertEqual(session2.MyName, 'Test') self.assertEqual(session2.Message, 'This is a test session') finally: session.destroy() logger.debug('attempting to destroy session %r', id) cmd = 'select * from sessions where id=%s' q = db(cmd, id) self.assertEqual(len(list(q)), 0)
def test_session(self): logger = logging.getLogger(__name__) db = self.request.site.db # create session and and store some values session = Session(self.request) token = session.token logger.debug('created session %r', token) self.assertNotEqual(token, 'Session error') session.MyName = 'Test' session.Message = 'This is a test session' session.Number = 123 session.save(db) try: cmd = 'select * from sessions where id=%s' q = db(cmd, token) self.assertEqual(len(list(q)), 1) # Create new session object session2 = Session(self.request) # Load previously created session self.request.session_token = token session2.load(db, token) self.assertEqual(session2.Number, 123) self.assertEqual(session2.MyName, 'Test') self.assertEqual(session2.Message, 'This is a test session') finally: session.destroy() logger.debug('attempting to destroy session %r', token) cmd = 'select * from sessions where id=%s' q = db(cmd, token) self.assertEqual(len(list(q)), 0)