def test_refresh_session_success(user_id, session_valid): session_infos = userdb._load_session_infos(user_id) assert session_infos old_session = session_infos[session_valid] with on_time("2019-09-05 00:00:30", "UTC"): userdb._refresh_session(user_id, session_valid) new_session_infos = userdb._load_session_infos(user_id) new_session = new_session_infos[session_valid] assert old_session.session_id == new_session.session_id assert new_session.last_activity > old_session.last_activity
def test_refresh_session_success(user_id: UserId, session_valid: str) -> None: session_infos = userdb._load_session_infos(user_id) assert session_infos old_session = userdb.SessionInfo(**asdict(session_infos[session_valid])) with on_time("2019-09-05 00:00:30", "UTC"): userdb._set_session(user_id, session_infos[session_valid]) userdb._refresh_session(user_id, session_infos[session_valid]) userdb.on_end_of_request(user_id) new_session_infos = userdb._load_session_infos(user_id) new_session = new_session_infos[session_valid] assert old_session.session_id == new_session.session_id assert new_session.last_activity > old_session.last_activity
def test_refresh_session_success(user_id: UserId) -> None: now = datetime.now() session_valid = make_valid_session(user_id, now) session_infos = userdb._load_session_infos(user_id) assert session_infos old_session = userdb.SessionInfo(**asdict(session_infos[session_valid])) now += timedelta(minutes=30) userdb._set_session(user_id, session_infos[session_valid]) userdb._refresh_session(session_infos[session_valid], now) userdb.on_end_of_request(user_id, now) new_session_infos = userdb._load_session_infos(user_id) new_session = new_session_infos[session_valid] assert old_session.session_id == new_session.session_id assert new_session.last_activity > old_session.last_activity