Beispiel #1
0
    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)
Beispiel #2
0
async def handle_EndSession(ctx: wire.Context, msg: EndSession) -> Success:
    cache.end_current_session()
    return Success()