Пример #1
0
    def test_start_game_no_prepared_game(self):
        tournament = Tournament()

        tournament.register_player("player1")
        tournament.start_game()

        self.assertEqual(tournament.current_game, None)
Пример #2
0
    def test_store_played_game_known_player(self):
        tournament = Tournament()

        tournament.register_player("player1")
        tournament.store_played_game(PlayedGame("player1", 17))

        self.assertEqual(tournament.played_games, [PlayedGame("player1", 17)])
    def test_store_played_game_known_player(self):
        tournament = Tournament()

        tournament.register_player("player1")
        tournament.store_played_game(PlayedGame("player1", 17))

        self.assertEqual(tournament.played_games, [PlayedGame("player1", 17)])
    def test_start_game_no_prepared_game(self):
        tournament = Tournament()

        tournament.register_player("player1")
        tournament.start_game()

        self.assertEqual(tournament.current_game, None)
Пример #5
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(self):
        tournament = Tournament()

        tournament.register_player("player1")
        tournament.prepare_game("player1")
        tournament.start_game()

        self.assertFalse(tournament.current_game.is_finished())
    def test_prepare_game_known_player(self):
        tournament = Tournament()

        tournament.register_player("player1")
        tournament.prepare_game("player1")

        self.assertEqual(tournament.current_game.player, "player1")
        self.assertIsNotNone(tournament.current_game.start_time)
    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)
Пример #9
0
    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)
Пример #10
0
    def test_prepare_game_known_player(self):
        tournament = Tournament()

        tournament.register_player("player1")
        tournament.prepare_game("player1")

        self.assertEqual(tournament.current_game.player, "player1")
        self.assertIsNotNone(tournament.current_game.start_time)
    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())
Пример #12
0
    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())
Пример #13
0
    def test_leaderboard_games_played_ordered_by_points(self):
        tournament = Tournament()

        tournament.register_player("player1")
        tournament.register_player("player2")
        tournament.store_played_game(PlayedGame("player1", 15))
        tournament.store_played_game(PlayedGame("player2", 18))

        self.assertEqual(tournament.leaderboard(), [Rank("player2", 18), Rank("player1", 15)])
    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)])
Пример #15
0
    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)])
Пример #16
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)])
Пример #18
0
    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)])
    def test_register_player(self):
        tournament = Tournament()

        tournament.register_player("player1")

        self.assertEqual(tournament.players, ["player1"])
Пример #20
0
    def test_leaderboard_no_games_played(self):
        tournament = Tournament()

        tournament.register_player("player1")

        self.assertEqual(tournament.leaderboard(), [Rank("player1", 0)])
Пример #21
0
    def test_register_player(self):
        tournament = Tournament()

        tournament.register_player("player1")

        self.assertEqual(tournament.players, ["player1"])
    def test_leaderboard_no_games_played(self):
        tournament = Tournament()

        tournament.register_player("player1")

        self.assertEqual(tournament.leaderboard(), [Rank("player1", 0)])