def test_get_future_board_new_user():
    """
    Test that get_future_board() retrieves an empty board for a new user.
    """
    with app.app_context():
        rpm = RestaurantProfileManager("newuser")
        gm = GameBoardManager(rpm)
        assert gm.get_future_board() == {
            "board": [],
            "name": "",
            "board_reward": [],
            "expiry_date": None,
            "size": 4
        }
Ejemplo n.º 2
0
def edit_board():
    """
    When retrieving this route, get a restaurant profile's goals, rewards and future
    board. Render these items together to show a bingo editor.
    """
    rest_id = current_user.get_restaurant_id()
    gbm = GameBoardManager(current_user)
    gbm.update_board(rest_id)
    bingo_board = gbm.get_future_board()
    current_expiry = gbm.get_current_board_expiry()

    goals = GoalsManager(current_user).get_goals()
    rewards = RewardsManager(current_user).get_rewards()

    return render_template('edit_game_board.j2',
                           goals=goals,
                           board_name=bingo_board["name"],
                           rewards=rewards,
                           board=bingo_board["board"],
                           board_reward=bingo_board["board_reward"],
                           board_size=bingo_board["size"],
                           current_expiry=current_expiry,
                           future_expiry=bingo_board["expiry_date"])
def test_get_future_board_old_user():
    """
    Test that get_future_board() retrieves the correct future board for a user with board data.
    """
    with app.app_context():
        rpm = RestaurantProfileManager("boardeditoruser")
        gm = GameBoardManager(rpm)
        assert gm.get_future_board() == {
            "name":
                "My 3x3",
            "size":
                3,
            "expiry_date":
                datetime(2020, 11, 27, 23, 59, 59),
            "board": [
                ObjectId("5ef50183ccd1e88ead4cd081"),
                ObjectId("5ef501f1ccd1e88ead4cd089"),
                ObjectId("5ef5010fccd1e88ead4cd079"),
                ObjectId("5ef50134ccd1e88ead4cd07c"),
                ObjectId("5ef50183ccd1e88ead4cd081"),
                ObjectId("5ef501b9ccd1e88ead4cd084"),
                ObjectId("5ef50155ccd1e88ead4cd07e"),
                ObjectId("5ef501b9ccd1e88ead4cd084"),
                ObjectId("5ef500edccd1e88ead4cd078")
            ],
            "board_reward": [
                ObjectId("5f03a9fd7aae4a086d810102"),
                ObjectId("5f03aa377aae4a086d810106"),
                ObjectId("5f03aa507aae4a086d810108"),
                ObjectId("5f03a9df7aae4a086d810100"),
                ObjectId("5f03aa377aae4a086d810106"),
                ObjectId("5f03a9df7aae4a086d810100"),
                ObjectId("5f03aa287aae4a086d810105"),
                ObjectId("5f03aa507aae4a086d810108")
            ]
        }