コード例 #1
0
ファイル: test_play.py プロジェクト: Jiankun-Huang/JGS
def test_game_players_handicap():
    svc = PlayService()

    user = UserFactory(rating=1500)
    other = UserFactory(rating=1500)
    assert svc.game_players_handicap(other, user)[2] == 0

    user = UserFactory(rating=1500)
    other = UserFactory(rating=1600)
    assert svc.game_players_handicap(other, user) == (user, other, 1)

    user = UserFactory(rating=1800)
    other = UserFactory(rating=1600)
    assert svc.game_players_handicap(other, user) == (other, user, 2)
コード例 #2
0
ファイル: test_play.py プロジェクト: Jiankun-Huang/JGS
def test_game_players_random():
    user = UserFactory(rating=1500)
    other = UserFactory(rating=1500)
    svc = PlayService()

    has_user_black = False
    has_user_white = False

    for i in range(20):
        if svc.game_players_handicap(other, user)[0] == user:
            has_user_black = True
        else:
            has_user_white = True

    assert has_user_black
    assert has_user_white
コード例 #3
0
ファイル: test_play.py プロジェクト: Jiankun-Huang/JGS
def test_game_player_handicap_limit():
    svc = PlayService()

    user = UserFactory(rating=2000)
    other = UserFactory(rating=100)
    assert svc.game_players_handicap(other, user)[2] == 9