Skip to content

Commit

Permalink
tests: more test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
DesiPilla committed Dec 20, 2023
1 parent c460343 commit 73bab47
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions tests/football/unit/test_league.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ def test_standings_weekly(self, m):
# final_standings = [team.team_id for team in league.standings()]
# self.assertEqual(week13_standings, final_standings)

# Test invalid playoff seeding rule
with self.assertRaises(Exception):
league.settings.playoff_seed_tie_rule = "NOT_A_REAL_RULE"
league.standings(week=1)

def get_list_of_team_data(self, league: League, week: int):
list_of_team_data = []
for team in league.teams:
Expand Down Expand Up @@ -233,10 +238,8 @@ def test_sort_functions(self, m):

league = League(self.league_id, self.season)

week1_teams_data = self.get_list_of_team_data(league, 1)
week10_teams_data = self.get_list_of_team_data(league, 10)
list_of_team_data = [
team for team in week10_teams_data if team["team_id"] in (1, 2)
]
division_record_dict = build_division_record_dict(week10_teams_data)

# Assert that sort_by_win_pct is correct
Expand All @@ -255,21 +258,32 @@ def test_sort_functions(self, m):
sorted_list_of_team_data[i + 1]["points_for"],
)

# Assert that sort_by_head_to_head is correct - 1 team
sorted_list_of_team_data = sort_by_head_to_head(week10_teams_data[:1].copy())
self.assertEqual(sorted_list_of_team_data == week10_teams_data[:1], True)

# Assert that sort_by_head_to_head is correct - 2 teams
sorted_list_of_team_data = sort_by_head_to_head(
[team for team in week10_teams_data if team["team_id"] in (1, 2)]
)
self.assertEqual(sorted_list_of_team_data[0]["team_id"], 1)

# Assert that sort_by_head_to_head is correct - 3 teams
# Assert that sort_by_head_to_head is correct - 3 teams, valid
sorted_list_of_team_data = sort_by_head_to_head(
[team for team in week10_teams_data if team["team_id"] in (1, 2, 3)]
)
# Team 1 is undefeated vs team 2
self.assertEqual(sorted_list_of_team_data[0]["team_id"], 1)
self.assertEqual(sorted_list_of_team_data[1]["team_id"], 3)
self.assertEqual(sorted_list_of_team_data[2]["team_id"], 2)

# Assert that sort_by_head_to_head is correct - 3 teams, invalid
sorted_list_of_team_data = sort_by_head_to_head(
[team for team in week1_teams_data if team["team_id"] in (1, 2, 3)]
)
self.assertEqual(sorted_list_of_team_data[0]["h2h_wins"], 0)
self.assertEqual(sorted_list_of_team_data[1]["h2h_wins"], 0)
self.assertEqual(sorted_list_of_team_data[2]["h2h_wins"], 0)

# Assert that sort_by_division_record is correct
sorted_list_of_team_data = sort_by_division_record(week10_teams_data)
for i in range(len(sorted_list_of_team_data) - 1):
Expand Down

0 comments on commit 73bab47

Please sign in to comment.