Пример #1
0
def test_week3_assign_playoff_matchups_top6(home_wins: bool):
    previous_week = ScheduleWeek(week_number=0, week_type=WeekType.REGULAR)
    playoffs = generate_playoffs(teams,
                                 PlayoffType.TOP_6,
                                 first_playoff_week=2,
                                 enable_loser_playoff=False)
    week1 = playoffs[0]
    # setup week 1
    week1.assign_playoff_matchups(PlayoffType.TOP_6, teams, previous_week)

    for matchup in week1.matchups:
        if matchup.type != MatchupType.PLAYOFF_BYE:
            matchup.home_score = 100 if home_wins else 0
            matchup.away_score = 100 if not home_wins else 0

    week2 = playoffs[1]
    week2.assign_playoff_matchups(PlayoffType.TOP_6, teams, week1)

    for matchup in week2.matchups:
        matchup.home_score = 100 if home_wins else 0
        matchup.away_score = 100 if not home_wins else 0

    week3 = playoffs[2]
    week3.assign_playoff_matchups(PlayoffType.TOP_6, teams, week2)

    matchup = week3.matchups[0]
    if home_wins:
        are_equal(team_1.id, matchup.home.id)
        are_equal(team_2.id, matchup.away.id)
    else:
        are_equal(team_5.id, matchup.home.id)
        are_equal(team_6.id, matchup.away.id)
Пример #2
0
def test_week1_assign_playoff_matchups_top6_no_loser_game(team_count: int):
    rosters = teams[0:team_count]

    previous_week = ScheduleWeek(week_number=0, week_type=WeekType.REGULAR)
    weeks = generate_playoffs(team_count,
                              PlayoffType.TOP_6,
                              first_playoff_week=2,
                              enable_loser_playoff=False)
    week1 = weeks[0]
    week1.assign_playoff_matchups(PlayoffType.TOP_6, rosters, previous_week)

    matchup1 = week1.matchups[0]
    are_equal(team_6, matchup1.away)
    are_equal(team_3, matchup1.home)

    matchup2 = week1.matchups[1]
    are_equal(team_5, matchup2.away)
    are_equal(team_4, matchup2.home)

    matchup3 = week1.matchups[2]
    are_equal(None, matchup3.away)
    are_equal(team_1, matchup3.home)

    matchup4 = week1.matchups[3]
    are_equal(None, matchup4.away)
    are_equal(team_2, matchup4.home)
Пример #3
0
def test_week1_assign_playoff_matchups_top2_no_loser_game(team_count: int):
    rosters = teams[0:team_count]

    previous_week = ScheduleWeek(week_number=0, week_type=WeekType.REGULAR)
    playoffs = generate_playoffs(team_count,
                                 PlayoffType.TOP_2,
                                 first_playoff_week=2,
                                 enable_loser_playoff=False)
    week = playoffs[0]
    week.assign_playoff_matchups(PlayoffType.TOP_2, rosters, previous_week)

    championship = week.matchups[0]
    are_equal(team_2, championship.away)
    are_equal(team_1, championship.home)
Пример #4
0
def test_week1_assign_playoff_matchups_top3_loser_game(team_count: int):
    rosters = teams[0:team_count]

    previous_week = ScheduleWeek(week_number=0, week_type=WeekType.REGULAR)
    playoffs = generate_playoffs(team_count,
                                 PlayoffType.TOP_3,
                                 first_playoff_week=2,
                                 enable_loser_playoff=True)
    week = playoffs[0]
    week.assign_playoff_matchups(PlayoffType.TOP_3, rosters, previous_week)

    loser_game = week.matchups[2]
    last_place = rosters[-1]
    second_last = rosters[-2]
    are_equal(last_place, loser_game.away)
    are_equal(second_last, loser_game.home)
Пример #5
0
def test_week1_assign_playoff_matchups_top3_no_loser_game(team_count: int):
    rosters = teams[0:team_count]

    previous_week = ScheduleWeek(week_number=0, week_type=WeekType.REGULAR)
    weeks = generate_playoffs(team_count,
                              PlayoffType.TOP_3,
                              first_playoff_week=2,
                              enable_loser_playoff=False)
    week1 = weeks[0]
    week1.assign_playoff_matchups(PlayoffType.TOP_3, rosters, previous_week)

    matchup = week1.matchups[0]
    are_equal(team_3, matchup.away)
    are_equal(team_2, matchup.home)

    bye = week1.matchups[1]
    are_equal(None, bye.away)
    are_equal(team_1, bye.home)