def test_end_session(self): session_id = cache.start_session() self.assertTrue(cache.is_session_started()) cache.set(KEY, b"A") cache.end_current_session() self.assertFalse(cache.is_session_started()) self.assertRaises(cache.InvalidSessionError, cache.get, KEY) # ending an ended session should be a no-op cache.end_current_session() self.assertFalse(cache.is_session_started()) session_id_a = cache.start_session(session_id) # original session no longer exists self.assertNotEqual(session_id_a, session_id) # original session data no longer exists self.assertIsNone(cache.get(KEY)) # create a new session session_id_b = cache.start_session() # switch back to original session session_id = cache.start_session(session_id_a) self.assertEqual(session_id, session_id_a) # end original session cache.end_current_session() # switch back to B session_id = cache.start_session(session_id_b) self.assertEqual(session_id, session_id_b)
def test_EndSession(self): self.assertRaises(cache.InvalidSessionError, cache.get, KEY) session_id = cache.start_session() self.assertTrue(cache.is_session_started()) self.assertIsNone(cache.get(KEY)) await_result(handle_EndSession(DUMMY_CONTEXT, EndSession())) self.assertFalse(cache.is_session_started()) self.assertRaises(cache.InvalidSessionError, cache.get, KEY)