def resign(req: Dict[str, Any]) -> Dict[str, Any]: """Delete the player from the database and return a conclusion response""" session_id = get_session_by_req(req) card = save_board_as_png_and_get_image_card(session_id) delete_user(session_id) output = "GG! Thanks for playing." return get_response_for_google(textToSpeech=output, expectUserResponse=False, basicCard=card)
def test_delete_user(context): session_id = get_random_session_id() board = chess.Board() color = chess.BLACK create_user(session_id, board, color) # Verify that the user has been created assert get_user(session_id) == User(board, color) delete_user(session_id) # Verify that deletion is successful assert exists_in_db(session_id) is False # Verify that no other operation has been performed assert UserModel.query.count() == 0
def get_response_kwargs(session_id: str, lastmove_lan: Optional[str] = None): """ Gets the appropriate args for generating response from result and engine's move Note: Also plays engine's move on the board """ user = get_user(session_id) kwargs = {} game_result = get_result_comment(user=user) if game_result: card = save_board_as_png_and_get_image_card(session_id) # TODO: Archive the game instead of deleting delete_user(session_id) kwargs.update( textToSpeech=game_result, expectUserResponse=False, basicCard=card ) else: # Play engine's move output = mediator.play_engine_move_and_get_speech(session_id) user = get_user(session_id) game_result = get_result_comment(user=user) if game_result: output = f"{output}. {game_result}" card = save_board_as_png_and_get_image_card(session_id) delete_user(session_id) kwargs.update( textToSpeech=output, expectUserResponse=False, basicCard=card ) else: output = f"{output}. {get_prompt_phrase()}" kwargs["textToSpeech"] = output if lastmove_lan: kwargs[ "displayText" ] = f"Your last move was {lastmove_lan}.\n {output}" return kwargs