Add Tournaments UI (#32)
Co-authored-by: David Rodenkirchen <drodenkirchen@linetco.com> Reviewed-on: #32
This commit was merged in pull request #32.
This commit is contained in:
@@ -9,29 +9,30 @@ class TournamentDomainTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
# Generic Tournament config
|
||||
self.name = "Tetris 1vs1"
|
||||
self.game_title = GameTitle("Tetris99", "Some Description", "https://de.wikipedia.org/wiki/Tetris_99")
|
||||
self.description = "Just play Tetris, yo"
|
||||
self.game_title = GameTitle("Tetris99", "Some Description", "https://de.wikipedia.org/wiki/Tetris_99", "tetris.png")
|
||||
self.format_ = TournamentFormat.SINGLE_ELIMINATION_BO_3
|
||||
self.start_time = datetime(year=2100, month=6, day=23, hour=16, minute=30, second=0)
|
||||
self.initial_status = TournamentStatus.CLOSED
|
||||
|
||||
# Generic Participants
|
||||
self.participant_a = Participant(1, "CoolUserName", ParticipantType.PLAYER)
|
||||
self.participant_b = Participant(2, "CrazyUserName", ParticipantType.PLAYER)
|
||||
self.participant_c = Participant(3, "FunnyUserName", ParticipantType.PLAYER)
|
||||
self.participant_a = Participant(1, ParticipantType.PLAYER)
|
||||
self.participant_b = Participant(2, ParticipantType.PLAYER)
|
||||
self.participant_c = Participant(3, ParticipantType.PLAYER)
|
||||
|
||||
def test_tournament_without_participants_can_not_be_started(self) -> None:
|
||||
tournament_under_test = generate_new_tournament(self.name, self.game_title, self.format_, self.start_time, self.initial_status)
|
||||
tournament_under_test = generate_new_tournament(self.name, self.description, self.game_title, self.format_, self.start_time, 32, self.initial_status)
|
||||
with self.assertRaises(TournamentError):
|
||||
tournament_under_test.start()
|
||||
|
||||
def test_adding_the_same_participant_twice_leads_to_exception(self) -> None:
|
||||
tournament_under_test = generate_new_tournament(self.name, self.game_title, self.format_, self.start_time, self.initial_status)
|
||||
tournament_under_test = generate_new_tournament(self.name, self.description, self.game_title, self.format_, self.start_time, 32, self.initial_status)
|
||||
tournament_under_test.add_participant(self.participant_a)
|
||||
with self.assertRaises(TournamentError):
|
||||
tournament_under_test.add_participant(self.participant_a)
|
||||
|
||||
def test_single_elimination_bo3_tournament_gets_generated_correctly(self) -> None:
|
||||
tournament_under_test = generate_new_tournament(self.name, self.game_title, self.format_, self.start_time, self.initial_status)
|
||||
tournament_under_test = generate_new_tournament(self.name, self.description, self.game_title, self.format_, self.start_time, 32, self.initial_status)
|
||||
|
||||
tournament_under_test.add_participant(self.participant_a)
|
||||
tournament_under_test.add_participant(self.participant_b)
|
||||
@@ -63,4 +64,19 @@ class TournamentDomainTests(unittest.TestCase):
|
||||
self.assertEqual(sm.status, MatchStatus.WAITING)
|
||||
self.assertEqual(sm.participants[0].participant_id, self.participant_c.id)
|
||||
self.assertEqual(sm.participants[0].slot_number, 1)
|
||||
self.assertIsNone(sm.winner)
|
||||
self.assertIsNone(sm.winner)
|
||||
|
||||
def test_ffa_tournament_with_15_participants_gets_generated_correctly(self) -> None:
|
||||
tournament_under_test = generate_new_tournament("Among Us", "It's Among Us", GameTitle("Among Us", "", "", ""), TournamentFormat.FFA, self.start_time, 32, TournamentStatus.OPEN)
|
||||
|
||||
for i in range(1, 16):
|
||||
tournament_under_test.add_participant(Participant(i, ParticipantType.PLAYER))
|
||||
tournament_under_test.start()
|
||||
|
||||
# Assert Tournament was switched to ONGOING
|
||||
self.assertEqual(TournamentStatus.ONGOING, tournament_under_test.status)
|
||||
|
||||
matches_in_tournament = sorted(tournament_under_test.matches, key=lambda m: m.match_id)
|
||||
|
||||
self.assertEqual(1, len(matches_in_tournament))
|
||||
self.assertEqual(15, len(matches_in_tournament[0].participants))
|
||||
|
||||
Reference in New Issue
Block a user