def test_mapping_for_leftover(): """ Tests correct mapping of leftover maze card """ created_game, _ = _create_test_game() game_dto = mapper.game_to_dto(created_game) game = mapper.dto_to_game(game_dto) assert _compare_maze_cards( *map(lambda g: g.board.leftover_card, [created_game, game]))
def test_mapping_for_objectives(): """ Tests correct mapping of players' objective """ created_game, player_ids = _create_test_game() game_dto = mapper.game_to_dto(created_game) game = mapper.dto_to_game(game_dto) _assert_games_using_function( created_game, game, lambda g: g.board.objective_maze_card.identifier)
def test_mapping_score(): """ Tests correct mapping of player's score """ created_game, player_ids = _create_test_game() game_dto = mapper.game_to_dto(created_game) game = mapper.dto_to_game(game_dto) for player_id in player_ids: _assert_games_using_function(created_game, game, lambda g: g.get_player(player_id).score)
def test_mapping_for_maze(): """ Tests correct mapping of current maze state """ created_game, _ = _create_test_game() game_dto = mapper.game_to_dto(created_game) game = mapper.dto_to_game(game_dto) assert game.board.maze.maze_size == created_game.board.maze.maze_size for location in game.board.maze.maze_locations: assert _compare_maze_cards( *map(lambda g: g.board.maze[location], [created_game, game])) assert _compare_maze_cards( *map(lambda g: g.board.leftover_card, [created_game, game]))
def test_mapping_for_player(): """ Tests correct mapping of player """ created_game, player_ids = _create_test_game() game_dto = mapper.game_to_dto(created_game) game = mapper.dto_to_game(game_dto) assert game.get_player(player_ids[0]).identifier == player_ids[0] assert game.get_player(player_ids[1]).identifier == player_ids[1] _assert_games_using_function( created_game, game, lambda g: g.get_player(player_ids[0]).piece.maze_card.identifier) _assert_games_using_function( created_game, game, lambda g: g.get_player(player_ids[1]).piece.maze_card.identifier)
def test_mapping_turns(): """ Tests correct mapping of next actions """ created_game, player_ids = _create_test_game() game_dto = mapper.game_to_dto(created_game) game = mapper.dto_to_game(game_dto) for _ in range(len(player_ids) * 2): _assert_games_using_function( created_game, game, lambda g: g.turns.next_player_action().player.identifier) _assert_games_using_function( created_game, game, lambda g: g.turns.next_player_action().action) game.turns.perform_action(game.turns.next_player_action().player, game.turns.next_player_action().action) created_game.turns.perform_action( created_game.turns.next_player_action().player, created_game.turns.next_player_action().action)
def test_mapping_turns(): """ Tests correct mapping of next actions """ created_game, player_ids = _create_test_game() game_dto = mapper.game_to_dto(created_game) game = mapper.dto_to_game(game_dto) _assert_games_using_function(created_game, game, lambda g: g.turns.prepare_delay) for _ in range(len(player_ids) * 2): _assert_games_using_function( created_game, game, lambda g: g.turns.next_player_action().player.identifier) _assert_games_using_function( created_game, game, lambda g: g.turns.next_player_action().action) game.turns.perform_action(game.turns.next_player_action().player, game.turns.next_player_action().action) created_game.turns.perform_action( created_game.turns.next_player_action().player, created_game.turns.next_player_action().action) assert game.turns.next_player_action().is_prepare() time.sleep(DELAY.total_seconds() + 0.1)
def test_mapping_identifier(): """ Tests correct mapping of game id """ created_game, _ = _create_test_game() game_dto = mapper.game_to_dto(created_game) game = mapper.dto_to_game(game_dto) assert game.identifier == created_game.identifier
def test_mapping_previous_shift_location(): """ Tests correct mapping of previous shift location """ created_game, player_ids = _create_test_game() game_dto = mapper.game_to_dto(created_game) game = mapper.dto_to_game(game_dto) assert game.previous_shift_location == BoardLocation(0, 3)