def test_start_game_no_prepared_game(self): tournament = Tournament() tournament.register_player("player1") tournament.start_game() self.assertEqual(tournament.current_game, None)
def test_start_game_prepared_game(self): tournament = Tournament() tournament.register_player("player1") tournament.prepare_game("player1") tournament.start_game() self.assertTrue(tournament.current_game.start_time > 0)
def test_is_finished(self): tournament = Tournament() tournament.register_player("player1") tournament.prepare_game("player1") tournament.start_game() self.assertFalse(tournament.current_game.is_finished())
def test_is_finished_time_elapsed(self): tournament = Tournament() tournament.register_player("player1") tournament.prepare_game("player1") tournament.start_game() tournament.current_game.start_time = 0 self.assertTrue(tournament.current_game.is_finished())
def test_finish(self): tournament = Tournament() tournament.register_player("player1") tournament.prepare_game("player1") tournament.start_game() tournament.finish_game() self.assertIsNone(tournament.current_game) self.assertEqual(tournament.played_games, [PlayedGame("player1", 0)])
def test_update_robot_state(self): tournament = Tournament() tournament.register_player("player1") tournament.prepare_game("player1") tournament.start_game() first_point = tournament.current_game.game.points()[0] tournament.update_robot_position({'x': first_point.x, 'y': first_point.y, 'r': 5}) tournament.finish_game() self.assertIsNone(tournament.current_game) self.assertEqual(tournament.played_games, [PlayedGame("player1", first_point.score)])
def test_store(self): tournament = Tournament() tournament.register_player("player1") tournament.prepare_game("player1") tournament.start_game() tournament.finish_game() storage = PickleTournamentStorage() storage.store_tournament(tournament) tournament = storage.load_tournament() self.assertIsNotNone(tournament) self.assertIsNone(tournament.current_game) self.assertEqual(tournament.played_games, [PlayedGame("player1", 0)])