def test_room_can_be_jsonified(): create_test_game() room = get_room(TEST_GAME) jsonified_room = convert_room_to_json(room) data = json.dumps(jsonified_room) assert data
def test_room_created(): create_test_game() assert game_room_exists(TEST_GAME) room = get_room(TEST_GAME) assert build_player('Mick') in room.team_1_players assert build_player('Dvir') in room.team_2_players
def test_start_game(): create_test_game() room = get_room(TEST_GAME) assert room.game_round == 0 assert room.game_mode == GameModes.LOBBY start_game_action.start_game(TEST_GAME) room = get_room(TEST_GAME) assert room.game_round == 1 assert room.game_mode == GameModes.TURN_RECAP
def test_randomize_room(): create_test_game() room = get_room(TEST_GAME) team_2 = room.team_2_players team_1 = room.team_1_players # Using a seed here ensures the teams will change. random.seed(11) randomize_teams(TEST_GAME) room = get_room(TEST_GAME) assert team_2 != room.team_2_players assert team_1 != room.team_1_players
def test_next_mode_typical_case(): clear_rooms() create_test_game() start_game_action.start_game(TEST_GAME) # go to turn recap room = get_room(TEST_GAME) assert room.game_mode == GameModes.TURN_RECAP next_mode(room.name) room = get_room(TEST_GAME) assert room.game_mode == GameModes.CLUE_GIVING next_mode(room.name) room = get_room(TEST_GAME) assert room.game_mode == GameModes.TURN_RECAP
def test_next_clue_giver_other_team_missing(): clear_rooms() create_test_game() start_game_action.start_game(TEST_GAME) room = get_room(TEST_GAME) assert room.clue_giver == room.team_1_players[0] assert room.last_clue_giver is None giver = room.clue_giver # remove players from team 2 update_room(room.name, evolve(room, team_2_players=[])) next_clue_giver(room.name) # next player now on same team as before room = get_room(TEST_GAME) assert room.clue_giver == room.team_1_players[1] assert room.last_clue_giver == giver
def test_next_clue_giver_typical_case(): clear_rooms() create_test_game() start_game_action.start_game(TEST_GAME) room = get_room(TEST_GAME) assert room.clue_giver == room.team_1_players[0] assert room.last_clue_giver is None giver = room.clue_giver next_clue_giver(room.name) room = get_room(TEST_GAME) assert room.clue_giver == room.team_2_players[0] assert room.last_clue_giver == giver giver = room.clue_giver next_clue_giver(room.name) room = get_room(TEST_GAME) assert room.clue_giver == room.team_1_players[1] assert room.last_clue_giver == giver
from app.actions import join_game_action from app.actions import leave_game_action from app.actions import randomize_teams_action from app.actions import submit_phrases_action from app.actions import unready_phrases_action from app.common.timer import timer from app.initialization import create_app from app.model.fields import Namespaces, ROOM_NAME, PLAYER_NAME, ERROR from app.test_game import create_test_game logging.basicConfig(level=logging.INFO) counter = 0 app, socketio = create_app() create_test_game() @app.route('/') def index(): return render_template('index.html') @socketio.on("add_random", namespace='/') def add_random(request): global counter logging.info("add_random {}".format(request)) counter = counter + random.randint(1, 10) response = {'value': counter} logging.info("response {}".format(response)) return response