Exemplo n.º 1
0
def test_league_ranker_simple():
    team_scores = { 'ABC': TeamScore(), 'DEF': TeamScore(4, 5) }
    ranking = LeagueScores.rank_league(team_scores)
    expected_map = {
        'DEF': 1,
        'ABC': 2,
    }
    expected_order = ['DEF', 'ABC']

    assert expected_map == ranking
    order = list(ranking.keys())
    assert expected_order == order
Exemplo n.º 2
0
def load_datas(the_datas, teams):
    my_datas = the_datas[:]
    the_files = ['whatever-{0}.yaml'.format(i) for i in range(len(the_datas))]
    def loader(*args):
        assert len(my_datas), "Should not be loading additional files"
        return my_datas.pop(0)

    with mock.patch('sr.comp.matches.yaml_loader.load') as mock_loader, \
            mock.patch('sr.comp.scores.results_finder') as mock_finder:

        mock_finder.return_value = the_files
        mock_loader.side_effect = loader

        scores = LeagueScores('somewhere', teams, FakeScorer)
        return scores
Exemplo n.º 3
0
def test_league_ranker_game_tie():
    team_scores = {
        'ABC': TeamScore(0, 5),
        'DEF': TeamScore(4, 5),
        'GHI': TeamScore(),
    }
    ranking = LeagueScores.rank_league(team_scores)
    expected_map = {
        'DEF': 1,
        'ABC': 2,
        'GHI': 3,
    }
    expected_order = ['DEF', 'ABC', 'GHI']

    assert expected_map == ranking
    order = list(ranking.keys())
    assert expected_order == order