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('.')
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('.')
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'])
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.")
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'])
def test_rookie(): eq_( compute_awards(MockScores(), FINAL_INFO, TEAMS).get(Award.rookie), ['AAA'])
def test_second(): eq_( compute_awards(MockScores(), FINAL_INFO, TEAMS).get(Award.second), ['DDD'])
def test_third(): eq_( compute_awards(MockScores(), FINAL_INFO, TEAMS).get(Award.third), ['AAA'])
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'])
def test_first(): eq_( compute_awards(MockScores(), FINAL_INFO, TEAMS).get(Award.first), ['BBB'])
def test_first_tiebreaker(): scores = build_tiebreaker_scores() eq_( compute_awards(scores, TIEBREAKER_INFO, TEAMS).get(Award.first), ['BBB'])
def test_first_tiebreaker(): scores = build_tiebreaker_scores() eq_(compute_awards(scores, TIEBREAKER_INFO, TEAMS).get(Award.first), ['BBB'])
def test_second(): eq_(compute_awards(MockScores(), FINAL_INFO, TEAMS).get(Award.second), ['DDD'])
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('.')
def test_first(): eq_(compute_awards(MockScores(), FINAL_INFO, TEAMS).get(Award.first), ['BBB'])
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'])
def test_second_tiebreaker(): scores = build_tiebreaker_scores() eq_(compute_awards(scores, TIEBREAKER_INFO, TEAMS).get(Award.second), ['AAA'])
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('.')
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'])
def test_third(): eq_(compute_awards(MockScores(), FINAL_INFO, TEAMS).get(Award.third), ['AAA'])
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'])
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'])
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'])
def test_second_tiebreaker(): scores = build_tiebreaker_scores() eq_( compute_awards(scores, TIEBREAKER_INFO, TEAMS).get(Award.second), ['AAA'])
def test_rookie(): eq_(compute_awards(MockScores(), FINAL_INFO, TEAMS).get(Award.rookie), ['AAA'])