Esempio n. 1
0
    def test_cannot_assign_score_without_code(self):
        _, _, ballot = self.add_one_matchup_w_judge()

        result = schema.execute(f"""
                mutation openingScore {{
                    assignSpeechScore(ballot: {ballot}, side: PL, speech: OPENING, score: 10)
                }}
            """)
        self.assertIsNotNone(result.errors)

        result = schema.execute(f"""
                mutation examinationScore {{
                    assignExamScore(ballot: {ballot}, side: PL, exam: 1, witness: true, cross: true, score: 10)
                }}
            """)
        self.assertIsNotNone(result.errors)
Esempio n. 2
0
    def assertSchoolContainsTeam(self, school, team_num, team_name):
        result = schema.execute(
            f"""
            query numTeams {{
                tournament(id: {self.tourn_id}) {{
                school(name: "{school}") {{
                    teams {{
                    num
                    name
                    }}
                }}
                }}
            }}
            """
        )
        teams = result.data["tournament"]["school"]["teams"]
        has_team = any(
            team["name"] == team_name and team["num"] == team_num for team in teams
        )

        team_ids = ", ".join(str(team["num"]) for team in teams)
        self.assertTrue(
            has_team,
            f"Team {team_num} not found. Team numbers: {team_ids} (also check the names)",
        )
Esempio n. 3
0
    def assertStudentHasRole(self, student_id, role, matchup, side):
        result = schema.execute(
            f"""
            query getRole {{
                tournament(id: {self.tourn_id}) {{
                    matchup(id: {matchup}) {{
                        team(side: {side}) {{
                            attorney(role: {role}) {{
                                student {{
                                    id
                                }}
                            }}
                        }}
                    }}
                }}
            }}
            """
        )

        role = result.data["tournament"]["matchup"]["team"]["attorney"]
        if student_id is None:
            self.assertIsNone(role)
        else:
            student_in_role = role["student"]
            self.assertIsNotNone(student_in_role, f"No student assigned to {role}")
            self.assertEqual(
                student_in_role["id"],
                student_id,
                f"Student {student_id} does not have role {role}",
            )
Esempio n. 4
0
    def assertHasMatchup(self, matchup_id, pl_num, def_num):
        result = schema.execute(
            f"""
            query matchupTest {{
                tournament(id: {self.tourn_id}) {{
                    matchup(id: {matchup_id}) {{
                        pl {{
                            team {{
                                num
                            }}
                        }}
                        def {{
                            team {{
                                num
                            }}
                        }}
                    }}
                }}
            }}
            """
        )

        matchup = result.data["tournament"]["matchup"]

        self.assertEqual(matchup["pl"]["team"]["num"], pl_num, "π num does not match")
        self.assertEqual(matchup["def"]["team"]["num"], def_num, "∆ num does not match")
Esempio n. 5
0
    def test_matchup_teams_are_fully_explorable(self):
        matchup = self.add_one_matchup_setup()
        result = schema.execute(
            f"""
            query teamMatchups {{
                tournament(id: {self.tourn_id}) {{
                    matchup(id: {matchup}) {{
                        pl {{
                            team {{
                                num
                                name
                            }}
                        }}
                        def {{
                            team {{
                                num
                                name
                            }}
                        }}
                    }}
                }}
            }}
            """
        )

        match = result.data['tournament']['matchup']
        pl = match['pl']['team']
        self.assertEqual(pl['num'], 1001)
        self.assertEqual(pl['name'], "Midlands University A")

        de = match['def']['team']
        self.assertEqual(de['num'], 1101)
        self.assertEqual(de['name'], "Midlands State University A")
 def add_judge_conflict(self, judge_id, school):
     result = schema.execute(f"""
         mutation addConflict {{
             addJudgeConflict(tournamentId: {self.tourn_id}, judgeId: {judge_id}, school: "{school}") {{
                 id
             }}
         }}
         """)
    def assign_exam_score(self, ballot, side, exam, witness, cross, score):
        result = schema.execute(
            f"""
                mutation addWitnessScore {{
                    {self._exam_assignment(ballot, side, exam, witness, cross, score)}
                }}
            """, None, FakeInfo)

        return result.data['assignExamScore']
    def assign_speech_notes(self, ballot, side, speech, notes):
        result = schema.execute(f"""
            mutation assignNotes($notes: String!) {{
                assignSpeechNotes(ballot: {ballot}, side: {side}, speech: {speech}, notes: $notes)
            }}
        """,
                                variable_values={"notes": notes})

        return result.data['assignSpeechNotes']
    def assign_exam_notes(self, ballot, side, exam, witness, cross, notes):
        result = schema.execute(f"""
            mutation assignExamNotes($notes: String!) {{
                assignExamNotes(ballot: {ballot}, side: {side}, exam: {exam}, witness: {self._to_GQL_bool(witness)}, cross: {self._to_GQL_bool(cross)}, notes: $notes)
            }}
        """,
                                variable_values={"notes": notes})

        return result.data['assignExamNotes']
 def set_matchup_notes(self, matchup, notes):
     result = schema.execute(f"""
         mutation assignNotes($notes: String!) {{
             assignMatchupNotes(tournament: {self.tourn_id}, matchup: {matchup}, notes: $notes) {{
                 notes
             }}
         }}
     """,
                             variable_values={"notes": notes})
    def complete_ballot(self, ballot):
        result = schema.execute(f"""
            mutation completeBallot {{
                completeBallot(tournament: {self.tourn_id}, ballot: {ballot}) {{
                    complete
                }}
            }}
        """)

        return result.data['completeBallot']
    def assign_full_round(self, ballot, pd):
        pl_scores = chain(repeat(10, pd), repeat(9))
        def_scores = repeat(9)

        side_scores = {"PL": pl_scores, "DEF": def_scores}

        def speech_assignment(side, speech):
            return self._speech_assignment(ballot, side, speech,
                                           next(side_scores[side]))

        def exam_assignment(side, exam, witness, cross):
            return self._exam_assignment(ballot, side, exam, witness, cross,
                                         next(side_scores[side]))

        def pl_full_exam(exam):
            return f"""
                wDir{exam}: {exam_assignment("PL", exam, True, False)}
                aDir{exam}: {exam_assignment("PL", exam, False, False)}
                wCr{exam}: {exam_assignment("PL", exam, True, True,)}
                aCr{exam}: {exam_assignment("DEF", exam, False, True)}
            """

        def def_full_exam(exam):
            return f"""
                dWDir{exam}: {exam_assignment("DEF", exam, True, False,)}
                dADir{exam}: {exam_assignment("DEF", exam, False, False)}
                dWCr{exam}: {exam_assignment("DEF", exam, True, True)}
                dACr{exam}: {exam_assignment("PL", exam, False, True)}
            """

        new_line = "\n"

        schema.execute(
            f"""
            mutation fullRound {{
                pOpen: {speech_assignment("PL", "OPENING")}
                dOpen: {speech_assignment("DEF", "OPENING")}
                {new_line.join(pl_full_exam(exam) for exam in range(1, 4))}
                {new_line.join(def_full_exam(exam) for exam in range(1, 4))}
                pClose: {speech_assignment("PL", "CLOSING")}
                dClose: {speech_assignment("DEF", "CLOSING")}
            }}
            """, None, FakeInfo)
    def assign_speech_score(self, ballot, side, speech, score):
        result = schema.execute(
            f"""
            mutation openingScore {{
                {self._speech_assignment(ballot, side, speech, score)}
            }}
            """, None, FakeInfo)

        score = result.data['assignSpeechScore']

        return score
    def add_school_to_tournament(self, name):
        result = schema.execute(f"""
            mutation addSchool {{
                addSchool(tournament: {self.tourn_id}, name: "{name}") {{
                    name
                }}
            }}
            """)

        new_school_data = result.data["addSchool"]

        return new_school_data
    def get_matchup_notes(self, matchup):
        result = schema.execute(f"""
            query getMatchupNotes {{
                tournament(id: {self.tourn_id}) {{
                    matchup(id: {matchup}) {{
                        notes
                    }}
                }}
            }}
        """)

        return result.data['tournament']['matchup']['notes']
Esempio n. 16
0
    def get_all_tournaments(self):
        result = schema.execute(
            f"""
            query getTournaments {{
                tournaments {{
                id
                name
                }}
            }}
            """
        )

        return result.data["tournaments"]
    def add_judge_to_tournament(self, name):
        result = schema.execute(f"""
            mutation addJudge {{
                addJudge(tournamentId: {self.tourn_id}, name: "{name}") {{
                    id
                    name
                }}
            }}
            """)

        new_judge = result.data["addJudge"]

        return new_judge
    def create_tournament(self):
        result = schema.execute("""
            mutation makeTournament {
                addTournament(name: "Test Tournament") {
                    id 
                    name
                }
            }
            """)
        new_tourn_data = result.data["addTournament"]
        self.tourn_id = new_tourn_data["id"]

        return new_tourn_data
Esempio n. 19
0
    def assertSpeechHasNotes(self, ballot, side, speech, notes):
        result = schema.execute(f"""
            query getOpeningNote {{
                tournament(id: {self.tourn_id}) {{
                    ballot(id: {ballot}) {{
                        side(side: {side}) {{
                            speechNotes(speech: {speech})
                        }}
                    }}
                }}
            }}
        """)

        self.assertEqual(result.data['tournament']['ballot']['side']['speechNotes'], notes)
    def assign_witness_name(self, matchup, side, order, name):
        result = schema.execute(f"""
            mutation assignWitnessName {{
                assignWitnessName(tournament: {self.tourn_id}, matchup: {matchup}, side: {side}, order: {order}, witness: "{name}") {{
                    matchup {{
                        id
                    }}
                    witnessName
                }}
            }}
            """)

        assignment = result.data['assignWitnessName']

        return assignment
Esempio n. 21
0
    def test_can_delete_ballot(self):
        matchup, judge, ballot = self.add_one_matchup_w_judge()

        result = schema.execute(
            f"""
                mutation deleteBallot {{
                    deleteBallot(id: {ballot})
                }}
            """
        )

        self.assertIsNone(result.errors)

        self.assertJudgeHasBallot(judge, ballot, should_have_ballot=False)
        self.assertMatchupHasBallot(matchup, ballot, should_have_ballot=False)
Esempio n. 22
0
    def test_can_assign_presiding_ballots(self):
        match = self.add_one_matchup_setup()
        judge = self.add_judge_to_tournament("John G. Roberts, Jr.")['id']

        result = schema.execute(
            f"""
                mutation assignBallot {{
                    assignJudgeToMatchup(tournament: {self.tourn_id}, judge: {judge}, matchup: {match}, presiding: true) {{
                        presiding
                    }}
                }}
            """
        )

        self.assertEqual(result.data['assignJudgeToMatchup']['presiding'], True)
    def get_judge_info(self, judge_id):
        result = schema.execute(f"""
            query getJudge {{
                tournament(id: {self.tourn_id}) {{
                    judge(id: {judge_id}) {{
                        id
                        name
                        email
                    }}
                }}
            }}
            """)

        judge = result.data["tournament"]["judge"]

        return judge
    def add_team_to_tournament(self, team_num, school, team_name):
        result = schema.execute(f"""
            mutation addTeam {{
                addTeam(tournament: {self.tourn_id}, school: "{school}", num: {team_num}, name: "{team_name}") {{
                    num
                    name

                    schoolName
                    tournamentId
                }}
            }}
            """)

        new_team = result.data["addTeam"]

        return new_team
Esempio n. 25
0
    def assertBallotHasPD(self, ballot, side, pd):
        result = schema.execute(
            f"""
            query getPD {{
                tournament(id: {self.tourn_id}) {{
                    ballot(id: {ballot}) {{
                        pd(side: {side})
                    }}
                }}
            }}
            """
        )

        true_pd = result.data['tournament']['ballot']['pd']

        self.assertEqual(pd, true_pd)
Esempio n. 26
0
    def assertHasRound(self, round_num):
        result = schema.execute(
            f"""
            query roundInTournament {{
                tournament(id: {self.tourn_id}) {{
                    round(num: {round_num}) {{
                        roundNum
                    }}
                }}
            }}
            """
        )

        found_round = result.data['tournament']['round']

        self.assertEqual(found_round['roundNum'], round_num)
Esempio n. 27
0
    def assertBallotIsDone(self, ballot, done=True):
        result = schema.execute(
            f"""
            query ballotIsDone {{
                tournament(id: {self.tourn_id}) {{
                    ballot(id: {ballot}) {{
                        complete
                    }}
                }}
            }}
            """
        )

        is_complete = result.data['tournament']['ballot']['complete']
        
        self.assertEqual(done, is_complete)
Esempio n. 28
0
    def test_can_toggle_note_only(self):
        matchup, judge, ballot = self.add_one_matchup_w_judge()

        result = schema.execute(
            f"""
                mutation noteOnly {{
                    noteOnlyBallot(id: {ballot}, noteOnly: true) {{
                        id
                        noteOnly
                    }}
                }}
            """
        )

        ballot_info = result.data['noteOnlyBallot']
        self.assertEqual(ballot_info['noteOnly'], True)
Esempio n. 29
0
    def test_matchup_gives_round_num(self):
        [matchup, _] = self.add_default_r1_setup()
        result = schema.execute(
            f"""
            query teamMatchups {{
                tournament(id: {self.tourn_id}) {{
                    matchup(id: {matchup}) {{
                        roundNum
                    }}
                }}
            }}
            """
        )

        round_num = result.data['tournament']['matchup']['roundNum']

        self.assertEqual(round_num, 1)
Esempio n. 30
0
    def assign_notes(self, matchup, notes):
        result = schema.execute(
            f"""
                mutation setMatchupNotes {{
                    assignMatchupNotes(tournament: {self.tourn_id}, matchup: {matchup}, notes: "{notes}") {{
                        matchup {{
                            id
                        }}
                        notes
                    }}
                }}
            """
        )

        result = result.data['assignMatchupNotes']

        return result