def test_del_session(self): user_id1 = factories.create_user() user_id2 = factories.create_user() session_id = str(utils.get_random_string(50)) session_id2 = str(utils.get_random_string(50)) data = {'user_id': user_id1} data2 = {'user_id': user_id2} user_db.create_session_data(session_id, data) user_db.create_session_data(session_id2, data2) user_db.del_session(session_id) deleted_row = user_db.get_session(session_id) session2 = user_db.get_session(session_id2) self.assertEqual(deleted_row, None) self.assertEqual(session2.data, data2)
def logout_user(request, response): sessionid = request.COOKIES.get(SESSION_KEY) user_db.del_session(sessionid) response.delete_cookie(key=SESSION_KEY) return response