Skip to content

Commit

Permalink
Modify Knockout tests
Browse files Browse the repository at this point in the history
Modify `Knockout` tests so that playoff matches (incomplete levels of the binary tree) are played by the last participants.
  • Loading branch information
kostrykin committed Jan 31, 2024
1 parent 5c959cb commit 471567d
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions tournaments/tournaments/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,8 +730,8 @@ def test_create_fixtures_5participants(self):
# Verify fixtures.
actual_fixtures = self.group_fixtures_by_level(mode)
expected_fixtures = {
0: [(5, 1)],
1: [(None, 3), (4, 2)],
0: [(5, 4)],
1: [(None, 2), (3, 1)],
2: [(None, None)]
}
self.assertEqual(actual_fixtures, expected_fixtures)
Expand All @@ -745,12 +745,39 @@ def test_create_fixtures_6participants(self):
# Verify fixtures.
actual_fixtures = self.group_fixtures_by_level(mode)
expected_fixtures = {
0: [(5, 2), (6, 1)],
1: [(None, None), (4, 3)],
0: [(5, 4), (6, 3)],
1: [(None, None), (2, 1)],
2: [(None, None)]
}
self.assertEqual(actual_fixtures, expected_fixtures)

def test_create_fixtures_8participants(self):
mode = Knockout.objects.create(tournament = self.tournament)
mode.create_fixtures(self.participants[:8])

# Verify fixtures.
actual_fixtures = self.group_fixtures_by_level(mode)
expected_fixtures = {
0: [(5, 4), (6, 3), (7, 2), (8, 1)],
1: [(None, None), (None, None)],
2: [(None, None)]
}
self.assertEqual(actual_fixtures, expected_fixtures)

def test_create_fixtures_9participants(self):
mode = Knockout.objects.create(tournament = self.tournament)
mode.create_fixtures(self.participants[:9])

# Verify fixtures.
actual_fixtures = self.group_fixtures_by_level(mode)
expected_fixtures = {
0: [(9, 8)],
1: [(None, 4), (5, 3), (6, 2), (7, 1)],
2: [(None, None), (None, None)],
3: [(None, None)]
}
self.assertEqual(actual_fixtures, expected_fixtures)

def test_check_fixture(self):
mode = self.test_create_fixtures_2participants()
fixture = mode.fixtures.get()
Expand Down

0 comments on commit 471567d

Please sign in to comment.