def setUp(self): super(RandomDrawTests, self).setUp() self.round = Round(tournament=self.tournament, seq=2, draw_type=Round.DRAW_RANDOM) self.round.save() activate_all(self.round)
class TestAdjudicatorDisable(BaseDebateTestCase): def setUp(self): super(TestAdjudicatorDisable, self).setUp() self.round = Round(tournament=self.t, seq=1) self.round.save() self.activate_all_adj(self.round) adj = Adjudicator.objects.get(name="Adjudicator00") self.round.activate_adjudicator(adj, False) def test_objects(self): self.failUnlessEqual(8, Adjudicator.objects.count()) def test_active(self): self.failUnlessEqual(7, self.round.active_adjudicators.count())
class RandomDrawTests(BaseDebateTestCase): def setUp(self): super(RandomDrawTests, self).setUp() self.round = Round(tournament=self.t, seq=2, draw_type=Round.DRAW_RANDOM) self.round.save() activate_all(self.round) def test_std(self): DrawManager(self.round).create() self.assertEqual(6, self.round.debate_set.count()) self.assertEqual(12, DebateTeam.objects.filter(debate__round=self.round).count()) for team in Team.objects.all(): self.assertEqual(1, DebateTeam.objects.filter(team=team).count())
def auto_make_break_rounds(bc, tournament=None, prefix=False): if tournament is None: tournament = bc.tournament num_rounds = tournament.round_set.all().aggregate(Max('seq'))['seq__max'] round_names = get_break_category_round_names(bc) if prefix else BREAK_ROUND_NAMES # Translators: "UBR" stands for "unknown break round" (used as a fallback when we don't know what it's called) unknown_round = (_("Unknown %s break round") % (bc.name), _("U%sBR") % (bc.name[:1])) if prefix \ else (_("Unknown break round"), _("UBR")) break_rounds = itertools.chain(round_names, itertools.repeat(unknown_round)) for i, (name, abbr) in zip(range(bc.num_break_rounds), break_rounds): Round( tournament=tournament, break_category=bc, seq=num_rounds+bc.num_break_rounds-i, stage=Round.STAGE_ELIMINATION, name=name, abbreviation=abbr, draw_type=Round.DRAW_ELIMINATION, feedback_weight=0.5, silent=True, ).save()
def setUp(self): super(RandomDrawTests, self).setUp() self.round = Round(tournament=self.t, seq=2, draw_type=Round.DRAW_RANDOM) self.round.save() self.activate_all_adj(self.round) self.activate_all_teams(self.round) self.activate_venues(self.round)
def setUp(self): super(TestAdjudicatorDisable, self).setUp() self.round = Round(tournament=self.t, seq=1) self.round.save() self.activate_all_adj(self.round) adj = Adjudicator.objects.get(name="Adjudicator00") self.round.activate_adjudicator(adj, False)
class RandomDrawTests(BaseDebateTestCase): def setUp(self): super(RandomDrawTests, self).setUp() self.round = Round(tournament=self.t, seq=2, draw_type=Round.DRAW_RANDOM) self.round.save() self.activate_all_adj(self.round) self.activate_all_teams(self.round) self.activate_venues(self.round) def test_std(self): self.round.draw() self.failUnlessEqual(6, Debate.objects.count()) self.failUnlessEqual(12, DebateTeam.objects.count()) for team in Team.objects.all(): self.failUnlessEqual(1, DebateTeam.objects.filter(team=team).count())
class RandomDrawTests(BaseMinimalTournamentTestCase): def setUp(self): super(RandomDrawTests, self).setUp() self.round = Round(tournament=self.tournament, seq=2, draw_type=Round.DRAW_RANDOM) self.round.save() activate_all(self.round) def test_std(self): DrawManager(self.round).create() self.assertEqual(6, self.round.debate_set.count()) self.assertEqual( 12, DebateTeam.objects.filter(debate__round=self.round).count()) for team in Team.objects.all(): self.assertEqual(1, DebateTeam.objects.filter(team=team).count())
class TestAvailability(BaseDebateTestCase): def setUp(self): super().setUp() self.round = Round(tournament=self.t, seq=1) self.round.save() def tearDown(self): super().tearDown() self.round.delete() def test_all_active(self): set_availability(Adjudicator.objects.all(), self.round) self.assertEqual(8, Adjudicator.objects.count()) self.assertEqual(8, self.round.active_adjudicators.count()) def test_one_disabled(self): set_availability(Adjudicator.objects.exclude(name="Adjudicator00"), self.round) self.assertEqual(8, Adjudicator.objects.count()) self.assertEqual(7, self.round.active_adjudicators.count()) def test_activate_all(self): Adjudicator.objects.create( institution=Institution.objects.get(code="INS0"), name="Unattached") self.t.preferences['league_options__share_adjs'] = False self.t.preferences['league_options__share_venues'] = False activate_all(self.round) self.assertEqual(8, self.round.active_adjudicators.count()) self.assertEqual(12, self.round.active_teams.count()) self.assertEqual(8, self.round.active_venues.count()) def test_activate_relevant(self): Adjudicator.objects.create( institution=Institution.objects.get(code="INS0"), name="Unattached") self.t.preferences['league_options__share_adjs'] = True self.t.preferences['league_options__share_venues'] = True activate_all(self.round) self.assertEqual(9, self.round.active_adjudicators.count()) self.assertEqual(12, self.round.active_teams.count()) self.assertEqual(16, self.round.active_venues.count())
class TestAvailability(BaseDebateTestCase): def setUp(self): super().setUp() self.round = Round(tournament=self.t, seq=1) self.round.save() def tearDown(self): super().tearDown() self.round.delete() def test_all_active(self): set_availability(Adjudicator.objects.all(), self.round) self.assertEqual(8, Adjudicator.objects.count()) self.assertEqual(8, self.round.active_adjudicators.count()) def test_one_disabled(self): set_availability(Adjudicator.objects.exclude(name="Adjudicator00"), self.round) self.assertEqual(8, Adjudicator.objects.count()) self.assertEqual(7, self.round.active_adjudicators.count()) def test_activate_all(self): Adjudicator.objects.create(institution=Institution.objects.get(code="INS0"), name="Unattached") self.t.preferences['league_options__share_adjs'] = False self.t.preferences['league_options__share_venues'] = False activate_all(self.round) self.assertEqual(8, self.round.active_adjudicators.count()) self.assertEqual(12, self.round.active_teams.count()) self.assertEqual(8, self.round.active_venues.count()) def test_activate_relevant(self): Adjudicator.objects.create(institution=Institution.objects.get(code="INS0"), name="Unattached") self.t.preferences['league_options__share_adjs'] = True self.t.preferences['league_options__share_venues'] = True activate_all(self.round) self.assertEqual(9, self.round.active_adjudicators.count()) self.assertEqual(12, self.round.active_teams.count()) self.assertEqual(16, self.round.active_venues.count())
def import_debates(self): self.debates = {} self.debateteams = {} self.debateadjudicators = {} rounds = [] for i, round in enumerate(self.root.findall('round'), 1): round_stage = Round.STAGE_ELIMINATION if round.get('elimination', 'false') == 'true' else Round.STAGE_PRELIMINARY draw_type = Round.DRAW_ELIMINATION if round_stage == Round.STAGE_ELIMINATION else Round.DRAW_MANUAL round_obj = Round( tournament=self.tournament, seq=i, completed=True, name=round.get('name'), abbreviation=round.get('abbreviation', round.get('name')[:10]), stage=round_stage, draw_type=draw_type, draw_status=Round.STATUS_RELEASED, feedback_weight=round.get('feedback-weight', 0), starts_at=round.get('start')) rounds.append(round_obj) if round.find('debate') is None: round_obj.completed = False if round.find('debate/side/ballot') is None: round_obj.draw_status = Round.STATUS_NONE if round_stage == Round.STAGE_ELIMINATION: round_obj.break_category = self.team_breaks.get(round.get('break-category')) round_obj.save() side_start = 2 if self.is_bp else 0 for debate in round.findall('debate'): debate_obj = Debate(round=round_obj, venue=self.venues.get(debate.get('venue')), result_status=Debate.STATUS_CONFIRMED) debate_obj.save() self.debates[debate.get('id')] = debate_obj # Debate-teams for i, side in enumerate(debate.findall('side'), side_start): position = DebateTeam.SIDE_CHOICES[i][0] debateteam_obj = DebateTeam(debate=debate_obj, team=self.teams[side.get('team')], side=position) debateteam_obj.save() self.debateteams[(debate.get('id'), side.get('team'))] = debateteam_obj # Debate-adjudicators voting_adjs = self._get_voting_adjs(debate) for adj in debate.get('adjudicators').split(): adj_type = DebateAdjudicator.TYPE_PANEL if adj in voting_adjs else DebateAdjudicator.TYPE_TRAINEE if debate.get('chair') == adj: adj_type = DebateAdjudicator.TYPE_CHAIR adj_obj = DebateAdjudicator(debate=debate_obj, adjudicator=self.adjudicators[adj], type=adj_type) adj_obj.save() self.debateadjudicators[(debate.get('id'), adj)] = adj_obj
def setUp(self): super().setUp() self.round = Round(tournament=self.t, seq=1) self.round.save()