コード例 #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_start_game_no_prepared_game(self):
        tournament = Tournament()

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

        self.assertEqual(tournament.current_game, None)
コード例 #3
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)
コード例 #4
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())
コード例 #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())
コード例 #6
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)
コード例 #7
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())
コード例 #8
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())
コード例 #9
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)])
コード例 #10
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)])
コード例 #11
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)])
コード例 #12
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)])
コード例 #13
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)])