Beispiel #1
0
    def test_get_number_of_victories_no_xp_point(self):
        test_session = Session()
        user = User(id=14, name='Me')
        test_session.add(user)
        test_session.commit()

        result = asyncio.run(XpPoint.get_user_aggregated_points(user.id))

        self.assertIsNone(result)
    def test_get_number_of_victories_no_games(self):
        test_session = Session()
        user_1 = User(id=14, name='Me')
        user_2 = User(id=15, name='Them')
        test_session.add(user_1)
        test_session.commit()

        result = asyncio.run(ChessGame.get_number_of_victories(user_1.id))

        self.assertEqual(result, 0)
Beispiel #3
0
    def test_get_number_of_victories_many_servers(self):
        test_session = Session()
        user = User(id=14, name='Me')
        xp_point_1 = XpPoint()
        xp_point_1.user = user
        xp_point_1.server_id = 10
        xp_point_1.points = 140
        test_session.add(xp_point_1)
        xp_point_2 = XpPoint()
        xp_point_2.user = user
        xp_point_2.server_id = 12
        xp_point_2.points = 260
        test_session.add(xp_point_2)
        test_session.commit()

        result = asyncio.run(XpPoint.get_user_aggregated_points(user.id))

        self.assertEqual(result, 400)
    def test_get_number_of_victories_many_games(self):
        test_session = Session()
        user_1 = User(id=14, name='Me')
        user_2 = User(id=15, name='Them')
        chess_game_1 = ChessGame()
        chess_game_1.player1 = user_1
        chess_game_1.player2 = user_2
        chess_game_1.result = 1
        test_session.add(chess_game_1)
        chess_game_2 = ChessGame()
        chess_game_2.player1 = user_2
        chess_game_2.player2 = user_1
        chess_game_2.result = 1
        test_session.add(chess_game_2)
        chess_game_3 = ChessGame()
        chess_game_3.player1 = user_2
        chess_game_3.player2 = user_1
        chess_game_3.result = -1
        test_session.add(chess_game_3)
        test_session.commit()

        result = asyncio.run(ChessGame.get_number_of_victories(user_1.id))

        self.assertEqual(result, 2)