Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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