def test_set_board_rewards(): """ Test that the set_bingo_board() function in restaurant_profile_manager.py can be used to update a user's list of rewards. """ with app.app_context(): rpm = RestaurantProfileManager("vchang") gbm = GameBoardManager(rpm) board = gbm.get_bingo_board() old_rewards = board["board_reward"] new_rewards = [ ObjectId('5ef50127ccd1e88ead4cd07b'), ObjectId('5ef50127ccd1e88ead4cd07b'), ObjectId('5ef50127ccd1e88ead4cd07b'), ObjectId('5ef50127ccd1e88ead4cd07b'), ObjectId('5ef50127ccd1e88ead4cd07b'), ObjectId('5ef50127ccd1e88ead4cd07b'), ObjectId('5ef50127ccd1e88ead4cd07b'), ObjectId('5ef50127ccd1e88ead4cd07b'), ObjectId('5ef50127ccd1e88ead4cd07b'), ObjectId('5ef50127ccd1e88ead4cd07b'), ObjectId('5ef50127ccd1e88ead4cd07b'), ObjectId('5ef50127ccd1e88ead4cd07b') ] board["board_reward"] = new_rewards gbm.set_bingo_board(board) assert (gbm.get_bingo_board())["board_reward"] == new_rewards board["board_reward"] = old_rewards gbm.set_bingo_board(board)
def test_set_bingo_board_old_user(db): """ Test that set_bingo_board() sets only the future board for users that have previous board data. """ with app.app_context(): prev_user = db.query("restaurant_users", {"username": "******"})[0] rpm = RestaurantProfileManager("boardeditoruser") gm = GameBoardManager(rpm) gm.set_bingo_board(get_board()) user = db.query("restaurant_users", {"username": "******"})[0] assert user["future_board"] == get_database_board() assert user["bingo_board"] == prev_user["bingo_board"] # reset user's boards to pre-test db.update("restaurant_users", {"username": "******"}, {"$set": prev_user})
def test_set_bingo_board_new_user(db): """ Test that set_bingo_board() sets both the current and future boards for users with no current board data. """ with app.app_context(): rpm = RestaurantProfileManager("newuser") gm = GameBoardManager(rpm) gm.set_bingo_board(get_board()) user = db.query("restaurant_users", {"username": "******"})[0] db_board = get_database_board() assert user["bingo_board"] == db_board db_board["expiry_date"] = datetime(2021, 8, 24, 23, 59, 59) assert user["future_board"] == db_board # reset new user's boards db.update("restaurant_users", {"username": "******"}, {"$unset": { "bingo_board": "", "future_board": "" }})