Пример #1
0
async def test_start_game_called_on_match(ladder_service: LadderService, player_factory):
    p1 = player_factory(
        "Dostya",
        player_id=1,
        ladder_rating=(2300, 64),
        ladder_games=0,
        with_lobby_connection=True
    )
    p2 = player_factory(
        "QAI",
        player_id=2,
        ladder_rating=(2350, 125),
        ladder_games=0,
        with_lobby_connection=True
    )

    ladder_service.start_game = CoroutineMock()
    ladder_service.write_rating_progress = CoroutineMock()

    ladder_service.start_search([p1], "ladder1v1")
    ladder_service.start_search([p2], "ladder1v1")

    await asyncio.sleep(2)

    ladder_service.write_rating_progress.assert_called()
    ladder_service.start_game.assert_called_once()
Пример #2
0
async def test_start_game_called_on_match(ladder_service: LadderService):
    p1 = mock.create_autospec(Player('Dostya', id=1))
    p1.ladder_rating = (2300, 64)
    p1.numGames = 0

    p2 = mock.create_autospec(Player('QAI', id=4))
    p2.ladder_rating = (2350, 125)
    p2.numGames = 0

    ladder_service.start_game = CoroMock()
    ladder_service.inform_player = mock.Mock()

    ladder_service.start_search(p1, Search([p1]), 'ladder1v1')
    ladder_service.start_search(p2, Search([p2]), 'ladder1v1')

    await asyncio.sleep(1)

    ladder_service.inform_player.assert_called()
    ladder_service.start_game.assert_called_once()
Пример #3
0
async def test_start_game_called_on_match(ladder_service: LadderService,
                                          player_factory):
    p1 = player_factory('Dostya',
                        player_id=1,
                        ladder_rating=(2300, 64),
                        ladder_games=0,
                        with_lobby_connection=True)
    p2 = player_factory('QAI',
                        player_id=2,
                        ladder_rating=(2350, 125),
                        ladder_games=0,
                        with_lobby_connection=True)

    ladder_service.start_game = CoroutineMock()
    ladder_service.inform_player = CoroutineMock()

    await ladder_service.start_search(p1, Search([p1]), 'ladder1v1')
    await ladder_service.start_search(p2, Search([p2]), 'ladder1v1')

    await asyncio.sleep(2)

    ladder_service.inform_player.assert_called()
    ladder_service.start_game.assert_called_once()