示例#1
0
def test_player_stat():
    player_stat = PlayerStat('test_player')
    assert player_stat
    assert player_stat.__str__() != ''
    assert player_stat.get_worst_ennemy() == ('none', 0)
    assert player_stat.last == 0
    # loss + last
    player_stat.new_play(__get_play(players='test_player=0,first=10'))
    # loss + not last
    player_stat.new_play(__get_play(players='test_player=5,other=10,last=0'))
    assert player_stat.last == 1
示例#2
0
def test_player_stat_winloss_streak():
    """
    test the streaks of win or loose
    :return:
    """
    pstat = PlayerStat('test_player')
    assert pstat.streak_win == 0
    assert pstat.streak_loose == 0
    pstat._PlayerStat__new_win()
    assert pstat.streak_win == 1
    assert pstat.streak_win_longest == 1
    assert pstat.streak_loose == 0
    pstat._PlayerStat__new_win()
    assert pstat.streak_win == 2
    assert pstat.streak_win_longest == 2
    assert pstat.streak_loose == 0
    pstat._PlayerStat__new_loss(['other'])
    assert pstat.streak_win == 0
    assert pstat.streak_loose == 1
    assert pstat.streak_loose_longest == 1
    pstat._PlayerStat__new_loss(['other'])
    assert pstat.streak_win == 0
    assert pstat.streak_win_longest == 2
    assert pstat.streak_loose == 2
    assert pstat.streak_loose_longest == 2
    pstat._PlayerStat__new_win()
    assert pstat.streak_win == 1
    assert pstat.streak_win_longest == 2
    assert pstat.streak_loose == 0
    assert pstat.streak_loose_longest == 2
    pstat._PlayerStat__new_win()
    pstat._PlayerStat__new_win()
    pstat._PlayerStat__new_win()
    assert pstat.streak_win == 4
    assert pstat.streak_win_longest == 4