예제 #1
0
def test_manual_tie():
    with mock.patch('sr.comp.yaml_loader.load') as yaml_load:
        yaml_load.return_value = {'web': ['BBB', 'CCC']}
        eq_(
            compute_awards(MockScores(), FINAL_INFO, TEAMS,
                           '.').get(Award.web), ['BBB', 'CCC'])
        yaml_load.assert_called_with('.')
예제 #2
0
def test_override():
    with mock.patch('sr.comp.yaml_loader.load') as yaml_load:
        yaml_load.return_value = {'third': 'DDD'}
        eq_(
            compute_awards(MockScores(), FINAL_INFO, TEAMS,
                           '.').get(Award.third), ['DDD'])
        yaml_load.assert_called_with('.')
예제 #3
0
def test_tied_rookie():
    eq_(
        compute_awards(
            MockScores(league={
                'AAA': 0,
                'BBB': 0,
                'CCC': 0,
                'DDD': 0
            }), FINAL_INFO, TEAMS).get(Award.rookie), ['AAA', 'CCC'])
예제 #4
0
    def __init__(self, root):
        self.root = root

        self.state = check_output(('git', 'rev-parse', 'HEAD'),
                                  universal_newlines=True,
                                  cwd=root).strip()
        """The current commit of the Compstate repository."""

        self.teams = teams.load_teams(os.path.join(root, "teams.yaml"))
        """A :class:`collections.OrderedDict` mapping TLAs to
        :class:`sr.comp.teams.Team` objects."""

        scorer = load_scorer(root)
        self.scores = scores.Scores(root, self.teams.keys(), scorer)
        """A :class:`sr.comp.scores.Scores` instance."""

        self.arenas = arenas.load_arenas(os.path.join(root, "arenas.yaml"))
        """A :class:`collections.OrderedDict` mapping arena names to
        :class:`sr.comp.arenas.Arena` objects."""

        schedule_fname = os.path.join(root, "schedule.yaml")
        league_fname = os.path.join(root, "league.yaml")
        self.schedule = matches.MatchSchedule.create(schedule_fname,
                                                     league_fname, self.scores,
                                                     self.arenas, self.teams)
        """A :class:`sr.comp.matches.MatchSchedule` instance."""

        self.timezone = self.schedule.timezone
        """The timezone of the competition."""

        self.corners = arenas.load_corners(os.path.join(root, "arenas.yaml"))
        """A :class:`collections.OrderedDict` mapping corner numbers to
        :class:`sr.comp.arenas.Corner` objects."""

        self.awards = compute_awards(self.scores, self.schedule.final_match,
                                     self.teams,
                                     os.path.join(root, "awards.yaml"))
        """A :class:`dict` mapping :class:`sr.comp.winners.Award` objects to
        a :class:`list` of teams."""

        self.venue = venue.Venue(self.teams.keys(),
                                 os.path.join(root, "layout.yaml"),
                                 os.path.join(root, "shepherding.yaml"))
        """A :class:`sr.comp.venue.Venue` instance."""

        self.venue.check_staging_times(self.schedule.staging_times)

        pyver = sys.version_info
        if pyver[0] == 3 and (pyver < (3, 4, 4) or pyver == (3, 5, 0)):
            from warnings import warn
            warn(
                "Python 3 < 3.4.4, 3.5.1 has a known issue with timezones that "
                "have the same `dst()` and `utcoffset()` values (such as BST). "
                "Using Python 2 instead is recommended. "
                "See https://bugs.python.org/issue23600.")
예제 #5
0
def test_tied_partial():
    eq_(
        compute_awards(
            MockScores(knockout={
                'AAA': 2,
                'BBB': 1,
                'CCC': 1,
                'DDD': 1
            },
                       knockout_dsq=()), FINAL_INFO, TEAMS).get(Award.first),
        ['AAA'])
예제 #6
0
def test_rookie():
    eq_(
        compute_awards(MockScores(), FINAL_INFO, TEAMS).get(Award.rookie),
        ['AAA'])
예제 #7
0
def test_second():
    eq_(
        compute_awards(MockScores(), FINAL_INFO, TEAMS).get(Award.second),
        ['DDD'])
예제 #8
0
def test_third():
    eq_(
        compute_awards(MockScores(), FINAL_INFO, TEAMS).get(Award.third),
        ['AAA'])
예제 #9
0
def test_third_tiebreaker():
    # Needs to look in the scores for the final
    scores = build_tiebreaker_scores()
    eq_(
        compute_awards(scores, TIEBREAKER_INFO, TEAMS).get(Award.third),
        ['DDD'])
예제 #10
0
def test_first():
    eq_(
        compute_awards(MockScores(), FINAL_INFO, TEAMS).get(Award.first),
        ['BBB'])
예제 #11
0
def test_first_tiebreaker():
    scores = build_tiebreaker_scores()
    eq_(
        compute_awards(scores, TIEBREAKER_INFO, TEAMS).get(Award.first),
        ['BBB'])
예제 #12
0
def test_first_tiebreaker():
    scores = build_tiebreaker_scores()
    eq_(compute_awards(scores, TIEBREAKER_INFO, TEAMS).get(Award.first), ['BBB'])
예제 #13
0
def test_second():
    eq_(compute_awards(MockScores(), FINAL_INFO, TEAMS).get(Award.second),
        ['DDD'])
예제 #14
0
def test_manual_tie():
    with mock.patch('sr.comp.yaml_loader.load') as yaml_load:
        yaml_load.return_value = {'web': ['BBB', 'CCC']}
        eq_(compute_awards(MockScores(), FINAL_INFO, TEAMS, '.').get(Award.web),
            ['BBB', 'CCC'])
        yaml_load.assert_called_with('.')
예제 #15
0
def test_first():
    eq_(compute_awards(MockScores(), FINAL_INFO, TEAMS).get(Award.first),
        ['BBB'])
예제 #16
0
def test_third_tiebreaker():
    # Needs to look in the scores for the final
    scores = build_tiebreaker_scores()
    eq_(compute_awards(scores, TIEBREAKER_INFO, TEAMS).get(Award.third), ['DDD'])
예제 #17
0
def test_second_tiebreaker():
    scores = build_tiebreaker_scores()
    eq_(compute_awards(scores, TIEBREAKER_INFO, TEAMS).get(Award.second), ['AAA'])
예제 #18
0
def test_override():
    with mock.patch('sr.comp.yaml_loader.load') as yaml_load:
        yaml_load.return_value = {'third': 'DDD'}
        eq_(compute_awards(MockScores(), FINAL_INFO, TEAMS, '.').get(Award.third),
            ['DDD'])
        yaml_load.assert_called_with('.')
예제 #19
0
def test_tied_rookie():
    eq_(compute_awards(MockScores(league={'AAA': 0, 'BBB': 0, 'CCC': 0, 'DDD': 0}),
                       FINAL_INFO,
                       TEAMS).get(Award.rookie),
        ['AAA', 'CCC'])
예제 #20
0
def test_third():
    eq_(compute_awards(MockScores(), FINAL_INFO, TEAMS).get(Award.third),
        ['AAA'])
예제 #21
0
def test_no_overrides_file():
    with mock.patch('os.path.exists') as test_file:
        test_file.return_value = False
        eq_(compute_awards(MockScores(), FINAL_INFO, TEAMS, '.').get(Award.third),
            ['AAA'])
예제 #22
0
def test_no_overrides_file():
    with mock.patch('os.path.exists') as test_file:
        test_file.return_value = False
        eq_(
            compute_awards(MockScores(), FINAL_INFO, TEAMS,
                           '.').get(Award.third), ['AAA'])
예제 #23
0
def test_tied_partial():
    eq_(compute_awards(MockScores(knockout={'AAA': 2, 'BBB': 1, 'CCC': 1, 'DDD': 1},
                                  knockout_dsq=()), FINAL_INFO, TEAMS).get(Award.first),
        ['AAA'])
예제 #24
0
def test_second_tiebreaker():
    scores = build_tiebreaker_scores()
    eq_(
        compute_awards(scores, TIEBREAKER_INFO, TEAMS).get(Award.second),
        ['AAA'])
예제 #25
0
def test_rookie():
    eq_(compute_awards(MockScores(), FINAL_INFO, TEAMS).get(Award.rookie),
        ['AAA'])