From 6a7c7ae0cf7145f1ec61a222d81872175565a111 Mon Sep 17 00:00:00 2001 From: Joey Greco <57115019+joeyagreco@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:49:40 -0400 Subject: [PATCH] Devex Improvements (#120) - Use Ruff as a formatter - General Makefile improvements --- .github/dependabot.yml | 6 +- .github/workflows/unit-tests.yml | 12 +- Makefile | 27 +- e2e/variables.py | 24 +- example/league/comparingLeagueObjects.py | 4 +- example/league/manualLeagueBuildingExample.py | 24 +- example/league/yearSettings.py | 4 +- .../league_loader/espnLeagueLoaderExample.py | 4 +- .../myFantasyLeagueLeagueLoaderExample.py | 4 +- .../league_loader/yahooLeagueLoaderExample.py | 6 +- example/stat/gettingStatsAllTimeExample.py | 18 +- example/stat/gettingStatsForYearExample.py | 30 +- .../AWALAllTimeCalculator.py | 11 +- .../GameOutcomeAllTimeCalculator.py | 27 +- .../PlusMinusAllTimeCalculator.py | 8 +- .../PointsScoredAllTimeCalculator.py | 22 +- .../SSLAllTimeCalculator.py | 46 +- .../ScoringShareAllTimeCalculator.py | 41 +- ...oringStandardDeviationAllTimeCalculator.py | 8 +- .../SmartWinsAllTimeCalculator.py | 42 +- .../TeamSummaryAllTimeCalculator.py | 8 +- .../all_time_calculator/__init__.py | 4 +- leeger/calculator/parent/AllTimeCalculator.py | 59 +- leeger/calculator/parent/YearCalculator.py | 14 +- .../year_calculator/AWALYearCalculator.py | 26 +- .../GameOutcomeYearCalculator.py | 39 +- .../PlusMinusYearCalculator.py | 13 +- .../PointsScoredYearCalculator.py | 21 +- .../year_calculator/SSLYearCalculator.py | 30 +- .../ScoringShareYearCalculator.py | 16 +- .../ScoringStandardDeviationYearCalculator.py | 8 +- .../SmartWinsYearCalculator.py | 39 +- leeger/calculator/year_calculator/__init__.py | 4 +- leeger/decorator/validators.py | 7 +- leeger/league_loader/ESPNLeagueLoader.py | 57 +- .../league_loader/FleaflickerLeagueLoader.py | 41 +- leeger/league_loader/LeagueLoader.py | 16 +- .../MyFantasyLeagueLeagueLoader.py | 49 +- leeger/league_loader/SleeperLeagueLoader.py | 128 +- leeger/league_loader/YahooLeagueLoader.py | 52 +- leeger/model/abstract/EqualityCheck.py | 3 +- leeger/model/filter/AllTimeFilters.py | 18 +- leeger/model/filter/YearFilters.py | 14 +- leeger/model/league/Division.py | 4 +- leeger/model/league/League.py | 12 +- leeger/model/league/Matchup.py | 10 +- leeger/model/league/Owner.py | 4 +- leeger/model/league/Team.py | 8 +- leeger/model/league/Week.py | 8 +- leeger/model/league/Year.py | 17 +- leeger/model/league/YearSettings.py | 4 +- leeger/model/league_helper/Performance.py | 8 +- leeger/model/stat/AllTimeStatSheet.py | 4 +- leeger/model/stat/YearStatSheet.py | 4 +- leeger/util/ConfigReader.py | 6 +- leeger/util/GeneralUtil.py | 8 +- leeger/util/equality.py | 4 +- leeger/util/excel.py | 13 +- leeger/util/excel_helper.py | 23 +- leeger/util/navigator/LeagueNavigator.py | 28 +- leeger/util/navigator/WeekNavigator.py | 8 +- leeger/util/navigator/YearNavigator.py | 31 +- leeger/util/stat_sheet.py | 82 +- leeger/validate/divisionValidation.py | 4 +- leeger/validate/leagueValidation.py | 8 +- leeger/validate/matchupValidation.py | 8 +- leeger/validate/weekValidation.py | 8 +- leeger/validate/yearValidation.py | 66 +- pyproject.toml | 15 +- requirements.dev.txt | 5 +- setup.py | 4 +- .../test_AWALAllTimeCalculator.py | 1282 +++++++++++---- .../test_GameOutcomeAllTimeCalculator.py | 1432 +++++++++++++---- .../test_PlusMinusAllTimeCalculator.py | 16 +- .../test_PointsScoredAllTimeCalculator.py | 50 +- .../test_SSLAllTimeCalculator.py | 236 ++- .../test_ScoringShareAllTimeCalculator.py | 566 +++++-- ...oringStandardDeviationAllTimeCalculator.py | 108 +- .../test_SingleScoreAllTimeCalculator.py | 30 +- .../test_SmartWinsAllTimeCalculator.py | 870 +++++++--- .../test_TeamSummaryAllTimeCalculator.py | 370 +++-- .../test_AWALYearCalculator.py | 862 +++++++--- .../test_GameOutcomeYearCalculator.py | 901 ++++++++--- .../test_PlusMinusYearCalculator.py | 92 +- .../test_PointsScoredYearCalculator.py | 390 +++-- .../test_SSLYearCalculator.py | 232 ++- .../test_ScoringShareYearCalculator.py | 386 +++-- ..._ScoringStandardDeviationYearCalculator.py | 104 +- .../test_SingleScoreYearCalculator.py | 306 +++- .../test_SmartWinsYearCalculator.py | 762 ++++++--- .../test_TeamSummaryYearCalculator.py | 204 ++- test/test_decorator/test_validators.py | 25 +- .../test_ESPNLeagueLoader.py | 308 +++- .../test_FleaflickerLeagueLoader.py | 521 ++++-- test/test_league_loader/test_LeagueLoader.py | 29 +- .../test_MyFantasyLeagueLeagueLoader.py | 1318 +++++++++++---- .../test_SleeperLeagueLoader.py | 1041 +++++++++--- .../test_YahooLeagueLoader.py | 351 +++- .../test_filter/test_AllTimeFilters.py | 7 +- test/test_model/test_league/test_League.py | 55 +- test/test_model/test_league/test_Matchup.py | 10 +- test/test_model/test_league/test_Week.py | 21 +- test/test_model/test_league/test_Year.py | 10 +- .../test_league_helper/test_Performance.py | 10 +- test/test_util/test_GeneralUtil.py | 42 +- test/test_util/test_equality.py | 4 +- test/test_util/test_excel.py | 293 +++- test/test_util/test_excel_helper.py | 26 +- .../test_navigator/test_LeagueNavigator.py | 243 ++- .../test_navigator/test_MatchupNavigator.py | 22 +- .../test_navigator/test_WeekNavigator.py | 6 +- .../test_navigator/test_YearNavigator.py | 153 +- test/test_util/test_stat_sheet.py | 30 +- test/test_validate/test_divisionValidation.py | 4 +- test/test_validate/test_leagueValidation.py | 52 +- test/test_validate/test_matchupValidation.py | 42 +- test/test_validate/test_teamValidation.py | 4 +- test/test_validate/test_weekValidation.py | 33 +- test/test_validate/test_yearValidation.py | 236 ++- 119 files changed, 11710 insertions(+), 3823 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 91abb11f..cfca83a1 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,7 +5,7 @@ version: 2 updates: - - package-ecosystem: "pip" # See documentation for possible values - directory: "/" # Location of package manifests + - package-ecosystem: "pip" + directory: "/" schedule: - interval: "weekly" + interval: "monthly" diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 0c4d62c3..99034926 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -18,20 +18,18 @@ jobs: build: name: unit tests runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.10"] steps: - uses: actions/checkout@v3 - - name: Get current required Python version - id: get-python-versions - run: | - MINIMUM_VERSION=$(grep -oP '__version_minimum_python__ = "\K.*(?=")' leeger/_version.py) - echo "CURRENT_VERSION=$MINIMUM_VERSION" >> $GITHUB_ENV - - name: Set up Python uses: actions/setup-python@v3 with: - python-version: ${{ env.CURRENT_VERSION }} + python-version: ${{ matrix.python-version }} - name: Install dependencies run: | diff --git a/Makefile b/Makefile index 14440b9e..de02c65b 100644 --- a/Makefile +++ b/Makefile @@ -1,39 +1,32 @@ .PHONY: deps deps: - @python3.10 -m pip install -r requirements.dev.txt - @python3.10 -m pip install -r requirements.txt + @python -m pip install -r requirements.dev.txt + @python -m pip install -r requirements.txt .PHONY: fmt fmt: - @black --config=pyproject.toml . - @autoflake --config=pyproject.toml . - @isort . + @ruff check --fix + @ruff format .PHONY: fmt-check fmt-check: - @black --config=pyproject.toml . --check - @autoflake --config=pyproject.toml . --check - @isort . --check-only - + @ruff check + @ruff format --check .PHONY: test test: - @python3.10 -m pytest test/ - -.PHONY: reqs -reqs: - @pipreqs --force --mode compat + @python -m pytest test/ .PHONY: pkg-build pkg-build: @rm -rf build @rm -rf dist - @python3.10 setup.py sdist bdist_wheel + @python setup.py sdist bdist_wheel .PHONY: pkg-test pkg-test: - @python3.10 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/* + @python -m twine upload --repository-url https://test.pypi.org/legacy/ dist/* .PHONY: pkg-prod pkg-prod: - @python3.10 -m twine upload dist/* \ No newline at end of file + @python -m twine upload dist/* diff --git a/e2e/variables.py b/e2e/variables.py index caf5a8af..da6bd3d3 100644 --- a/e2e/variables.py +++ b/e2e/variables.py @@ -17,13 +17,22 @@ teamDominic2019 = Team(ownerId=ownerDominic.id, name="Bike Ridas") matchup1 = Matchup( - teamAId=teamFrankie2019.id, teamBId=teamDominic2019.id, teamAScore=101.2, teamBScore=122 + teamAId=teamFrankie2019.id, + teamBId=teamDominic2019.id, + teamAScore=101.2, + teamBScore=122, ) matchup2 = Matchup( - teamAId=teamMonika2019.id, teamBId=teamGiovanna2019.id, teamAScore=78.4, teamBScore=114.3 + teamAId=teamMonika2019.id, + teamBId=teamGiovanna2019.id, + teamAScore=78.4, + teamBScore=114.3, ) matchup3 = Matchup( - teamAId=teamJoseph2019.id, teamBId=teamVincent2019.id, teamAScore=112, teamBScore=145.3 + teamAId=teamJoseph2019.id, + teamBId=teamVincent2019.id, + teamAScore=112, + teamBScore=145.3, ) matchup4 = Matchup( @@ -107,6 +116,13 @@ LEAGUE = League( name="G League", - owners=[ownerFrankie, ownerMonika, ownerJoseph, ownerVincent, ownerGiovanna, ownerDominic], + owners=[ + ownerFrankie, + ownerMonika, + ownerJoseph, + ownerVincent, + ownerGiovanna, + ownerDominic, + ], years=[year2019], ) diff --git a/example/league/comparingLeagueObjects.py b/example/league/comparingLeagueObjects.py index 57e28384..d1d48ba7 100644 --- a/example/league/comparingLeagueObjects.py +++ b/example/league/comparingLeagueObjects.py @@ -10,7 +10,9 @@ # 2. lets compare it league.equals(league) # compares models with all fields - league.equals(league, ignoreBaseIds=True) # ignores the base "id" field in each object + league.equals( + league, ignoreBaseIds=True + ) # ignores the base "id" field in each object league.equals( league, ignoreIds=True ) # ignores fields that hold an id but not the base "id" fields diff --git a/example/league/manualLeagueBuildingExample.py b/example/league/manualLeagueBuildingExample.py index 264a3608..48d47c22 100644 --- a/example/league/manualLeagueBuildingExample.py +++ b/example/league/manualLeagueBuildingExample.py @@ -26,13 +26,22 @@ # Create matchups for week 1. # Use the team IDs when creating a matchup. matchup1 = Matchup( - teamAId=teamFrankie2019.id, teamBId=teamDominic2019.id, teamAScore=101.2, teamBScore=122 + teamAId=teamFrankie2019.id, + teamBId=teamDominic2019.id, + teamAScore=101.2, + teamBScore=122, ) matchup2 = Matchup( - teamAId=teamMonika2019.id, teamBId=teamGiovanna2019.id, teamAScore=78.4, teamBScore=114.3 + teamAId=teamMonika2019.id, + teamBId=teamGiovanna2019.id, + teamAScore=78.4, + teamBScore=114.3, ) matchup3 = Matchup( - teamAId=teamJoseph2019.id, teamBId=teamVincent2019.id, teamAScore=112, teamBScore=145.3 + teamAId=teamJoseph2019.id, + teamBId=teamVincent2019.id, + teamAScore=112, + teamBScore=145.3, ) # Create matchups for week 2. @@ -126,6 +135,13 @@ # Create the league. league = League( name="G League", - owners=[ownerFrankie, ownerMonika, ownerJoseph, ownerVincent, ownerGiovanna, ownerDominic], + owners=[ + ownerFrankie, + ownerMonika, + ownerJoseph, + ownerVincent, + ownerGiovanna, + ownerDominic, + ], years=[year2019], ) diff --git a/example/league/yearSettings.py b/example/league/yearSettings.py index 9bc74a02..2a5ffaa5 100644 --- a/example/league/yearSettings.py +++ b/example/league/yearSettings.py @@ -10,4 +10,6 @@ year = Year(yearNumber=2020, teams=list(), weeks=list(), yearSettings=yearSettings) # The YearSettings object can be used for multiple years if desired - anotherYear = Year(yearNumber=2021, teams=list(), weeks=list(), yearSettings=yearSettings) + anotherYear = Year( + yearNumber=2021, teams=list(), weeks=list(), yearSettings=yearSettings + ) diff --git a/example/league_loader/espnLeagueLoaderExample.py b/example/league_loader/espnLeagueLoaderExample.py index 360b5f8d..5fd1461d 100644 --- a/example/league_loader/espnLeagueLoaderExample.py +++ b/example/league_loader/espnLeagueLoaderExample.py @@ -18,5 +18,7 @@ # Get a League object with years 2019 and 2020 for ESPN league with ID: "12345678". espnS2 = "ABCDEFG1234567" swid = "{ABC-DEF-GHI-JKL-MNOP}" - espnLeagueLoader = ESPNLeagueLoader("12345678", [2019, 2020], espnS2=espnS2, swid=swid) + espnLeagueLoader = ESPNLeagueLoader( + "12345678", [2019, 2020], espnS2=espnS2, swid=swid + ) league: League = espnLeagueLoader.loadLeague() diff --git a/example/league_loader/myFantasyLeagueLeagueLoaderExample.py b/example/league_loader/myFantasyLeagueLeagueLoaderExample.py index 93e2c8ff..01bcfa48 100644 --- a/example/league_loader/myFantasyLeagueLeagueLoaderExample.py +++ b/example/league_loader/myFantasyLeagueLeagueLoaderExample.py @@ -16,7 +16,9 @@ MFL_USERNAME = "myUsername" # The username for your MFL account. MFL_PASSWORD = "myPassword" # The password for your MFL account. - MFL_USER_AGENT_NAME = "myUserAgentName" # The Client User Agent you set for your API Client. + MFL_USER_AGENT_NAME = ( + "myUserAgentName" # The Client User Agent you set for your API Client. + ) LEAGUE_ID = "123456" myFantasyLeagueLoader = MyFantasyLeagueLeagueLoader( diff --git a/example/league_loader/yahooLeagueLoaderExample.py b/example/league_loader/yahooLeagueLoaderExample.py index 27b1be57..0b77688e 100644 --- a/example/league_loader/yahooLeagueLoaderExample.py +++ b/example/league_loader/yahooLeagueLoaderExample.py @@ -20,6 +20,10 @@ clientId = "myClientId" clientSecret = "myClientSecret" yahooLeagueLoader = YahooLeagueLoader( - "123456", [2019, 2020], clientId=clientId, clientSecret=clientSecret, loginTimeoutSeconds=4 + "123456", + [2019, 2020], + clientId=clientId, + clientSecret=clientSecret, + loginTimeoutSeconds=4, ) league: League = yahooLeagueLoader.loadLeague() diff --git a/example/stat/gettingStatsAllTimeExample.py b/example/stat/gettingStatsAllTimeExample.py index 02d15dae..580be650 100644 --- a/example/stat/gettingStatsAllTimeExample.py +++ b/example/stat/gettingStatsAllTimeExample.py @@ -27,18 +27,22 @@ wins = GameOutcomeAllTimeCalculator.getWins(league) # Get opponent points scored per game. - opponentPointsScoredPerGame = PointsScoredAllTimeCalculator.getOpponentPointsScoredPerGame( - league + opponentPointsScoredPerGame = ( + PointsScoredAllTimeCalculator.getOpponentPointsScoredPerGame(league) ) # To limit results to only regular season, specify that as a keyword argument. maxScore = SingleScoreAllTimeCalculator.getMaxScore(league, onlyRegularSeason=True) # To limit results to only post-season (playoffs), specify that as a keyword argument. - scoringShare = ScoringShareAllTimeCalculator.getScoringShare(league, onlyPostSeason=True) + scoringShare = ScoringShareAllTimeCalculator.getScoringShare( + league, onlyPostSeason=True + ) # To limit results to only championship games, specify that as a keyword argument. - winPercentage = GameOutcomeAllTimeCalculator.getWinPercentage(league, onlyChampionship=True) + winPercentage = GameOutcomeAllTimeCalculator.getWinPercentage( + league, onlyChampionship=True + ) # To limit results to only certain years, specify that as a keyword argument. # This league has years 2019, 2020, 2021, 2022. @@ -89,5 +93,9 @@ ) # Will get week 5, 2020 - week 10, 2021. smartWins = SmartWinsAllTimeCalculator.getSmartWins( - league, weekNumberStart=5, yearNumberStart=2020, weekNumberEnd=10, yearNumberEnd=2021 + league, + weekNumberStart=5, + yearNumberStart=2020, + weekNumberEnd=10, + yearNumberEnd=2021, ) diff --git a/example/stat/gettingStatsForYearExample.py b/example/stat/gettingStatsForYearExample.py index 0149552a..044e6189 100644 --- a/example/stat/gettingStatsForYearExample.py +++ b/example/stat/gettingStatsForYearExample.py @@ -29,31 +29,41 @@ wins = GameOutcomeYearCalculator.getWins(year2019) # Get opponent points scored per game. - opponentPointsScoredPerGame = PointsScoredYearCalculator.getOpponentPointsScoredPerGame( - year2019 + opponentPointsScoredPerGame = ( + PointsScoredYearCalculator.getOpponentPointsScoredPerGame(year2019) ) # To limit results to only regular season, specify that as a keyword argument. maxScore = SingleScoreYearCalculator.getMaxScore(year2019, onlyRegularSeason=True) # To limit results to only post-season (playoffs), specify that as a keyword argument. - scoringShare = ScoringShareYearCalculator.getScoringShare(year2019, onlyPostSeason=True) + scoringShare = ScoringShareYearCalculator.getScoringShare( + year2019, onlyPostSeason=True + ) # To limit results to only championship games, specify that as a keyword argument. - winPercentage = GameOutcomeYearCalculator.getWinPercentage(year2019, onlyChampionship=True) + winPercentage = GameOutcomeYearCalculator.getWinPercentage( + year2019, onlyChampionship=True + ) # To limit results to only certain weeks, specify that as a keyword argument. # Let's assume this year has weeks 1-15. # Will get weeks 5-15. - scoringStandardDeviation = ScoringStandardDeviationYearCalculator.getScoringStandardDeviation( - year2019, weekNumberStart=5 + scoringStandardDeviation = ( + ScoringStandardDeviationYearCalculator.getScoringStandardDeviation( + year2019, weekNumberStart=5 + ) ) # Will get weeks 1-10. - scoringStandardDeviation = ScoringStandardDeviationYearCalculator.getScoringStandardDeviation( - year2019, weekNumberEnd=10 + scoringStandardDeviation = ( + ScoringStandardDeviationYearCalculator.getScoringStandardDeviation( + year2019, weekNumberEnd=10 + ) ) # Will get weeks 5-10. - scoringStandardDeviation = ScoringStandardDeviationYearCalculator.getScoringStandardDeviation( - year2019, weekNumberStart=5, weekNumberEnd=10 + scoringStandardDeviation = ( + ScoringStandardDeviationYearCalculator.getScoringStandardDeviation( + year2019, weekNumberStart=5, weekNumberEnd=10 + ) ) diff --git a/leeger/calculator/all_time_calculator/AWALAllTimeCalculator.py b/leeger/calculator/all_time_calculator/AWALAllTimeCalculator.py index d1bfbb84..9189cc5e 100644 --- a/leeger/calculator/all_time_calculator/AWALAllTimeCalculator.py +++ b/leeger/calculator/all_time_calculator/AWALAllTimeCalculator.py @@ -92,11 +92,15 @@ def getOpponentAWAL(cls, league: League, **kwargs) -> dict[str, Optional[Deci]]: ... } """ - return cls._addAndCombineResults(league, AWALYearCalculator.getOpponentAWAL, **kwargs) + return cls._addAndCombineResults( + league, AWALYearCalculator.getOpponentAWAL, **kwargs + ) @classmethod @validateLeague - def getOpponentAWALPerGame(cls, league: League, **kwargs) -> dict[str, Optional[Deci]]: + def getOpponentAWALPerGame( + cls, league: League, **kwargs + ) -> dict[str, Optional[Deci]]: """ Returns the number of Adjusted Wins Against the League per game for each Owner's opponent in the given League. Returns None for an Owner if they have no games played in the range. @@ -124,7 +128,8 @@ def getOpponentAWALPerGame(cls, league: League, **kwargs) -> dict[str, Optional[ ownerIdAndOpponentAWALPerGame[ownerId] = None else: ownerIdAndOpponentAWALPerGame[ownerId] = ( - ownerIdAndOpponentAWAL[ownerId] / ownerIdAndNumberOfGamesPlayed[ownerId] + ownerIdAndOpponentAWAL[ownerId] + / ownerIdAndNumberOfGamesPlayed[ownerId] ) return ownerIdAndOpponentAWALPerGame diff --git a/leeger/calculator/all_time_calculator/GameOutcomeAllTimeCalculator.py b/leeger/calculator/all_time_calculator/GameOutcomeAllTimeCalculator.py index 578f2fc0..794dada8 100644 --- a/leeger/calculator/all_time_calculator/GameOutcomeAllTimeCalculator.py +++ b/leeger/calculator/all_time_calculator/GameOutcomeAllTimeCalculator.py @@ -1,7 +1,9 @@ from typing import Optional from leeger.calculator.parent.AllTimeCalculator import AllTimeCalculator -from leeger.calculator.year_calculator.GameOutcomeYearCalculator import GameOutcomeYearCalculator +from leeger.calculator.year_calculator.GameOutcomeYearCalculator import ( + GameOutcomeYearCalculator, +) from leeger.decorator.validators import validateLeague from leeger.model.filter import AllTimeFilters from leeger.model.league.League import League @@ -25,7 +27,9 @@ def getWins(cls, league: League, **kwargs) -> dict[str, Optional[int]]: ... } """ - return cls._addAndCombineResults(league, GameOutcomeYearCalculator.getWins, **kwargs) + return cls._addAndCombineResults( + league, GameOutcomeYearCalculator.getWins, **kwargs + ) @classmethod @validateLeague @@ -42,7 +46,9 @@ def getLosses(cls, league: League, **kwargs) -> dict[str, Optional[int]]: ... } """ - return cls._addAndCombineResults(league, GameOutcomeYearCalculator.getLosses, **kwargs) + return cls._addAndCombineResults( + league, GameOutcomeYearCalculator.getLosses, **kwargs + ) @classmethod @validateLeague @@ -59,7 +65,9 @@ def getTies(cls, league: League, **kwargs) -> dict[str, Optional[int]]: ... } """ - return cls._addAndCombineResults(league, GameOutcomeYearCalculator.getTies, **kwargs) + return cls._addAndCombineResults( + league, GameOutcomeYearCalculator.getTies, **kwargs + ) @classmethod @validateLeague @@ -95,7 +103,12 @@ def getWinPercentage(cls, league: League, **kwargs) -> dict[str, Optional[Deci]] numberOfTies = ownerIdAndTies[ownerId] numberOfLeagueMedianWins = ownerIdAndLeagueMedianWins[ownerId] - if None in (numberOfWins, numberOfLosses, numberOfTies, numberOfLeagueMedianWins): + if None in ( + numberOfWins, + numberOfLosses, + numberOfTies, + numberOfLeagueMedianWins, + ): ownerIdAndWinPercentage[ownerId] = None else: filters = AllTimeFilters.getForLeague(league, **kwargs) @@ -210,7 +223,9 @@ def getLeagueMedianWins(cls, league: League, **kwargs) -> dict[str, Optional[Dec @classmethod @validateLeague - def getOpponentLeagueMedianWins(cls, league: League, **kwargs) -> dict[str, Optional[Deci]]: + def getOpponentLeagueMedianWins( + cls, league: League, **kwargs + ) -> dict[str, Optional[Deci]]: """ Returns the number of league median wins for each Owner's opponents in the given League. Returns None for an Owner if they have no games played in the range. diff --git a/leeger/calculator/all_time_calculator/PlusMinusAllTimeCalculator.py b/leeger/calculator/all_time_calculator/PlusMinusAllTimeCalculator.py index 592bb637..431fd87e 100644 --- a/leeger/calculator/all_time_calculator/PlusMinusAllTimeCalculator.py +++ b/leeger/calculator/all_time_calculator/PlusMinusAllTimeCalculator.py @@ -1,7 +1,9 @@ from typing import Optional from leeger.calculator.parent.AllTimeCalculator import AllTimeCalculator -from leeger.calculator.year_calculator.PlusMinusYearCalculator import PlusMinusYearCalculator +from leeger.calculator.year_calculator.PlusMinusYearCalculator import ( + PlusMinusYearCalculator, +) from leeger.decorator.validators import validateLeague from leeger.model.league.League import League from leeger.util.Deci import Deci @@ -35,4 +37,6 @@ def getPlusMinus(cls, league: League, **kwargs) -> dict[str, Optional[Deci]]: } """ - return cls._addAndCombineResults(league, PlusMinusYearCalculator.getPlusMinus, **kwargs) + return cls._addAndCombineResults( + league, PlusMinusYearCalculator.getPlusMinus, **kwargs + ) diff --git a/leeger/calculator/all_time_calculator/PointsScoredAllTimeCalculator.py b/leeger/calculator/all_time_calculator/PointsScoredAllTimeCalculator.py index ae790705..b2031e07 100644 --- a/leeger/calculator/all_time_calculator/PointsScoredAllTimeCalculator.py +++ b/leeger/calculator/all_time_calculator/PointsScoredAllTimeCalculator.py @@ -1,7 +1,9 @@ from typing import Optional from leeger.calculator.parent.AllTimeCalculator import AllTimeCalculator -from leeger.calculator.year_calculator.PointsScoredYearCalculator import PointsScoredYearCalculator +from leeger.calculator.year_calculator.PointsScoredYearCalculator import ( + PointsScoredYearCalculator, +) from leeger.decorator.validators import validateLeague from leeger.model.filter import AllTimeFilters from leeger.model.league.League import League @@ -35,7 +37,9 @@ def getPointsScored(cls, league: League, **kwargs) -> dict[str, Optional[Deci]]: @classmethod @validateLeague - def getPointsScoredPerGame(cls, league: League, **kwargs) -> dict[str, Optional[Deci]]: + def getPointsScoredPerGame( + cls, league: League, **kwargs + ) -> dict[str, Optional[Deci]]: """ Returns the number of Points Scored per game for each Owner in the given League. @@ -60,14 +64,17 @@ def getPointsScoredPerGame(cls, league: League, **kwargs) -> dict[str, Optional[ ownerIdAndPointsScoredPerGame[ownerId] = None else: ownerIdAndPointsScoredPerGame[ownerId] = ( - ownerIdAndPointsScored[ownerId] / ownerIdAndNumberOfGamesPlayed[ownerId] + ownerIdAndPointsScored[ownerId] + / ownerIdAndNumberOfGamesPlayed[ownerId] ) return ownerIdAndPointsScoredPerGame @classmethod @validateLeague - def getOpponentPointsScored(cls, league: League, **kwargs) -> dict[str, Optional[Deci]]: + def getOpponentPointsScored( + cls, league: League, **kwargs + ) -> dict[str, Optional[Deci]]: """ Returns the number of Points Scored for each Owner's opponent in the given League. Returns None for an Owner if they have no games played in the range. @@ -86,7 +93,9 @@ def getOpponentPointsScored(cls, league: League, **kwargs) -> dict[str, Optional @classmethod @validateLeague - def getOpponentPointsScoredPerGame(cls, league: League, **kwargs) -> dict[str, Optional[Deci]]: + def getOpponentPointsScoredPerGame( + cls, league: League, **kwargs + ) -> dict[str, Optional[Deci]]: """ Returns the number of Points Scored per game for each Owner's opponent in the given League. Returns None for an Owner if they have no games played in the range. @@ -112,7 +121,8 @@ def getOpponentPointsScoredPerGame(cls, league: League, **kwargs) -> dict[str, O ownerIdAndOpponentPointsScoredPerGame[ownerId] = None else: ownerIdAndOpponentPointsScoredPerGame[ownerId] = ( - ownerIdAndOpponentPointsScored[ownerId] / ownerIdAndNumberOfGamesPlayed[ownerId] + ownerIdAndOpponentPointsScored[ownerId] + / ownerIdAndNumberOfGamesPlayed[ownerId] ) return ownerIdAndOpponentPointsScoredPerGame diff --git a/leeger/calculator/all_time_calculator/SSLAllTimeCalculator.py b/leeger/calculator/all_time_calculator/SSLAllTimeCalculator.py index 9512dc87..61dfa80e 100644 --- a/leeger/calculator/all_time_calculator/SSLAllTimeCalculator.py +++ b/leeger/calculator/all_time_calculator/SSLAllTimeCalculator.py @@ -29,7 +29,9 @@ class SSLAllTimeCalculator(AllTimeCalculator): @classmethod @validateLeague - def getAdjustedTeamScore(cls, league: League, **kwargs) -> dict[str, Optional[Deci]]: + def getAdjustedTeamScore( + cls, league: League, **kwargs + ) -> dict[str, Optional[Deci]]: """ Returns the Adjusted Team Score per Game for each Owner in the given League. Returns None for an Owner if all Years for that Owner are None @@ -58,7 +60,9 @@ def getAdjustedTeamScore(cls, league: League, **kwargs) -> dict[str, Optional[De year, **yearFiltersByYear[str(yearNumber)].asKwargs() ) - ownerIdToTeamScoreAndGamesPlayedListMap: dict[str, list[tuple[Deci, int]]] = dict() + ownerIdToTeamScoreAndGamesPlayedListMap: dict[str, list[tuple[Deci, int]]] = ( + dict() + ) # {"someOwnerId": [(Deci("101.5"), 4), (Deci("109.4), 5)]} for yearNumber, teamScoreResultDict in teamScoreResultsOrderedByYear.items(): for teamId, teamScore in teamScoreResultDict.items(): @@ -75,7 +79,10 @@ def getAdjustedTeamScore(cls, league: League, **kwargs) -> dict[str, Optional[De # adjust team scores by games played ownerIdAndAdjustedTeamScore: dict[str, Optional[Deci]] = dict() - for ownerId, teamScoreAndGamesPlayedList in ownerIdToTeamScoreAndGamesPlayedListMap.items(): + for ( + ownerId, + teamScoreAndGamesPlayedList, + ) in ownerIdToTeamScoreAndGamesPlayedListMap.items(): totalGamesPlayed = sum([tsagp[1] for tsagp in teamScoreAndGamesPlayedList]) if totalGamesPlayed > 0: for teamScore, gamesPlayed in teamScoreAndGamesPlayedList: @@ -96,7 +103,9 @@ def getAdjustedTeamScore(cls, league: League, **kwargs) -> dict[str, Optional[De @classmethod @validateLeague - def getAdjustedTeamSuccess(cls, league: League, **kwargs) -> dict[str, Optional[Deci]]: + def getAdjustedTeamSuccess( + cls, league: League, **kwargs + ) -> dict[str, Optional[Deci]]: """ Returns the Adjusted Team Success per Game for each Owner in the given League. Returns None for an Owner if all Years for that Owner are None @@ -125,9 +134,14 @@ def getAdjustedTeamSuccess(cls, league: League, **kwargs) -> dict[str, Optional[ year, **yearFiltersByYear[str(yearNumber)].asKwargs() ) - ownerIdToTeamSuccessAndGamesPlayedListMap: dict[str, list[tuple[Deci, int]]] = dict() + ownerIdToTeamSuccessAndGamesPlayedListMap: dict[str, list[tuple[Deci, int]]] = ( + dict() + ) # {"someOwnerId": [(Deci("101.5"), 4), (Deci("109.4), 5)]} - for yearNumber, teamSuccessResultDict in teamSuccessResultsOrderedByYear.items(): + for ( + yearNumber, + teamSuccessResultDict, + ) in teamSuccessResultsOrderedByYear.items(): for teamId, teamSuccess in teamSuccessResultDict.items(): team = LeagueNavigator.getTeamById(league, teamId) gamesPlayed = gamesPlayedByYear[yearNumber][teamId] @@ -146,14 +160,20 @@ def getAdjustedTeamSuccess(cls, league: League, **kwargs) -> dict[str, Optional[ ownerId, teamSuccessAndGamesPlayedList, ) in ownerIdToTeamSuccessAndGamesPlayedListMap.items(): - totalGamesPlayed = sum([tsagp[1] for tsagp in teamSuccessAndGamesPlayedList]) + totalGamesPlayed = sum( + [tsagp[1] for tsagp in teamSuccessAndGamesPlayedList] + ) if totalGamesPlayed > 0: for teamSuccess, gamesPlayed in teamSuccessAndGamesPlayedList: if teamSuccess is not None: percentageOfGamesPlayed = Deci(gamesPlayed / totalGamesPlayed) - adjustedTeamSuccess = Deci(teamSuccess * percentageOfGamesPlayed) + adjustedTeamSuccess = Deci( + teamSuccess * percentageOfGamesPlayed + ) if ownerId in ownerIdAndAdjustedTeamSuccess: - ownerIdAndAdjustedTeamSuccess[ownerId] += adjustedTeamSuccess + ownerIdAndAdjustedTeamSuccess[ownerId] += ( + adjustedTeamSuccess + ) else: ownerIdAndAdjustedTeamSuccess[ownerId] = adjustedTeamSuccess @@ -180,7 +200,9 @@ def getAdjustedTeamLuck(cls, league: League, **kwargs) -> dict[str, Optional[Dec } """ ownerIdAndAdjustedTeamLuck: dict[str, Optional[Deci]] = dict() - ownerIdAndAdjustedTeamScore = SSLAllTimeCalculator.getAdjustedTeamScore(league, **kwargs) + ownerIdAndAdjustedTeamScore = SSLAllTimeCalculator.getAdjustedTeamScore( + league, **kwargs + ) ownerIdAndAdjustedTeamSuccess = SSLAllTimeCalculator.getAdjustedTeamSuccess( league, **kwargs ) @@ -189,7 +211,9 @@ def getAdjustedTeamLuck(cls, league: League, **kwargs) -> dict[str, Optional[Dec adjustedTeamScore = ownerIdAndAdjustedTeamScore[ownerId] adjustedTeamSuccess = ownerIdAndAdjustedTeamSuccess[ownerId] if adjustedTeamScore is not None and adjustedTeamSuccess is not None: - ownerIdAndAdjustedTeamLuck[ownerId] = Deci(adjustedTeamSuccess - adjustedTeamScore) + ownerIdAndAdjustedTeamLuck[ownerId] = Deci( + adjustedTeamSuccess - adjustedTeamScore + ) else: ownerIdAndAdjustedTeamLuck[ownerId] = None diff --git a/leeger/calculator/all_time_calculator/ScoringShareAllTimeCalculator.py b/leeger/calculator/all_time_calculator/ScoringShareAllTimeCalculator.py index 98f9c119..a0007f5b 100644 --- a/leeger/calculator/all_time_calculator/ScoringShareAllTimeCalculator.py +++ b/leeger/calculator/all_time_calculator/ScoringShareAllTimeCalculator.py @@ -40,8 +40,12 @@ def getScoringShare(cls, league: League, **kwargs) -> dict[str, Optional[Deci]]: } """ - ownerIdAndPointsScored = PointsScoredAllTimeCalculator.getPointsScored(league, **kwargs) - allScores = GeneralUtil.filter(value=None, list_=ownerIdAndPointsScored.values()) + ownerIdAndPointsScored = PointsScoredAllTimeCalculator.getPointsScored( + league, **kwargs + ) + allScores = GeneralUtil.filter( + value=None, list_=ownerIdAndPointsScored.values() + ) totalPointsScoredInLeague = sum(allScores) ownerIdAndScoringShare = dict() for ownerId in LeagueNavigator.getAllOwnerIds(league): @@ -60,7 +64,9 @@ def getScoringShare(cls, league: League, **kwargs) -> dict[str, Optional[Deci]]: @classmethod @validateLeague - def getOpponentScoringShare(cls, league: League, **kwargs) -> dict[str, Optional[Deci]]: + def getOpponentScoringShare( + cls, league: League, **kwargs + ) -> dict[str, Optional[Deci]]: """ Returns the Scoring Share for each Owner's opponent in the given League. Returns None for an Owner if they have no games played in the range. @@ -74,10 +80,12 @@ def getOpponentScoringShare(cls, league: League, **kwargs) -> dict[str, Optional } """ - ownerIdAndOpponentPointsScored = PointsScoredAllTimeCalculator.getOpponentPointsScored( - league, **kwargs + ownerIdAndOpponentPointsScored = ( + PointsScoredAllTimeCalculator.getOpponentPointsScored(league, **kwargs) + ) + allScores = GeneralUtil.filter( + value=None, list_=ownerIdAndOpponentPointsScored.values() ) - allScores = GeneralUtil.filter(value=None, list_=ownerIdAndOpponentPointsScored.values()) totalPointsScoredInLeague = sum(allScores) ownerIdAndOpponentScoringShare = dict() for ownerId in LeagueNavigator.getAllOwnerIds(league): @@ -89,7 +97,8 @@ def getOpponentScoringShare(cls, league: League, **kwargs) -> dict[str, Optional ownerIdAndOpponentScoringShare[ownerId] = Deci("0") else: ownerIdAndOpponentScoringShare[ownerId] = ( - ownerIdAndOpponentPointsScored[ownerId] / totalPointsScoredInLeague + ownerIdAndOpponentPointsScored[ownerId] + / totalPointsScoredInLeague ) * Deci("100") return ownerIdAndOpponentScoringShare @@ -122,7 +131,10 @@ def getMaxScoringShare(cls, league: League, **kwargs) -> dict[str, Optional[Deci ) # swap out team IDs for owner IDs maxScoringSharesByYear = dict() - for yearNumber, maxScoringSharesByTeamId in maxScoringSharesByYearTeamIds.items(): + for ( + yearNumber, + maxScoringSharesByTeamId, + ) in maxScoringSharesByYearTeamIds.items(): maxScoringSharesByYear[yearNumber] = dict() for teamId, maxScoringShare in maxScoringSharesByTeamId.items(): ownerId = LeagueNavigator.getTeamById(league, teamId).ownerId @@ -149,7 +161,9 @@ def getMaxScoringShare(cls, league: League, **kwargs) -> dict[str, Optional[Deci i for i in ownerIdAndMaxScoringShares[ownerId] if i is not None ] if len(ownerIdAndMaxScoringShares[ownerId]) > 0: - ownerIdAndMaxScoringShare[ownerId] = max(ownerIdAndMaxScoringShares[ownerId]) + ownerIdAndMaxScoringShare[ownerId] = max( + ownerIdAndMaxScoringShares[ownerId] + ) else: ownerIdAndMaxScoringShare[ownerId] = None @@ -183,7 +197,10 @@ def getMinScoringShare(cls, league: League, **kwargs) -> dict[str, Optional[Deci ) # swap out team IDs for owner IDs minScoringSharesByYear = dict() - for yearNumber, minScoringSharesByTeamId in minScoringSharesByYearTeamIds.items(): + for ( + yearNumber, + minScoringSharesByTeamId, + ) in minScoringSharesByYearTeamIds.items(): minScoringSharesByYear[yearNumber] = dict() for teamId, maxScoringShare in minScoringSharesByTeamId.items(): ownerId = LeagueNavigator.getTeamById(league, teamId).ownerId @@ -210,7 +227,9 @@ def getMinScoringShare(cls, league: League, **kwargs) -> dict[str, Optional[Deci i for i in ownerIdAndMinScoringShares[ownerId] if i is not None ] if len(ownerIdAndMinScoringShares[ownerId]) > 0: - ownerIdAndMinScoringShare[ownerId] = min(ownerIdAndMinScoringShares[ownerId]) + ownerIdAndMinScoringShare[ownerId] = min( + ownerIdAndMinScoringShares[ownerId] + ) else: ownerIdAndMinScoringShare[ownerId] = None diff --git a/leeger/calculator/all_time_calculator/ScoringStandardDeviationAllTimeCalculator.py b/leeger/calculator/all_time_calculator/ScoringStandardDeviationAllTimeCalculator.py index a1fea16b..5a937f52 100644 --- a/leeger/calculator/all_time_calculator/ScoringStandardDeviationAllTimeCalculator.py +++ b/leeger/calculator/all_time_calculator/ScoringStandardDeviationAllTimeCalculator.py @@ -17,7 +17,9 @@ class ScoringStandardDeviationAllTimeCalculator(AllTimeCalculator): @classmethod @validateLeague - def getScoringStandardDeviation(cls, league: League, **kwargs) -> dict[str, Optional[Deci]]: + def getScoringStandardDeviation( + cls, league: League, **kwargs + ) -> dict[str, Optional[Deci]]: """ Scoring STDEV (Standard Deviation) is used to show how volatile a team's scoring was. This stat measures an Owner's scores relative to the mean (or PPG) of all of their scores. @@ -46,7 +48,9 @@ def getScoringStandardDeviation(cls, league: League, **kwargs) -> dict[str, Opti for ownerId in allOwnerIds: ownerIdAndScores[ownerId] = list() - for matchup in cls._getAllFilteredMatchups(league, filters, simplifyMultiWeekMatchups=True): + for matchup in cls._getAllFilteredMatchups( + league, filters, simplifyMultiWeekMatchups=True + ): ownerAId = LeagueNavigator.getTeamById(league, matchup.teamAId).ownerId ownerBId = LeagueNavigator.getTeamById(league, matchup.teamBId).ownerId ownerIdAndScores[ownerAId].append(Deci(matchup.teamAScore)) diff --git a/leeger/calculator/all_time_calculator/SmartWinsAllTimeCalculator.py b/leeger/calculator/all_time_calculator/SmartWinsAllTimeCalculator.py index 50f449a2..23c4d017 100644 --- a/leeger/calculator/all_time_calculator/SmartWinsAllTimeCalculator.py +++ b/leeger/calculator/all_time_calculator/SmartWinsAllTimeCalculator.py @@ -63,13 +63,17 @@ def getNumberOfScoresBeatAndTied( # get all scores we want to include in our smart wins calculation ownerIdsAndScores: list[tuple] = list() - for matchup in cls._getAllFilteredMatchups(league, filters, simplifyMultiWeekMatchups=True): + for matchup in cls._getAllFilteredMatchups( + league, filters, simplifyMultiWeekMatchups=True + ): teamA = LeagueNavigator.getTeamById(league, matchup.teamAId) teamB = LeagueNavigator.getTeamById(league, matchup.teamBId) ownerIdsAndScores.append((teamA.ownerId, matchup.teamAScore)) ownerIdsAndScores.append((teamB.ownerId, matchup.teamBScore)) - allScores = LeagueNavigator.getAllScoresInLeague(league, simplifyMultiWeekMatchups=True) + allScores = LeagueNavigator.getAllScoresInLeague( + league, simplifyMultiWeekMatchups=True + ) ownerIdAndSmartWins = dict() allOwnerIds = LeagueNavigator.getAllOwnerIds(league) for ownerId in allOwnerIds: @@ -77,7 +81,9 @@ def getNumberOfScoresBeatAndTied( for ownerId, score in ownerIdsAndScores: scoresBeat, scoresTied = getNumberOfScoresBeatAndTied(score, allScores) - smartWins = (scoresBeat + (scoresTied / Deci(2))) / (len(allScores) - Deci(1)) + smartWins = (scoresBeat + (scoresTied / Deci(2))) / ( + len(allScores) - Deci(1) + ) if ownerIdAndSmartWins[ownerId] is None: ownerIdAndSmartWins[ownerId] = smartWins else: @@ -115,14 +121,17 @@ def getSmartWinsPerGame(cls, league: League, **kwargs) -> dict[str, Optional[Dec ownerIdAndSmartWinsPerGame[ownerId] = None else: ownerIdAndSmartWinsPerGame[ownerId] = ( - ownerIdAndSmartWins[ownerId] / ownerIdAndNumberOfGamesPlayed[ownerId] + ownerIdAndSmartWins[ownerId] + / ownerIdAndNumberOfGamesPlayed[ownerId] ) return ownerIdAndSmartWinsPerGame @classmethod @validateLeague - def getOpponentSmartWins(cls, league: League, **kwargs) -> dict[str, Optional[Deci]]: + def getOpponentSmartWins( + cls, league: League, **kwargs + ) -> dict[str, Optional[Deci]]: """ Returns the number of Smart Wins for each Owner's opponent in the given League. Returns None for an Owner if they have no games played in the range. @@ -161,21 +170,29 @@ def getNumberOfScoresBeatAndTied( # get all scores we want to include in our smart wins calculation ownerIdsAndOpponentScores: list[tuple] = list() - for matchup in cls._getAllFilteredMatchups(league, filters, simplifyMultiWeekMatchups=True): + for matchup in cls._getAllFilteredMatchups( + league, filters, simplifyMultiWeekMatchups=True + ): teamA = LeagueNavigator.getTeamById(league, matchup.teamAId) teamB = LeagueNavigator.getTeamById(league, matchup.teamBId) ownerIdsAndOpponentScores.append((teamA.ownerId, matchup.teamBScore)) ownerIdsAndOpponentScores.append((teamB.ownerId, matchup.teamAScore)) - allScores = LeagueNavigator.getAllScoresInLeague(league, simplifyMultiWeekMatchups=True) + allScores = LeagueNavigator.getAllScoresInLeague( + league, simplifyMultiWeekMatchups=True + ) ownerIdAndOpponentSmartWins = dict() allOwnerIds = LeagueNavigator.getAllOwnerIds(league) for ownerId in allOwnerIds: ownerIdAndOpponentSmartWins[ownerId] = None for ownerId, opponentScore in ownerIdsAndOpponentScores: - scoresBeat, scoresTied = getNumberOfScoresBeatAndTied(opponentScore, allScores) - smartWins = (scoresBeat + (scoresTied / Deci(2))) / (len(allScores) - Deci(1)) + scoresBeat, scoresTied = getNumberOfScoresBeatAndTied( + opponentScore, allScores + ) + smartWins = (scoresBeat + (scoresTied / Deci(2))) / ( + len(allScores) - Deci(1) + ) if ownerIdAndOpponentSmartWins[ownerId] is None: ownerIdAndOpponentSmartWins[ownerId] = smartWins else: @@ -185,7 +202,9 @@ def getNumberOfScoresBeatAndTied( @classmethod @validateLeague - def getOpponentSmartWinsPerGame(cls, league: League, **kwargs) -> dict[str, Optional[Deci]]: + def getOpponentSmartWinsPerGame( + cls, league: League, **kwargs + ) -> dict[str, Optional[Deci]]: """ Returns the number of Smart Wins per game for each Owner's opponent in the given League. Returns None for an Owner if they have no games played in the range. @@ -213,7 +232,8 @@ def getOpponentSmartWinsPerGame(cls, league: League, **kwargs) -> dict[str, Opti ownerIdAndOpponentSmartWinsPerGame[ownerId] = None else: ownerIdAndOpponentSmartWinsPerGame[ownerId] = ( - ownerIdAndOpponentSmartWins[ownerId] / ownerIdAndNumberOfGamesPlayed[ownerId] + ownerIdAndOpponentSmartWins[ownerId] + / ownerIdAndNumberOfGamesPlayed[ownerId] ) return ownerIdAndOpponentSmartWinsPerGame diff --git a/leeger/calculator/all_time_calculator/TeamSummaryAllTimeCalculator.py b/leeger/calculator/all_time_calculator/TeamSummaryAllTimeCalculator.py index 227513ec..18ceb0c6 100644 --- a/leeger/calculator/all_time_calculator/TeamSummaryAllTimeCalculator.py +++ b/leeger/calculator/all_time_calculator/TeamSummaryAllTimeCalculator.py @@ -21,7 +21,9 @@ def getGamesPlayed(cls, league: League, **kwargs) -> dict[str, Optional[int]]: ... } """ - return cls._addAndCombineResults(league, TeamSummaryYearCalculator.getGamesPlayed, **kwargs) + return cls._addAndCombineResults( + league, TeamSummaryYearCalculator.getGamesPlayed, **kwargs + ) @classmethod @validateLeague @@ -40,4 +42,6 @@ def getTotalGames(cls, league: League, **kwargs) -> dict[str, Optional[int]]: ... } """ - return cls._addAndCombineResults(league, TeamSummaryYearCalculator.getTotalGames, **kwargs) + return cls._addAndCombineResults( + league, TeamSummaryYearCalculator.getTotalGames, **kwargs + ) diff --git a/leeger/calculator/all_time_calculator/__init__.py b/leeger/calculator/all_time_calculator/__init__.py index 7ef000bc..c6010104 100644 --- a/leeger/calculator/all_time_calculator/__init__.py +++ b/leeger/calculator/all_time_calculator/__init__.py @@ -3,7 +3,9 @@ from .PlusMinusAllTimeCalculator import PlusMinusAllTimeCalculator from .PointsScoredAllTimeCalculator import PointsScoredAllTimeCalculator from .ScoringShareAllTimeCalculator import ScoringShareAllTimeCalculator -from .ScoringStandardDeviationAllTimeCalculator import ScoringStandardDeviationAllTimeCalculator +from .ScoringStandardDeviationAllTimeCalculator import ( + ScoringStandardDeviationAllTimeCalculator, +) from .SingleScoreAllTimeCalculator import SingleScoreAllTimeCalculator from .SmartWinsAllTimeCalculator import SmartWinsAllTimeCalculator from .SSLAllTimeCalculator import SSLAllTimeCalculator diff --git a/leeger/calculator/parent/AllTimeCalculator.py b/leeger/calculator/parent/AllTimeCalculator.py index e8d184c5..56c09f77 100644 --- a/leeger/calculator/parent/AllTimeCalculator.py +++ b/leeger/calculator/parent/AllTimeCalculator.py @@ -41,7 +41,9 @@ def _addAndCombineResults( # sum all results result: dict[str, int | float | Deci] = dict() for ownerId in LeagueNavigator.getAllOwnerIds(league): - result[ownerId] = 0 # TODO: this may have a Deci/int/float so test for bugs there + result[ownerId] = ( + 0 # TODO: this may have a Deci/int/float so test for bugs there + ) ownerIdAndWhetherOwnerHasHadAValidResult[ownerId] = False for resultDict in allResultDicts: @@ -76,7 +78,9 @@ def __getAllResultDicts( if allTimeFilters.yearNumberStart == allTimeFilters.yearNumberEnd: yearWeekNumberStartWeekNumberEnd.append( ( - LeagueNavigator.getYearByYearNumber(league, allTimeFilters.yearNumberStart), + LeagueNavigator.getYearByYearNumber( + league, allTimeFilters.yearNumberStart + ), allTimeFilters.weekNumberStart, allTimeFilters.weekNumberEnd, ) @@ -92,9 +96,13 @@ def __getAllResultDicts( elif year.yearNumber == allTimeFilters.yearNumberEnd: # last year we want, make sure week number end matches what was requested # first week and every week til givenWeekEnd - yearWeekNumberStartWeekNumberEnd.append((year, 1, allTimeFilters.weekNumberEnd)) + yearWeekNumberStartWeekNumberEnd.append( + (year, 1, allTimeFilters.weekNumberEnd) + ) elif ( - allTimeFilters.yearNumberStart < year.yearNumber < allTimeFilters.yearNumberEnd + allTimeFilters.yearNumberStart + < year.yearNumber + < allTimeFilters.yearNumberEnd ): # this year is in our year range, include every week in this year yearWeekNumberStartWeekNumberEnd.append((year, 1, len(year.weeks))) @@ -133,7 +141,9 @@ def _getAllResultDictsByYear( if allTimeFilters.yearNumberStart == allTimeFilters.yearNumberEnd: yearWeekNumberStartWeekNumberEnd.append( ( - LeagueNavigator.getYearByYearNumber(league, allTimeFilters.yearNumberStart), + LeagueNavigator.getYearByYearNumber( + league, allTimeFilters.yearNumberStart + ), allTimeFilters.weekNumberStart, allTimeFilters.weekNumberEnd, ) @@ -149,9 +159,13 @@ def _getAllResultDictsByYear( elif year.yearNumber == allTimeFilters.yearNumberEnd: # last year we want, make sure week number end matches what was requested # first week and every week til givenWeekEnd - yearWeekNumberStartWeekNumberEnd.append((year, 1, allTimeFilters.weekNumberEnd)) + yearWeekNumberStartWeekNumberEnd.append( + (year, 1, allTimeFilters.weekNumberEnd) + ) elif ( - allTimeFilters.yearNumberStart < year.yearNumber < allTimeFilters.yearNumberEnd + allTimeFilters.yearNumberStart + < year.yearNumber + < allTimeFilters.yearNumberEnd ): # this year is in our year range, include every week in this year yearWeekNumberStartWeekNumberEnd.append((year, 1, len(year.weeks))) @@ -175,7 +189,10 @@ def _getAllResultDictsByYear( @classmethod def _getAllFilteredMatchups( - cls, league: League, allTimeFilters: AllTimeFilters, simplifyMultiWeekMatchups=False + cls, + league: League, + allTimeFilters: AllTimeFilters, + simplifyMultiWeekMatchups=False, ) -> list[Matchup]: """ Returns all Matchups in the given League that are remaining after the given filters are applied. @@ -186,7 +203,9 @@ def _getAllFilteredMatchups( if allTimeFilters.yearNumberStart == allTimeFilters.yearNumberEnd: yearWeekNumberStartWeekNumberEnd.append( ( - LeagueNavigator.getYearByYearNumber(league, allTimeFilters.yearNumberStart), + LeagueNavigator.getYearByYearNumber( + league, allTimeFilters.yearNumberStart + ), allTimeFilters.weekNumberStart, allTimeFilters.weekNumberEnd, ) @@ -202,9 +221,13 @@ def _getAllFilteredMatchups( elif year.yearNumber == allTimeFilters.yearNumberEnd: # last year we want, make sure week number end matches what was requested # first week and every week til givenWeekEnd - yearWeekNumberStartWeekNumberEnd.append((year, 1, allTimeFilters.weekNumberEnd)) + yearWeekNumberStartWeekNumberEnd.append( + (year, 1, allTimeFilters.weekNumberEnd) + ) elif ( - allTimeFilters.yearNumberStart < year.yearNumber < allTimeFilters.yearNumberEnd + allTimeFilters.yearNumberStart + < year.yearNumber + < allTimeFilters.yearNumberEnd ): # this year is in our year range, include every week in this year yearWeekNumberStartWeekNumberEnd.append((year, 1, len(year.weeks))) @@ -231,16 +254,18 @@ def _getAllFilteredMatchups( matchup.multiWeekMatchupId ].append(matchup) else: - multiWeekMatchupIdToMatchupsMap[matchup.multiWeekMatchupId] = [ - matchup - ] + multiWeekMatchupIdToMatchupsMap[ + matchup.multiWeekMatchupId + ] = [matchup] else: allFilteredMatchups.append(matchup) if simplifyMultiWeekMatchups: # simplify any multi-week matchups and add them to the returning list for _, matchupList in multiWeekMatchupIdToMatchupsMap.items(): - allFilteredMatchups.append(MatchupNavigator.simplifyMultiWeekMatchups(matchupList)) + allFilteredMatchups.append( + MatchupNavigator.simplifyMultiWeekMatchups(matchupList) + ) return allFilteredMatchups @@ -300,7 +325,9 @@ def _allTimeFiltersToYearFilters( onlyRegularSeason=allTimeFilters.onlyRegularSeason, ) elif ( - allTimeFilters.yearNumberStart < year.yearNumber < allTimeFilters.yearNumberEnd + allTimeFilters.yearNumberStart + < year.yearNumber + < allTimeFilters.yearNumberEnd ): # this year is in our year range, include every week in this year yearFiltersByYear[str(year.yearNumber)] = YearFilters( diff --git a/leeger/calculator/parent/YearCalculator.py b/leeger/calculator/parent/YearCalculator.py index f5c94d23..3254c7f6 100644 --- a/leeger/calculator/parent/YearCalculator.py +++ b/leeger/calculator/parent/YearCalculator.py @@ -29,15 +29,23 @@ def _getAllFilteredMatchups( @classmethod def _setToNoneIfNoGamesPlayed( - cls, responseDict: dict[str, Any], year: Year, yearFilters: YearFilters = None, **kwargs + cls, + responseDict: dict[str, Any], + year: Year, + yearFilters: YearFilters = None, + **kwargs, ) -> None: """ Takes a response dict and sets any value to None where the Team ID has no games played in the given range. """ yearFilters = ( - yearFilters if yearFilters is not None else YearFilters.getForYear(year, **kwargs) + yearFilters + if yearFilters is not None + else YearFilters.getForYear(year, **kwargs) + ) + teamIdAndNumberOfGamesPlayed = YearNavigator.getNumberOfGamesPlayed( + year, yearFilters ) - teamIdAndNumberOfGamesPlayed = YearNavigator.getNumberOfGamesPlayed(year, yearFilters) for teamId in responseDict: if teamIdAndNumberOfGamesPlayed[teamId] == 0: diff --git a/leeger/calculator/year_calculator/AWALYearCalculator.py b/leeger/calculator/year_calculator/AWALYearCalculator.py index 7866811b..47ead214 100644 --- a/leeger/calculator/year_calculator/AWALYearCalculator.py +++ b/leeger/calculator/year_calculator/AWALYearCalculator.py @@ -1,7 +1,9 @@ from typing import Optional from leeger.calculator.parent.YearCalculator import YearCalculator -from leeger.calculator.year_calculator.GameOutcomeYearCalculator import GameOutcomeYearCalculator +from leeger.calculator.year_calculator.GameOutcomeYearCalculator import ( + GameOutcomeYearCalculator, +) from leeger.decorator.validators import validateYear from leeger.model.filter import YearFilters from leeger.model.filter.WeekFilters import WeekFilters @@ -91,7 +93,9 @@ def getAWAL(cls, year: Year, **kwargs) -> dict[str, Optional[Deci]]: ) for teamId in allTeamIds: leagueMedianWins = teamIdAndLeagueMedianWins[teamId] - teamIdAndAWAL[teamId] = GeneralUtil.safeSum(teamIdAndAWAL[teamId], leagueMedianWins) + teamIdAndAWAL[teamId] = GeneralUtil.safeSum( + teamIdAndAWAL[teamId], leagueMedianWins + ) cls._setToNoneIfNoGamesPlayed(teamIdAndAWAL, year, filters, **kwargs) return teamIdAndAWAL @@ -114,7 +118,9 @@ def getAWALPerGame(cls, year: Year, **kwargs) -> dict[str, Optional[Deci]]: teamIdAndAWAL = AWALYearCalculator.getAWAL(year, **kwargs) teamIdAndNumberOfGamesPlayed = YearNavigator.getNumberOfGamesPlayed( - year, YearFilters.getForYear(year, **kwargs), countLeagueMedianGamesAsTwoGames=True + year, + YearFilters.getForYear(year, **kwargs), + countLeagueMedianGamesAsTwoGames=True, ) teamIdAndAWALPerGame = dict() @@ -164,8 +170,10 @@ def getOpponentAWAL(cls, year: Year, **kwargs) -> dict[str, Optional[Deci]]: for teamId in allTeamIds: teamsOutscored[teamId] = 0 teamsTied[teamId] = 0 - allTeamIdsAndOpponentScoresForWeek = WeekNavigator.getTeamIdsAndOpponentScores( - week, WeekFilters(includeMatchupTypes=filters.includeMatchupTypes) + allTeamIdsAndOpponentScoresForWeek = ( + WeekNavigator.getTeamIdsAndOpponentScores( + week, WeekFilters(includeMatchupTypes=filters.includeMatchupTypes) + ) ) allScores = allTeamIdsAndOpponentScoresForWeek.values() @@ -187,8 +195,8 @@ def getOpponentAWAL(cls, year: Year, **kwargs) -> dict[str, Optional[Deci]]: # add league median wins if applicable if year.yearSettings.leagueMedianGames: - teamIdAndLeagueMedianWins = GameOutcomeYearCalculator.getOpponentLeagueMedianWins( - year, **kwargs + teamIdAndLeagueMedianWins = ( + GameOutcomeYearCalculator.getOpponentLeagueMedianWins(year, **kwargs) ) for teamId in allTeamIds: leagueMedianWins = teamIdAndLeagueMedianWins[teamId] @@ -217,7 +225,9 @@ def getOpponentAWALPerGame(cls, year: Year, **kwargs) -> dict[str, Optional[Deci teamIdAndOpponentAWAL = AWALYearCalculator.getOpponentAWAL(year, **kwargs) teamIdAndNumberOfGamesPlayed = YearNavigator.getNumberOfGamesPlayed( - year, YearFilters.getForYear(year, **kwargs), countLeagueMedianGamesAsTwoGames=True + year, + YearFilters.getForYear(year, **kwargs), + countLeagueMedianGamesAsTwoGames=True, ) teamIdAndOpponentAWALPerGame = dict() diff --git a/leeger/calculator/year_calculator/GameOutcomeYearCalculator.py b/leeger/calculator/year_calculator/GameOutcomeYearCalculator.py index 0278472c..c3977138 100644 --- a/leeger/calculator/year_calculator/GameOutcomeYearCalculator.py +++ b/leeger/calculator/year_calculator/GameOutcomeYearCalculator.py @@ -116,7 +116,9 @@ def getLosses(cls, year: Year, **kwargs) -> dict[str, Optional[int]]: winnerTeamId = MatchupNavigator.getTeamIdOfMatchupWinner(matchup) if winnerTeamId is not None: loserTeamId = ( - matchup.teamAId if winnerTeamId == matchup.teamBId else matchup.teamBId + matchup.teamAId + if winnerTeamId == matchup.teamBId + else matchup.teamBId ) teamIdAndLosses[loserTeamId] += 1 cls._setToNoneIfNoGamesPlayed(teamIdAndLosses, year, filters, **kwargs) @@ -197,14 +199,21 @@ def getWinPercentage(cls, year: Year, **kwargs) -> dict[str, Optional[Deci]]: teamIdAndWins = GameOutcomeYearCalculator.getWins(year, **kwargs) teamIdAndLosses = GameOutcomeYearCalculator.getLosses(year, **kwargs) teamIdAndTies = GameOutcomeYearCalculator.getTies(year, **kwargs) - teamIdAndLeagueMedianWins = GameOutcomeYearCalculator.getLeagueMedianWins(year, **kwargs) + teamIdAndLeagueMedianWins = GameOutcomeYearCalculator.getLeagueMedianWins( + year, **kwargs + ) for teamId in YearNavigator.getAllTeamIds(year): numberOfWins = teamIdAndWins[teamId] numberOfLosses = teamIdAndLosses[teamId] numberOfTies = teamIdAndTies[teamId] numberOfLeagueMedianWins = teamIdAndLeagueMedianWins[teamId] - if None in (numberOfWins, numberOfLosses, numberOfTies, numberOfLeagueMedianWins): + if None in ( + numberOfWins, + numberOfLosses, + numberOfTies, + numberOfLeagueMedianWins, + ): teamIdAndWinPercentage[teamId] = None else: numberOfGamesPlayed = numberOfWins + numberOfLosses + numberOfTies @@ -247,7 +256,9 @@ def getWAL(cls, year: Year, **kwargs) -> dict[str, Optional[Deci]]: teamIdAndWAL = dict() teamIdAndWins = GameOutcomeYearCalculator.getWins(year, **kwargs) teamIdAndTies = GameOutcomeYearCalculator.getTies(year, **kwargs) - teamIdAndLeagueMedianWins = GameOutcomeYearCalculator.getLeagueMedianWins(year, **kwargs) + teamIdAndLeagueMedianWins = GameOutcomeYearCalculator.getLeagueMedianWins( + year, **kwargs + ) for teamId in YearNavigator.getAllTeamIds(year): wins = teamIdAndWins[teamId] @@ -357,12 +368,16 @@ def getLeagueMedianWins(cls, year: Year, **kwargs) -> dict[str, Optional[Deci]]: elif score == leagueMedianScore: teamIdAndLeagueMedianWins[teamId] += Deci("0.5") - cls._setToNoneIfNoGamesPlayed(teamIdAndLeagueMedianWins, year, filters, **kwargs) + cls._setToNoneIfNoGamesPlayed( + teamIdAndLeagueMedianWins, year, filters, **kwargs + ) return teamIdAndLeagueMedianWins @classmethod @validateYear - def getOpponentLeagueMedianWins(cls, year: Year, **kwargs) -> dict[str, Optional[Deci]]: + def getOpponentLeagueMedianWins( + cls, year: Year, **kwargs + ) -> dict[str, Optional[Deci]]: """ Returns the number of league median wins for each team's opponent in the given Year. Returns None for a Team if they have no games played in the range. @@ -395,8 +410,12 @@ def getOpponentLeagueMedianWins(cls, year: Year, **kwargs) -> dict[str, Optional for matchup in week.matchups: if matchup.matchupType in filters.includeMatchupTypes: week_matchups.append(matchup) - teamIdAndOpponentScoreList.append((matchup.teamAId, matchup.teamBScore)) - teamIdAndOpponentScoreList.append((matchup.teamBId, matchup.teamAScore)) + teamIdAndOpponentScoreList.append( + (matchup.teamAId, matchup.teamBScore) + ) + teamIdAndOpponentScoreList.append( + (matchup.teamBId, matchup.teamAScore) + ) if len(week_matchups) > 0: leagueMedianScore = MatchupNavigator.getMedianScore(week_matchups) @@ -411,5 +430,7 @@ def getOpponentLeagueMedianWins(cls, year: Year, **kwargs) -> dict[str, Optional elif score == leagueMedianScore: teamIdAndOpponentLeagueMedianWins[teamId] += Deci("0.5") - cls._setToNoneIfNoGamesPlayed(teamIdAndOpponentLeagueMedianWins, year, filters, **kwargs) + cls._setToNoneIfNoGamesPlayed( + teamIdAndOpponentLeagueMedianWins, year, filters, **kwargs + ) return teamIdAndOpponentLeagueMedianWins diff --git a/leeger/calculator/year_calculator/PlusMinusYearCalculator.py b/leeger/calculator/year_calculator/PlusMinusYearCalculator.py index 17b743e6..0a32f908 100644 --- a/leeger/calculator/year_calculator/PlusMinusYearCalculator.py +++ b/leeger/calculator/year_calculator/PlusMinusYearCalculator.py @@ -1,7 +1,9 @@ from typing import Optional from leeger.calculator.parent.YearCalculator import YearCalculator -from leeger.calculator.year_calculator.PointsScoredYearCalculator import PointsScoredYearCalculator +from leeger.calculator.year_calculator.PointsScoredYearCalculator import ( + PointsScoredYearCalculator, +) from leeger.decorator.validators import validateYear from leeger.model.league.Year import Year from leeger.util.Deci import Deci @@ -37,10 +39,12 @@ def getPlusMinus(cls, year: Year, **kwargs) -> dict[str, Optional[Deci]]: """ teamIdAndPlusMinus = dict() - teamIdAndPointsScored = PointsScoredYearCalculator.getPointsScored(year, **kwargs) - teamIdAndOpponentPointsScored = PointsScoredYearCalculator.getOpponentPointsScored( + teamIdAndPointsScored = PointsScoredYearCalculator.getPointsScored( year, **kwargs ) + teamIdAndOpponentPointsScored = ( + PointsScoredYearCalculator.getOpponentPointsScored(year, **kwargs) + ) for teamId in YearNavigator.getAllTeamIds(year): pointsScored = teamIdAndPointsScored[teamId] opponentPointsScored = teamIdAndOpponentPointsScored[teamId] @@ -48,7 +52,8 @@ def getPlusMinus(cls, year: Year, **kwargs) -> dict[str, Optional[Deci]]: teamIdAndPlusMinus[teamId] = None else: teamIdAndPlusMinus[teamId] = ( - teamIdAndPointsScored[teamId] - teamIdAndOpponentPointsScored[teamId] + teamIdAndPointsScored[teamId] + - teamIdAndOpponentPointsScored[teamId] ) return teamIdAndPlusMinus diff --git a/leeger/calculator/year_calculator/PointsScoredYearCalculator.py b/leeger/calculator/year_calculator/PointsScoredYearCalculator.py index bd2e3006..f491de5f 100644 --- a/leeger/calculator/year_calculator/PointsScoredYearCalculator.py +++ b/leeger/calculator/year_calculator/PointsScoredYearCalculator.py @@ -103,15 +103,23 @@ def getOpponentPointsScored(cls, year: Year, **kwargs) -> dict[str, Optional[Dec week = year.weeks[i] for matchup in week.matchups: if matchup.matchupType in filters.includeMatchupTypes: - teamIdAndOpponentPointsScored[matchup.teamAId] += Deci(matchup.teamBScore) - teamIdAndOpponentPointsScored[matchup.teamBId] += Deci(matchup.teamAScore) - - cls._setToNoneIfNoGamesPlayed(teamIdAndOpponentPointsScored, year, filters, **kwargs) + teamIdAndOpponentPointsScored[matchup.teamAId] += Deci( + matchup.teamBScore + ) + teamIdAndOpponentPointsScored[matchup.teamBId] += Deci( + matchup.teamAScore + ) + + cls._setToNoneIfNoGamesPlayed( + teamIdAndOpponentPointsScored, year, filters, **kwargs + ) return teamIdAndOpponentPointsScored @classmethod @validateYear - def getOpponentPointsScoredPerGame(cls, year: Year, **kwargs) -> dict[str, Optional[Deci]]: + def getOpponentPointsScoredPerGame( + cls, year: Year, **kwargs + ) -> dict[str, Optional[Deci]]: """ Returns the number of opponent Points Scored per game for each team in the given Year. Returns None for a Team if they have no games played in the range. @@ -138,7 +146,8 @@ def getOpponentPointsScoredPerGame(cls, year: Year, **kwargs) -> dict[str, Optio teamIdAndOpponentPointsScoredPerGame[teamId] = None else: teamIdAndOpponentPointsScoredPerGame[teamId] = ( - teamIdAndOpponentPointsScored[teamId] / teamIdAndNumberOfGamesPlayed[teamId] + teamIdAndOpponentPointsScored[teamId] + / teamIdAndNumberOfGamesPlayed[teamId] ) return teamIdAndOpponentPointsScoredPerGame diff --git a/leeger/calculator/year_calculator/SSLYearCalculator.py b/leeger/calculator/year_calculator/SSLYearCalculator.py index 91e5a964..6402ef04 100644 --- a/leeger/calculator/year_calculator/SSLYearCalculator.py +++ b/leeger/calculator/year_calculator/SSLYearCalculator.py @@ -2,9 +2,15 @@ from leeger.calculator.parent.YearCalculator import YearCalculator from leeger.calculator.year_calculator.AWALYearCalculator import AWALYearCalculator -from leeger.calculator.year_calculator.GameOutcomeYearCalculator import GameOutcomeYearCalculator -from leeger.calculator.year_calculator.ScoringShareYearCalculator import ScoringShareYearCalculator -from leeger.calculator.year_calculator.SingleScoreYearCalculator import SingleScoreYearCalculator +from leeger.calculator.year_calculator.GameOutcomeYearCalculator import ( + GameOutcomeYearCalculator, +) +from leeger.calculator.year_calculator.ScoringShareYearCalculator import ( + ScoringShareYearCalculator, +) +from leeger.calculator.year_calculator.SingleScoreYearCalculator import ( + SingleScoreYearCalculator, +) from leeger.decorator.validators import validateYear from leeger.model.league.Year import Year from leeger.util.Deci import Deci @@ -57,7 +63,9 @@ def getTeamScore(cls, year: Year, **kwargs) -> dict[str, Optional[Deci]]: teamIdAndTeamScore = dict() for teamId in YearNavigator.getAllTeamIds(year): awalPerGame = AWALYearCalculator.getAWALPerGame(year, **kwargs)[teamId] - scoringShare = ScoringShareYearCalculator.getScoringShare(year, **kwargs)[teamId] + scoringShare = ScoringShareYearCalculator.getScoringShare(year, **kwargs)[ + teamId + ] maxScore = SingleScoreYearCalculator.getMaxScore(year, **kwargs)[teamId] minScore = SingleScoreYearCalculator.getMinScore(year, **kwargs)[teamId] @@ -68,7 +76,10 @@ def getTeamScore(cls, year: Year, **kwargs) -> dict[str, Optional[Deci]]: teamIdAndTeamScore[teamId] = ( (awalPerGame * Deci(cls.__AWAL_AND_WAL_PER_GAME_MULTIPLIER)) + (scoringShare * Deci(cls.__SCORING_SHARE_MULTIPLIER)) - + ((Deci(maxScore) + Deci(minScore)) * Deci(cls.__MAX_AND_MIN_SCORE_MULTIPLIER)) + + ( + (Deci(maxScore) + Deci(minScore)) + * Deci(cls.__MAX_AND_MIN_SCORE_MULTIPLIER) + ) ) return teamIdAndTeamScore @@ -96,7 +107,9 @@ def getTeamSuccess(cls, year: Year, **kwargs) -> dict[str, Optional[Deci]]: teamIdAndTeamSuccess = dict() for teamId in YearNavigator.getAllTeamIds(year): walPerGame = GameOutcomeYearCalculator.getWALPerGame(year, **kwargs)[teamId] - scoringShare = ScoringShareYearCalculator.getScoringShare(year, **kwargs)[teamId] + scoringShare = ScoringShareYearCalculator.getScoringShare(year, **kwargs)[ + teamId + ] maxScore = SingleScoreYearCalculator.getMaxScore(year, **kwargs)[teamId] minScore = SingleScoreYearCalculator.getMinScore(year, **kwargs)[teamId] @@ -107,7 +120,10 @@ def getTeamSuccess(cls, year: Year, **kwargs) -> dict[str, Optional[Deci]]: teamIdAndTeamSuccess[teamId] = ( (walPerGame * Deci(cls.__AWAL_AND_WAL_PER_GAME_MULTIPLIER)) + (scoringShare * Deci(cls.__SCORING_SHARE_MULTIPLIER)) - + ((Deci(maxScore) + Deci(minScore)) * Deci(cls.__MAX_AND_MIN_SCORE_MULTIPLIER)) + + ( + (Deci(maxScore) + Deci(minScore)) + * Deci(cls.__MAX_AND_MIN_SCORE_MULTIPLIER) + ) ) return teamIdAndTeamSuccess diff --git a/leeger/calculator/year_calculator/ScoringShareYearCalculator.py b/leeger/calculator/year_calculator/ScoringShareYearCalculator.py index bf92c783..6a1a4906 100644 --- a/leeger/calculator/year_calculator/ScoringShareYearCalculator.py +++ b/leeger/calculator/year_calculator/ScoringShareYearCalculator.py @@ -1,7 +1,9 @@ from typing import Optional from leeger.calculator.parent.YearCalculator import YearCalculator -from leeger.calculator.year_calculator.PointsScoredYearCalculator import PointsScoredYearCalculator +from leeger.calculator.year_calculator.PointsScoredYearCalculator import ( + PointsScoredYearCalculator, +) from leeger.decorator.validators import validateYear from leeger.model.filter import WeekFilters, YearFilters from leeger.model.league.Year import Year @@ -39,7 +41,9 @@ def getScoringShare(cls, year: Year, **kwargs) -> dict[str, Optional[Deci]]: } """ - teamIdAndPointsScored = PointsScoredYearCalculator.getPointsScored(year, **kwargs) + teamIdAndPointsScored = PointsScoredYearCalculator.getPointsScored( + year, **kwargs + ) allScores = GeneralUtil.filter(value=None, list_=teamIdAndPointsScored.values()) totalPointsScoredInYear = sum(allScores) teamIdAndScoringShare = dict() @@ -80,10 +84,12 @@ def getOpponentScoringShare(cls, year: Year, **kwargs) -> dict[str, Optional[Dec } """ - teamIdAndOpponentPointsScored = PointsScoredYearCalculator.getOpponentPointsScored( - year, **kwargs + teamIdAndOpponentPointsScored = ( + PointsScoredYearCalculator.getOpponentPointsScored(year, **kwargs) + ) + allScores = GeneralUtil.filter( + value=None, list_=teamIdAndOpponentPointsScored.values() ) - allScores = GeneralUtil.filter(value=None, list_=teamIdAndOpponentPointsScored.values()) totalPointsScoredInYear = sum(allScores) teamIdAndOpponentScoringShare = dict() for teamId in YearNavigator.getAllTeamIds(year): diff --git a/leeger/calculator/year_calculator/ScoringStandardDeviationYearCalculator.py b/leeger/calculator/year_calculator/ScoringStandardDeviationYearCalculator.py index aea60ebc..b406f3b5 100644 --- a/leeger/calculator/year_calculator/ScoringStandardDeviationYearCalculator.py +++ b/leeger/calculator/year_calculator/ScoringStandardDeviationYearCalculator.py @@ -17,7 +17,9 @@ class ScoringStandardDeviationYearCalculator(YearCalculator): @classmethod @validateYear - def getScoringStandardDeviation(cls, year: Year, **kwargs) -> dict[str, Optional[Deci]]: + def getScoringStandardDeviation( + cls, year: Year, **kwargs + ) -> dict[str, Optional[Deci]]: """ Scoring STDEV (Standard Deviation) is used to show how volatile a team's scoring was. This stat measures a team's scores relative to the mean (or PPG) of all of their scores. @@ -56,7 +58,9 @@ def getScoringStandardDeviation(cls, year: Year, **kwargs) -> dict[str, Optional for teamId in allTeamIds: if len(teamIdAndScores[teamId]) > 0: # the Team has scores in this range - teamIdAndScoringStandardDeviation[teamId] = Deci(numpy.std(teamIdAndScores[teamId])) + teamIdAndScoringStandardDeviation[teamId] = Deci( + numpy.std(teamIdAndScores[teamId]) + ) else: # no scores for this Team in this range, return None for them teamIdAndScoringStandardDeviation[teamId] = None diff --git a/leeger/calculator/year_calculator/SmartWinsYearCalculator.py b/leeger/calculator/year_calculator/SmartWinsYearCalculator.py index bd036130..2f541682 100644 --- a/leeger/calculator/year_calculator/SmartWinsYearCalculator.py +++ b/leeger/calculator/year_calculator/SmartWinsYearCalculator.py @@ -73,10 +73,14 @@ def getNumberOfScoresBeatAndTied( for teamId in allTeamIds: teamIdAndSmartWins[teamId] = Deci(0) - allScores = YearNavigator.getAllScoresInYear(year, simplifyMultiWeekMatchups=True) + allScores = YearNavigator.getAllScoresInYear( + year, simplifyMultiWeekMatchups=True + ) for teamId, score in teamIdsAndScores: scoresBeat, scoresTied = getNumberOfScoresBeatAndTied(score, allScores) - smartWins = (scoresBeat + (scoresTied / Deci("2"))) / (len(allScores) - Deci("1")) + smartWins = (scoresBeat + (scoresTied / Deci("2"))) / ( + len(allScores) - Deci("1") + ) teamIdAndSmartWins[teamId] += smartWins cls._setToNoneIfNoGamesPlayed(teamIdAndSmartWins, year, filters, **kwargs) @@ -100,7 +104,9 @@ def getSmartWinsPerGame(cls, year: Year, **kwargs) -> dict[str, Optional[Deci]]: teamIdAndSmartWins = SmartWinsYearCalculator.getSmartWins(year, **kwargs) teamIdAndNumberOfGamesPlayed = YearNavigator.getNumberOfGamesPlayed( - year, YearFilters.getForYear(year, **kwargs), countMultiWeekMatchupsAsOneGame=True + year, + YearFilters.getForYear(year, **kwargs), + countMultiWeekMatchupsAsOneGame=True, ) teamIdAndSmartWinsPerGame = dict() @@ -167,18 +173,26 @@ def getNumberOfScoresBeatAndTied( for teamId in allTeamIds: teamIdAndOpponentSmartWins[teamId] = Deci(0) - allScores = YearNavigator.getAllScoresInYear(year, simplifyMultiWeekMatchups=True) + allScores = YearNavigator.getAllScoresInYear( + year, simplifyMultiWeekMatchups=True + ) for teamId, score in teamIdsAndScores: scoresBeat, scoresTied = getNumberOfScoresBeatAndTied(score, allScores) - smartWins = (scoresBeat + (scoresTied / Deci("2"))) / (len(allScores) - Deci("1")) + smartWins = (scoresBeat + (scoresTied / Deci("2"))) / ( + len(allScores) - Deci("1") + ) teamIdAndOpponentSmartWins[teamId] += smartWins - cls._setToNoneIfNoGamesPlayed(teamIdAndOpponentSmartWins, year, filters, **kwargs) + cls._setToNoneIfNoGamesPlayed( + teamIdAndOpponentSmartWins, year, filters, **kwargs + ) return teamIdAndOpponentSmartWins @classmethod @validateYear - def getOpponentSmartWinsPerGame(cls, year: Year, **kwargs) -> dict[str, Optional[Deci]]: + def getOpponentSmartWinsPerGame( + cls, year: Year, **kwargs + ) -> dict[str, Optional[Deci]]: """ Returns the number of Smart Wins per game for each team's opponents in the given Year. Returns None for a Team if they have no games played in the range. @@ -192,9 +206,13 @@ def getOpponentSmartWinsPerGame(cls, year: Year, **kwargs) -> dict[str, Optional } """ - teamIdAndOpponentSmartWins = SmartWinsYearCalculator.getOpponentSmartWins(year, **kwargs) + teamIdAndOpponentSmartWins = SmartWinsYearCalculator.getOpponentSmartWins( + year, **kwargs + ) teamIdAndNumberOfGamesPlayed = YearNavigator.getNumberOfGamesPlayed( - year, YearFilters.getForYear(year, **kwargs), countMultiWeekMatchupsAsOneGame=True + year, + YearFilters.getForYear(year, **kwargs), + countMultiWeekMatchupsAsOneGame=True, ) teamIdAndOpponentSmartWinsPerGame = dict() @@ -205,7 +223,8 @@ def getOpponentSmartWinsPerGame(cls, year: Year, **kwargs) -> dict[str, Optional teamIdAndOpponentSmartWinsPerGame[teamId] = None else: teamIdAndOpponentSmartWinsPerGame[teamId] = ( - teamIdAndOpponentSmartWins[teamId] / teamIdAndNumberOfGamesPlayed[teamId] + teamIdAndOpponentSmartWins[teamId] + / teamIdAndNumberOfGamesPlayed[teamId] ) return teamIdAndOpponentSmartWinsPerGame diff --git a/leeger/calculator/year_calculator/__init__.py b/leeger/calculator/year_calculator/__init__.py index ffc03a58..469b4878 100644 --- a/leeger/calculator/year_calculator/__init__.py +++ b/leeger/calculator/year_calculator/__init__.py @@ -3,7 +3,9 @@ from .PlusMinusYearCalculator import PlusMinusYearCalculator from .PointsScoredYearCalculator import PointsScoredYearCalculator from .ScoringShareYearCalculator import ScoringShareYearCalculator -from .ScoringStandardDeviationYearCalculator import ScoringStandardDeviationYearCalculator +from .ScoringStandardDeviationYearCalculator import ( + ScoringStandardDeviationYearCalculator, +) from .SingleScoreYearCalculator import SingleScoreYearCalculator from .SmartWinsYearCalculator import SmartWinsYearCalculator from .SSLYearCalculator import SSLYearCalculator diff --git a/leeger/decorator/validators.py b/leeger/decorator/validators.py index 10d7b65f..ee85f114 100644 --- a/leeger/decorator/validators.py +++ b/leeger/decorator/validators.py @@ -5,7 +5,12 @@ from leeger.model.league.Matchup import Matchup from leeger.model.league.Week import Week from leeger.model.league.Year import Year -from leeger.validate import leagueValidation, matchupValidation, weekValidation, yearValidation +from leeger.validate import ( + leagueValidation, + matchupValidation, + weekValidation, + yearValidation, +) def __shouldValidate(kwargs) -> bool: diff --git a/leeger/league_loader/ESPNLeagueLoader.py b/leeger/league_loader/ESPNLeagueLoader.py index badb400e..fbc899b3 100644 --- a/leeger/league_loader/ESPNLeagueLoader.py +++ b/leeger/league_loader/ESPNLeagueLoader.py @@ -50,15 +50,18 @@ def __init__( except ValueError: raise ValueError(f"League ID '{leagueId}' could not be turned into an int.") super().__init__( - leagueId, years, ownerNamesAndAliases=ownerNamesAndAliases, leagueName=leagueName + leagueId, + years, + ownerNamesAndAliases=ownerNamesAndAliases, + leagueName=leagueName, ) self.__espnS2 = espnS2 self.__swid = swid self.__espnTeamIdToTeamMap: dict[str, Team] = dict() - self.__espnDivisionIdToDivisionMap: dict[ - int, Division - ] = dict() # holds the division info for ONLY the current year + self.__espnDivisionIdToDivisionMap: dict[int, Division] = ( + dict() + ) # holds the division info for ONLY the current year def __getAllLeagues(self) -> list[ESPNLeague]: espnLeagueYears = list() @@ -100,7 +103,9 @@ def __buildLeague(self, espnLeagues: list[ESPNLeague]) -> League: self.__loadOwners(espnLeague.teams) years.append(self.__buildYear(espnLeague)) return League( - name=self._getLeagueName(), owners=self._owners, years=self._getValidYears(years) + name=self._getLeagueName(), + owners=self._owners, + years=self._getValidYears(years), ) def __loadOwners(self, espnTeams: list[ESPNTeam]) -> None: @@ -109,15 +114,24 @@ def __loadOwners(self, espnTeams: list[ESPNTeam]) -> None: for espnTeam in espnTeams: # get general owner name if there is one ownerName = self.__getESPNOwnerName(espnTeam.owners) - generalOwnerName = self._getGeneralOwnerNameFromGivenOwnerName(ownerName) - ownerName = generalOwnerName if generalOwnerName is not None else ownerName + generalOwnerName = self._getGeneralOwnerNameFromGivenOwnerName( + ownerName + ) + ownerName = ( + generalOwnerName if generalOwnerName is not None else ownerName + ) owners.append(Owner(name=ownerName)) self._owners = owners def __buildYear(self, espnLeague: ESPNLeague) -> Year: # save division info - for espnDivisionId, espnDivisionName in espnLeague.settings.division_map.items(): - self.__espnDivisionIdToDivisionMap[espnDivisionId] = Division(name=espnDivisionName) + for ( + espnDivisionId, + espnDivisionName, + ) in espnLeague.settings.division_map.items(): + self.__espnDivisionIdToDivisionMap[espnDivisionId] = Division( + name=espnDivisionName + ) teams = self.__buildTeams(espnLeague.teams) weeks = self.__buildWeeks(espnLeague) # TODO: see if there are cases where ESPN leagues do NOT have divisions @@ -160,12 +174,16 @@ def __buildWeeks(self, espnLeague: ESPNLeague) -> list[Week]: ).scores[i] # figure out tiebreakers if there needs to be one teamAHasTiebreaker = ( - teamAScore == teamBScore and espnTeamA.outcomes[i] == self.__ESPN_WIN_OUTCOME + teamAScore == teamBScore + and espnTeamA.outcomes[i] == self.__ESPN_WIN_OUTCOME ) teamBHasTiebreaker = ( - teamAScore == teamBScore and espnTeamB.outcomes[i] == self.__ESPN_WIN_OUTCOME + teamAScore == teamBScore + and espnTeamB.outcomes[i] == self.__ESPN_WIN_OUTCOME + ) + matchupType = self.__getMatchupType( + espnLeague, i + 1, espnTeamA.team_id ) - matchupType = self.__getMatchupType(espnLeague, i + 1, espnTeamA.team_id) matchups.append( Matchup( teamAId=teamA.id, @@ -194,11 +212,14 @@ def __getMatchupType( if playoffTeamCount >= espnTeam.standing: # this team made the playoffs # figure out if this is the last week of playoffs (the championship week) - numberOfPlayoffWeeks = self.__TEAMS_IN_PLAYOFFS_TO_PLAYOFF_WEEK_COUNT_MAP[ - playoffTeamCount - ] + numberOfPlayoffWeeks = ( + self.__TEAMS_IN_PLAYOFFS_TO_PLAYOFF_WEEK_COUNT_MAP[playoffTeamCount] + ) # TODO: Raise specific exception here if not found in map - if weekNumber == espnLeague.settings.reg_season_count + numberOfPlayoffWeeks: + if ( + weekNumber + == espnLeague.settings.reg_season_count + numberOfPlayoffWeeks + ): # this is the championship week # figure out if this team has lost in the playoffs before this week playoffOutcomes = espnTeam.outcomes[-numberOfPlayoffWeeks:-1] @@ -230,7 +251,9 @@ def __buildTeams(self, espnTeams: list[ESPNTeam]) -> list[Team]: divisionId = self.__espnDivisionIdToDivisionMap[espnTeam.division_id].id ownerName = self.__getESPNOwnerName(espnTeam.owners) owner = self._getOwnerByName(ownerName) - team = Team(ownerId=owner.id, name=espnTeam.team_name, divisionId=divisionId) + team = Team( + ownerId=owner.id, name=espnTeam.team_name, divisionId=divisionId + ) teams.append(team) self.__espnTeamIdToTeamMap[espnTeam.team_id] = team return teams diff --git a/leeger/league_loader/FleaflickerLeagueLoader.py b/leeger/league_loader/FleaflickerLeagueLoader.py index af8f999f..f78f2098 100644 --- a/leeger/league_loader/FleaflickerLeagueLoader.py +++ b/leeger/league_loader/FleaflickerLeagueLoader.py @@ -37,14 +37,17 @@ def __init__( except ValueError: raise ValueError(f"League ID '{leagueId}' could not be turned into an int.") super().__init__( - leagueId, years, ownerNamesAndAliases=ownerNamesAndAliases, leagueName=leagueName + leagueId, + years, + ownerNamesAndAliases=ownerNamesAndAliases, + leagueName=leagueName, ) self.__fleaflickerTeamIdToOwnerMap: dict[int, Owner] = dict() self.__fleaflickerTeamIdToTeamMap: dict[int, Team] = dict() - self.__fleaflickerDivisionIdToDivisionMap: dict[ - int, Division - ] = dict() # holds the division info for ONLY the current year + self.__fleaflickerDivisionIdToDivisionMap: dict[int, Division] = ( + dict() + ) # holds the division info for ONLY the current year def __getAllLeagues(self) -> list[dict]: # return a list of all leagues @@ -84,17 +87,19 @@ def __buildLeague(self, fleaflickerLeagues: list[dict]) -> League: owners = list(self.__fleaflickerTeamIdToOwnerMap.values()) for fleaflickerLeague in fleaflickerLeagues: # save league name for each year - self._leagueNameByYear[fleaflickerLeague["season"]] = fleaflickerLeague["league"][ - "name" - ] + self._leagueNameByYear[fleaflickerLeague["season"]] = fleaflickerLeague[ + "league" + ]["name"] years.append(self.__buildYear(fleaflickerLeague)) - return League(name=self._getLeagueName(), owners=owners, years=self._getValidYears(years)) + return League( + name=self._getLeagueName(), owners=owners, years=self._getValidYears(years) + ) def __buildYear(self, fleaflickerLeague: dict) -> Year: # save division info for fleaflickerDivision in fleaflickerLeague["divisions"]: - self.__fleaflickerDivisionIdToDivisionMap[fleaflickerDivision["id"]] = Division( - name=fleaflickerDivision["name"] + self.__fleaflickerDivisionIdToDivisionMap[fleaflickerDivision["id"]] = ( + Division(name=fleaflickerDivision["name"]) ) teams = self.__buildTeams(fleaflickerLeague) weeks = self.__buildWeeks(fleaflickerLeague) @@ -185,7 +190,9 @@ def __buildTeams(self, fleaflickerLeague: dict) -> list[Team]: team = Team( ownerId=owner.id, name=teamName, - divisionId=self.__fleaflickerDivisionIdToDivisionMap[division["id"]].id, + divisionId=self.__fleaflickerDivisionIdToDivisionMap[ + division["id"] + ].id, ) teams.append(team) self.__fleaflickerTeamIdToTeamMap[teamId] = team @@ -201,6 +208,12 @@ def __loadOwners(self, fleaflickerLeagues: list[dict]) -> None: else: ownerName = team["owners"][0]["displayName"] # get general owner name if there is one - generalOwnerName = self._getGeneralOwnerNameFromGivenOwnerName(ownerName) - ownerName = generalOwnerName if generalOwnerName is not None else ownerName - self.__fleaflickerTeamIdToOwnerMap[team["id"]] = Owner(name=ownerName) + generalOwnerName = self._getGeneralOwnerNameFromGivenOwnerName( + ownerName + ) + ownerName = ( + generalOwnerName if generalOwnerName is not None else ownerName + ) + self.__fleaflickerTeamIdToOwnerMap[team["id"]] = Owner( + name=ownerName + ) diff --git a/leeger/league_loader/LeagueLoader.py b/leeger/league_loader/LeagueLoader.py index 1fb689c7..1c8e41ff 100644 --- a/leeger/league_loader/LeagueLoader.py +++ b/leeger/league_loader/LeagueLoader.py @@ -44,9 +44,9 @@ def __init__( ownerNamesAndAliases if ownerNamesAndAliases else dict() ) self._leagueName = leagueName - self._leagueNameByYear: dict[ - int, str - ] = dict() # will hold league name by year like {2020: "foo", 2021: "baz", ...} + self._leagueNameByYear: dict[int, str] = ( + dict() + ) # will hold league name by year like {2020: "foo", 2021: "baz", ...} def _getLeagueName(self) -> str: leagueName = self._leagueName @@ -80,7 +80,9 @@ def _validateRetrievedLeagues(self, retrievedLeagues: list) -> None: f"Expected to retrieve {expectedLeagueCount} league/s, got {actualLeagueCount} league/s." ) - def _getGeneralOwnerNameFromGivenOwnerName(self, givenOwnerName: str) -> Optional[str]: + def _getGeneralOwnerNameFromGivenOwnerName( + self, givenOwnerName: str + ) -> Optional[str]: foundGeneralOwnerName = None for generalOwnerName, aliases in self._ownerNamesAndAliases.items(): if givenOwnerName in aliases: @@ -115,9 +117,7 @@ def _warnForUnusedOwnerNames(self, league: League) -> None: ) @abstractmethod - def loadLeague(self, validate: bool = True, *args, **kwargs) -> League: - ... + def loadLeague(self, validate: bool = True, *args, **kwargs) -> League: ... @abstractmethod - def getOwnerNames(self, *args, **kwargs) -> dict[int, list[str]]: - ... + def getOwnerNames(self, *args, **kwargs) -> dict[int, list[str]]: ... diff --git a/leeger/league_loader/MyFantasyLeagueLeagueLoader.py b/leeger/league_loader/MyFantasyLeagueLeagueLoader.py index 1b37994a..2e31ea8e 100644 --- a/leeger/league_loader/MyFantasyLeagueLeagueLoader.py +++ b/leeger/league_loader/MyFantasyLeagueLeagueLoader.py @@ -33,7 +33,10 @@ def __init__( leagueName: Optional[str] = None, ): super().__init__( - leagueId, years, ownerNamesAndAliases=ownerNamesAndAliases, leagueName=leagueName + leagueId, + years, + ownerNamesAndAliases=ownerNamesAndAliases, + leagueName=leagueName, ) self.__mflUsername = mflUsername @@ -43,9 +46,9 @@ def __init__( self.__mflLeagueIdToYearMap: dict[str, int] = dict() self.__mflFranchiseIdToOwnerMap: dict[str, Owner] = dict() self.__mflFranchiseIdToTeamMap: dict[int, Team] = dict() - self.__mflDivisionIdToDivisionMap: dict[ - str, Division - ] = dict() # holds the division info for ONLY the current year + self.__mflDivisionIdToDivisionMap: dict[str, Division] = ( + dict() + ) # holds the division info for ONLY the current year def __getAllLeagues(self) -> list[dict]: mflLeagues: list[dict] = list() @@ -59,9 +62,9 @@ def __getAllLeagues(self) -> list[dict]: user_agent_name=self.__mflUserAgentName, ) - mflLeague = CommonLeagueInfoAPIClient.get_league(year=year, league_id=self._leagueId)[ - "league" - ] + mflLeague = CommonLeagueInfoAPIClient.get_league( + year=year, league_id=self._leagueId + )["league"] self.__mflLeagueIdToYearMap[mflLeague["id"]] = year mflLeagues.append(mflLeague) self._validateRetrievedLeagues(mflLeagues) @@ -93,14 +96,20 @@ def __buildLeague(self, mflLeagues: list[dict]) -> League: owners = list(self.__mflFranchiseIdToOwnerMap.values()) for mflLeague in mflLeagues: # save league name for each year - self._leagueNameByYear[self.__mflLeagueIdToYearMap[mflLeague["id"]]] = mflLeague["name"] + self._leagueNameByYear[self.__mflLeagueIdToYearMap[mflLeague["id"]]] = ( + mflLeague["name"] + ) years.append(self.__buildYear(mflLeague)) - return League(name=self._getLeagueName(), owners=owners, years=self._getValidYears(years)) + return League( + name=self._getLeagueName(), owners=owners, years=self._getValidYears(years) + ) def __buildYear(self, mflLeague: dict) -> Year: # save division info for division in mflLeague["divisions"]["division"]: - self.__mflDivisionIdToDivisionMap[division["id"]] = Division(name=division["name"]) + self.__mflDivisionIdToDivisionMap[division["id"]] = Division( + name=division["name"] + ) yearNumber = self.__mflLeagueIdToYearMap[mflLeague["id"]] teams = self.__buildTeams(mflLeague) weeks = self.__buildWeeks(mflLeague) @@ -219,8 +228,12 @@ def __isChampionshipMatchup( # helper method def isValid(*, pGame: dict, aId: int, bId: int) -> bool: return ( - aId == pGame["away"]["franchise_id"] or bId == pGame["away"]["franchise_id"] - ) and (aId == pGame["home"]["franchise_id"] or bId == pGame["home"]["franchise_id"]) + aId == pGame["away"]["franchise_id"] + or bId == pGame["away"]["franchise_id"] + ) and ( + aId == pGame["home"]["franchise_id"] + or bId == pGame["home"]["franchise_id"] + ) isChampionshipMatchup = False @@ -240,7 +253,9 @@ def isValid(*, pGame: dict, aId: int, bId: int) -> bool: # check if this matchup is the championship game for playoffGame in playoffWeek["playoffGame"]: isChampionshipMatchup = isChampionshipMatchup or isValid( - pGame=playoffGame, aId=teamAMFLFranchiseId, bId=teamBMFLFranchiseId + pGame=playoffGame, + aId=teamAMFLFranchiseId, + bId=teamBMFLFranchiseId, ) return isChampionshipMatchup @@ -260,6 +275,10 @@ def __loadOwners(self, mflLeagues: list[dict]) -> None: for franchise in mflLeague["franchises"]["franchise"]: ownerName = franchise["owner_name"] # get general owner name if there is one - generalOwnerName = self._getGeneralOwnerNameFromGivenOwnerName(ownerName) - ownerName = generalOwnerName if generalOwnerName is not None else ownerName + generalOwnerName = self._getGeneralOwnerNameFromGivenOwnerName( + ownerName + ) + ownerName = ( + generalOwnerName if generalOwnerName is not None else ownerName + ) self.__mflFranchiseIdToOwnerMap[franchise["id"]] = Owner(name=ownerName) diff --git a/leeger/league_loader/SleeperLeagueLoader.py b/leeger/league_loader/SleeperLeagueLoader.py index 1d8d0059..da513a3b 100644 --- a/leeger/league_loader/SleeperLeagueLoader.py +++ b/leeger/league_loader/SleeperLeagueLoader.py @@ -51,13 +51,15 @@ def __init__( self.__sleeperUserIdToOwnerMap: dict[str, Owner] = dict() self.__sleeperRosterIdToTeamMap: dict[int, Team] = dict() - self.__SLEEPER_USERS_BY_LEAGUE_ID_CACHE = dict() # functions as a cache for Sleeper Users + self.__SLEEPER_USERS_BY_LEAGUE_ID_CACHE = ( + dict() + ) # functions as a cache for Sleeper Users self.__SLEEPER_SPORT_STATE_CACHE: SleeperSportState = ( None # functions as a cache for Sleeper SportState ) - self.__sleeperDivisionIdToDivisionMap: dict[ - int, Division - ] = dict() # holds the division info for ONLY the current year + self.__sleeperDivisionIdToDivisionMap: dict[int, Division] = ( + dict() + ) # holds the division info for ONLY the current year def __resetCaches(self) -> None: self.__SLEEPER_USERS_BY_LEAGUE_ID_CACHE = dict() @@ -83,8 +85,12 @@ def __getAllLeagues(self) -> list[SleeperLeague]: sleeperLeagues = list() years = self._years.copy() currentLeagueId = self._leagueId - while len(years) > 0 and currentLeagueId not in self.__INVALID_SLEEPER_LEAGUE_IDS: - currentLeague: SleeperLeague = LeagueAPIClient.get_league(league_id=currentLeagueId) + while ( + len(years) > 0 and currentLeagueId not in self.__INVALID_SLEEPER_LEAGUE_IDS + ): + currentLeague: SleeperLeague = LeagueAPIClient.get_league( + league_id=currentLeagueId + ) if int(currentLeague.season) in years: # we only want to add valid seasons # NOTE: Not sure if we should include SleeperSeasonStatus.POSTPONED here or not @@ -134,7 +140,9 @@ def __buildLeague(self, sleeperLeagues: list[SleeperLeague]) -> League: # save league name for each year self._leagueNameByYear[int(sleeperLeague.season)] = sleeperLeague.name years.append(self.__buildYear(sleeperLeague)) - return League(name=self._getLeagueName(), owners=owners, years=self._getValidYears(years)) + return League( + name=self._getLeagueName(), owners=owners, years=self._getValidYears(years) + ) def __buildYear(self, sleeperLeague: SleeperLeague) -> Year: # save division info if applicable @@ -169,31 +177,42 @@ def __buildWeeks(self, sleeperLeague: SleeperLeague) -> list[Week]: # once we have found an incomplete week, all weeks after will also be incomplete foundIncompleteWeek = False for weekNumber in range(1, sleeperLeague.settings.playoff_week_start): - if not foundIncompleteWeek and self.__isCompletedWeek(weekNumber, sleeperLeague): + if not foundIncompleteWeek and self.__isCompletedWeek( + weekNumber, sleeperLeague + ): # get each teams matchup for that week matchups = list() sleeperMatchupsForThisWeek = LeagueAPIClient.get_matchups_for_week( league_id=sleeperLeague.league_id, week=weekNumber ) - sleeperMatchupIdToSleeperMatchupMap: dict[int, list[SleeperMatchup]] = dict() + sleeperMatchupIdToSleeperMatchupMap: dict[int, list[SleeperMatchup]] = ( + dict() + ) for sleeperMatchup in sleeperMatchupsForThisWeek: - if sleeperMatchup.matchup_id in sleeperMatchupIdToSleeperMatchupMap.keys(): - sleeperMatchupIdToSleeperMatchupMap[sleeperMatchup.matchup_id].append( - sleeperMatchup - ) + if ( + sleeperMatchup.matchup_id + in sleeperMatchupIdToSleeperMatchupMap.keys() + ): + sleeperMatchupIdToSleeperMatchupMap[ + sleeperMatchup.matchup_id + ].append(sleeperMatchup) else: - sleeperMatchupIdToSleeperMatchupMap[sleeperMatchup.matchup_id] = [ - sleeperMatchup - ] + sleeperMatchupIdToSleeperMatchupMap[ + sleeperMatchup.matchup_id + ] = [sleeperMatchup] for sleeperMatchupPair in sleeperMatchupIdToSleeperMatchupMap.values(): # team A teamASleeperMatchup = sleeperMatchupPair[0] - teamA = self.__sleeperRosterIdToTeamMap[teamASleeperMatchup.roster_id] + teamA = self.__sleeperRosterIdToTeamMap[ + teamASleeperMatchup.roster_id + ] # team B teamBSleeperMatchup = sleeperMatchupPair[1] - teamB = self.__sleeperRosterIdToTeamMap[teamBSleeperMatchup.roster_id] + teamB = self.__sleeperRosterIdToTeamMap[ + teamBSleeperMatchup.roster_id + ] # sleeper does not have tiebreakers for regular season games # Source: https://support.sleeper.app/en/articles/4238872-can-i-set-tiebreakers#:~:text=We%20do%20not%20offer%20any,and%20adjust%20the%20point%20total. @@ -218,16 +237,21 @@ def __buildWeeks(self, sleeperLeague: SleeperLeague) -> list[Week]: ) if len(allSleeperPlayoffMatchups) > 0: # sort sleeperPlayoffMatchups by round into a dict - playoffRoundAndSleeperPlayoffMatchups: dict[int, list[SleeperPlayoffMatchup]] = dict() + playoffRoundAndSleeperPlayoffMatchups: dict[ + int, list[SleeperPlayoffMatchup] + ] = dict() for sleeperPlayoffMatchup in allSleeperPlayoffMatchups: - if sleeperPlayoffMatchup.round in playoffRoundAndSleeperPlayoffMatchups.keys(): - playoffRoundAndSleeperPlayoffMatchups[sleeperPlayoffMatchup.round].append( - sleeperPlayoffMatchup - ) + if ( + sleeperPlayoffMatchup.round + in playoffRoundAndSleeperPlayoffMatchups.keys() + ): + playoffRoundAndSleeperPlayoffMatchups[ + sleeperPlayoffMatchup.round + ].append(sleeperPlayoffMatchup) else: - playoffRoundAndSleeperPlayoffMatchups[sleeperPlayoffMatchup.round] = [ - sleeperPlayoffMatchup - ] + playoffRoundAndSleeperPlayoffMatchups[ + sleeperPlayoffMatchup.round + ] = [sleeperPlayoffMatchup] numberOfPlayoffRounds = max( [playoffMatchup.round for playoffMatchup in allSleeperPlayoffMatchups] ) # don't know a better way to determine this @@ -257,24 +281,32 @@ def __buildWeeks(self, sleeperLeague: SleeperLeague) -> list[Week]: ] # used to check if a Sleeper playoff matchup is in this week's matchups sleeperMatchupIdsForThisWeek = { - sleeperMatchup.matchup_id for sleeperMatchup in sleeperMatchupsForThisWeek + sleeperMatchup.matchup_id + for sleeperMatchup in sleeperMatchupsForThisWeek } if self.__isCompletedWeek(weekNumber, sleeperLeague): # sort matchups by roster IDs rosterIdToSleeperMatchupMap: dict[int, SleeperMatchup] = dict() for sleeperMatchup in sleeperMatchupsForThisWeek: - rosterIdToSleeperMatchupMap[sleeperMatchup.roster_id] = sleeperMatchup - for sleeperPlayoffMatchup in playoffRoundAndSleeperPlayoffMatchups[roundNumber]: + rosterIdToSleeperMatchupMap[sleeperMatchup.roster_id] = ( + sleeperMatchup + ) + for sleeperPlayoffMatchup in playoffRoundAndSleeperPlayoffMatchups[ + roundNumber + ]: # check if this matchup is in this week (needed for leagues with multiple weeks in a single round) if ( - sleeperPlayoffMatchup.matchup_id in sleeperMatchupIdsForThisWeek + sleeperPlayoffMatchup.matchup_id + in sleeperMatchupIdsForThisWeek or sleeperLeague.settings.playoff_round_type_enum == SleeperPlayoffRoundType.ONE_WEEK_PER_ROUND ): # team A teamARosterId = sleeperPlayoffMatchup.team_1_roster_id teamA = self.__sleeperRosterIdToTeamMap[teamARosterId] - teamAPoints = rosterIdToSleeperMatchupMap[teamARosterId].points + teamAPoints = rosterIdToSleeperMatchupMap[ + teamARosterId + ].points teamAHasTiebreaker = ( sleeperPlayoffMatchup.winning_roster_id == sleeperPlayoffMatchup.team_1_roster_id @@ -282,7 +314,9 @@ def __buildWeeks(self, sleeperLeague: SleeperLeague) -> list[Week]: # team B teamBRosterId = sleeperPlayoffMatchup.team_2_roster_id teamB = self.__sleeperRosterIdToTeamMap[teamBRosterId] - teamBPoints = rosterIdToSleeperMatchupMap[teamBRosterId].points + teamBPoints = rosterIdToSleeperMatchupMap[ + teamBRosterId + ].points teamBHasTiebreaker = ( sleeperPlayoffMatchup.winning_roster_id == sleeperPlayoffMatchup.team_2_roster_id @@ -369,21 +403,33 @@ def __loadOwners(self, sleeperLeagues: list[SleeperLeague]) -> None: for sleeperUser in sleeperUsers: ownerName = sleeperUser.display_name # get general owner name if there is one - generalOwnerName = self._getGeneralOwnerNameFromGivenOwnerName(ownerName) - ownerName = generalOwnerName if generalOwnerName is not None else ownerName - self.__sleeperUserIdToOwnerMap[sleeperUser.user_id] = Owner(name=ownerName) + generalOwnerName = self._getGeneralOwnerNameFromGivenOwnerName( + ownerName + ) + ownerName = ( + generalOwnerName if generalOwnerName is not None else ownerName + ) + self.__sleeperUserIdToOwnerMap[sleeperUser.user_id] = Owner( + name=ownerName + ) @staticmethod def __calculate_number_of_playoff_weeks( - sleeperLeague: SleeperLeague, sleeperPlayoffMatchups: list[SleeperPlayoffMatchup] + sleeperLeague: SleeperLeague, + sleeperPlayoffMatchups: list[SleeperPlayoffMatchup], ) -> int: # sort sleeperPlayoffMatchups by round into a dict - playoffRoundAndSleeperPlayoffMatchups: dict[int, list[SleeperPlayoffMatchup]] = dict() + playoffRoundAndSleeperPlayoffMatchups: dict[ + int, list[SleeperPlayoffMatchup] + ] = dict() for sleeperPlayoffMatchup in sleeperPlayoffMatchups: - if sleeperPlayoffMatchup.round in playoffRoundAndSleeperPlayoffMatchups.keys(): - playoffRoundAndSleeperPlayoffMatchups[sleeperPlayoffMatchup.round].append( - sleeperPlayoffMatchup - ) + if ( + sleeperPlayoffMatchup.round + in playoffRoundAndSleeperPlayoffMatchups.keys() + ): + playoffRoundAndSleeperPlayoffMatchups[ + sleeperPlayoffMatchup.round + ].append(sleeperPlayoffMatchup) else: playoffRoundAndSleeperPlayoffMatchups[sleeperPlayoffMatchup.round] = [ sleeperPlayoffMatchup diff --git a/leeger/league_loader/YahooLeagueLoader.py b/leeger/league_loader/YahooLeagueLoader.py index 207d6f0d..7361c1f2 100644 --- a/leeger/league_loader/YahooLeagueLoader.py +++ b/leeger/league_loader/YahooLeagueLoader.py @@ -44,7 +44,9 @@ def __init__( try: int(mostRecentLeagueId) except ValueError: - raise ValueError(f"League ID '{mostRecentLeagueId}' could not be turned into an int.") + raise ValueError( + f"League ID '{mostRecentLeagueId}' could not be turned into an int." + ) super().__init__( mostRecentLeagueId, years, @@ -163,7 +165,9 @@ def __buildWeeks(self, yahooLeague: YahooLeague) -> list[Week]: # get each teams matchup for that week matchups = list() # only get matchups that are completed - validYahooMatchups = [m for m in yahooWeek.matchups if m.status == "postevent"] + validYahooMatchups = [ + m for m in yahooWeek.matchups if m.status == "postevent" + ] for yahooMatchup in validYahooMatchups: # team A is *this* team yahooTeamA = yahooMatchup.teams.team[0] @@ -178,8 +182,12 @@ def __buildWeeks(self, yahooLeague: YahooLeague) -> list[Week]: teamBHasTiebreaker = False if yahooMatchup.is_tied == 0: # non-tied matchup - teamAHasTiebreaker = yahooMatchup.winner_team_key == yahooTeamA.team_key - teamBHasTiebreaker = yahooMatchup.winner_team_key == yahooTeamB.team_key + teamAHasTiebreaker = ( + yahooMatchup.winner_team_key == yahooTeamA.team_key + ) + teamBHasTiebreaker = ( + yahooMatchup.winner_team_key == yahooTeamB.team_key + ) matchupType = self.__getMatchupType(yahooMatchup) matchups.append( Matchup( @@ -208,17 +216,21 @@ def __getMatchupType(self, yahooMatchup: YahooMatchup) -> MatchupType: if ( ( team1Id - not in self.__yearToTeamIdHasLostInPlayoffs[yahooMatchup.league.season] - or not self.__yearToTeamIdHasLostInPlayoffs[yahooMatchup.league.season][ - team1Id + not in self.__yearToTeamIdHasLostInPlayoffs[ + yahooMatchup.league.season ] + or not self.__yearToTeamIdHasLostInPlayoffs[ + yahooMatchup.league.season + ][team1Id] ) and ( team2Id - not in self.__yearToTeamIdHasLostInPlayoffs[yahooMatchup.league.season] - or not self.__yearToTeamIdHasLostInPlayoffs[yahooMatchup.league.season][ - team2Id + not in self.__yearToTeamIdHasLostInPlayoffs[ + yahooMatchup.league.season ] + or not self.__yearToTeamIdHasLostInPlayoffs[ + yahooMatchup.league.season + ][team2Id] ) and yahooMatchup.is_consolation == 0 ): @@ -226,12 +238,12 @@ def __getMatchupType(self, yahooMatchup: YahooMatchup) -> MatchupType: # update tracking dict with the team that lost for yahooTeamResult in yahooMatchup.teams.team: # NOTE: this check is needed so we don't overwrite teams that have already lost with a win (e.g. W, L, W) - if not self.__yearToTeamIdHasLostInPlayoffs[yahooMatchup.league.season].get( - yahooTeamResult.team_id, False - ): + if not self.__yearToTeamIdHasLostInPlayoffs[ + yahooMatchup.league.season + ].get(yahooTeamResult.team_id, False): self.__yearToTeamIdHasLostInPlayoffs[yahooMatchup.league.season][ yahooTeamResult.team_id - ] = (yahooTeamResult.team_key != yahooMatchup.winner_team_key) + ] = yahooTeamResult.team_key != yahooMatchup.winner_team_key return MatchupType.PLAYOFF else: return MatchupType.REGULAR_SEASON @@ -252,13 +264,19 @@ def __loadOwners(self, yahooTeams: list[YahooTeam]) -> None: for yahooTeam in yahooTeams: ownerName = yahooTeam.manager.nickname # get general owner name if there is one - generalOwnerName = self._getGeneralOwnerNameFromGivenOwnerName(ownerName) - ownerName = generalOwnerName if generalOwnerName is not None else ownerName + generalOwnerName = self._getGeneralOwnerNameFromGivenOwnerName( + ownerName + ) + ownerName = ( + generalOwnerName if generalOwnerName is not None else ownerName + ) # prevent duplicate owner names i = 2 while ownerName in yahooOwnerTeamNames: ownerName = f"{yahooTeam.manager.nickname}({i})" - yahooManagerIdToOwnerMap[yahooTeam.manager.manager_id] = Owner(name=ownerName) + yahooManagerIdToOwnerMap[yahooTeam.manager.manager_id] = Owner( + name=ownerName + ) yahooOwnerTeamNames.append(ownerName) self.__yahooManagerIdToOwnerMap = yahooManagerIdToOwnerMap diff --git a/leeger/model/abstract/EqualityCheck.py b/leeger/model/abstract/EqualityCheck.py index 0040294b..1f6830f7 100644 --- a/leeger/model/abstract/EqualityCheck.py +++ b/leeger/model/abstract/EqualityCheck.py @@ -17,5 +17,4 @@ def equals( ignoreIds: bool = False, ignoreBaseIds: bool = False, logDifferences: bool = False, - ) -> bool: - ... + ) -> bool: ... diff --git a/leeger/model/filter/AllTimeFilters.py b/leeger/model/filter/AllTimeFilters.py index d73220e2..2190198e 100644 --- a/leeger/model/filter/AllTimeFilters.py +++ b/leeger/model/filter/AllTimeFilters.py @@ -31,7 +31,11 @@ def includeMatchupTypes(self) -> list[MatchupType]: elif self.onlyRegularSeason: return [MatchupType.REGULAR_SEASON] else: - return [MatchupType.REGULAR_SEASON, MatchupType.PLAYOFF, MatchupType.CHAMPIONSHIP] + return [ + MatchupType.REGULAR_SEASON, + MatchupType.PLAYOFF, + MatchupType.CHAMPIONSHIP, + ] @classmethod def preferredOrderWithTitle(cls, league: League, **kwargs) -> list[tuple[str, Any]]: @@ -59,12 +63,16 @@ def getForLeague(cls, league: League, **kwargs) -> AllTimeFilters: yearNumberStart = kwargsCopy.pop("yearNumberStart", league.years[0].yearNumber) weekNumberStart = kwargsCopy.pop( "weekNumberStart", - LeagueNavigator.getYearByYearNumber(league, yearNumberStart).weeks[0].weekNumber, + LeagueNavigator.getYearByYearNumber(league, yearNumberStart) + .weeks[0] + .weekNumber, ) yearNumberEnd = kwargsCopy.pop("yearNumberEnd", league.years[-1].yearNumber) weekNumberEnd = kwargsCopy.pop( "weekNumberEnd", - LeagueNavigator.getYearByYearNumber(league, yearNumberEnd).weeks[-1].weekNumber, + LeagueNavigator.getYearByYearNumber(league, yearNumberEnd) + .weeks[-1] + .weekNumber, ) GeneralUtil.warnForUnusedKwargs(kwargsCopy) @@ -99,7 +107,9 @@ def getForLeague(cls, league: League, **kwargs) -> AllTimeFilters: ) if weekNumberStart < 1: raise InvalidFilterException("'weekNumberStart' cannot be less than 1.") - if weekNumberEnd > len(LeagueNavigator.getYearByYearNumber(league, yearNumberEnd).weeks): + if weekNumberEnd > len( + LeagueNavigator.getYearByYearNumber(league, yearNumberEnd).weeks + ): raise InvalidFilterException( "'weekNumberEnd' cannot be greater than the number of weeks in the year." ) diff --git a/leeger/model/filter/YearFilters.py b/leeger/model/filter/YearFilters.py index 47e96a17..7c1f6629 100644 --- a/leeger/model/filter/YearFilters.py +++ b/leeger/model/filter/YearFilters.py @@ -16,7 +16,9 @@ class YearFilters: weekNumberStart: int # week to start at (inclusive) weekNumberEnd: int # week to end at (inclusive) - includeMultiWeekMatchups: bool = True # whether to include multi-week matchups or not + includeMultiWeekMatchups: bool = ( + True # whether to include multi-week matchups or not + ) onlyChampionship: bool = False # only include championship weeks onlyPostSeason: bool = False # only include playoff weeks onlyRegularSeason: bool = False # only include regular season weeks @@ -30,7 +32,11 @@ def includeMatchupTypes(self) -> list[MatchupType]: elif self.onlyRegularSeason: return [MatchupType.REGULAR_SEASON] else: - return [MatchupType.REGULAR_SEASON, MatchupType.PLAYOFF, MatchupType.CHAMPIONSHIP] + return [ + MatchupType.REGULAR_SEASON, + MatchupType.PLAYOFF, + MatchupType.CHAMPIONSHIP, + ] @classmethod def preferredOrderWithTitle(cls, year: Year, **kwargs) -> list[tuple[str, Any]]: @@ -74,7 +80,9 @@ def getForYear(cls, year: Year, **kwargs) -> YearFilters: if not isinstance(weekNumberEnd, int): raise InvalidFilterException("'weekNumberEnd' must be type 'int'") if not isinstance(includeMultiWeekMatchups, bool): - raise InvalidFilterException("'includeMultiWeekMatchups' must be type 'bool'") + raise InvalidFilterException( + "'includeMultiWeekMatchups' must be type 'bool'" + ) # logic checks if [onlyChampionship, onlyPostSeason, onlyRegularSeason].count(True) > 1: diff --git a/leeger/model/league/Division.py b/leeger/model/league/Division.py index 19c91b65..2b5083db 100644 --- a/leeger/model/league/Division.py +++ b/leeger/model/league/Division.py @@ -38,7 +38,9 @@ def equals( ) def __eq__(self, otherDivision: Division) -> bool: - self.__LOGGER.info("Use .equals() for more options when comparing Division instances.") + self.__LOGGER.info( + "Use .equals() for more options when comparing Division instances." + ) return self.equals(otherDivision=otherDivision) def toJson(self) -> dict: diff --git a/leeger/model/league/League.py b/leeger/model/league/League.py index b21c166a..71c88bb6 100644 --- a/leeger/model/league/League.py +++ b/leeger/model/league/League.py @@ -68,7 +68,9 @@ def listsEqual( ) def __eq__(self, otherLeague: League) -> bool: - self.__LOGGER.info("Use .equals() for more options when comparing League instances.") + self.__LOGGER.info( + "Use .equals() for more options when comparing League instances." + ) return self.equals(otherLeague=otherLeague) def __add__(self, otherLeague: League) -> League: @@ -151,7 +153,9 @@ def getYearByYearNumber(self, yearNumber: int) -> Year: for year in self.years: if year.yearNumber == yearNumber: return year - raise DoesNotExistException(f"League does not have a year with year number {yearNumber}") + raise DoesNotExistException( + f"League does not have a year with year number {yearNumber}" + ) def getOwnerByName(self, ownerName: str) -> Owner: """ @@ -160,7 +164,9 @@ def getOwnerByName(self, ownerName: str) -> Owner: for owner in self.owners: if owner.name == ownerName: return owner - raise DoesNotExistException(f"League does not have an owner with name '{ownerName}'") + raise DoesNotExistException( + f"League does not have an owner with name '{ownerName}'" + ) def toJson(self) -> dict: return { diff --git a/leeger/model/league/Matchup.py b/leeger/model/league/Matchup.py index 6dd285f6..ce8c2839 100644 --- a/leeger/model/league/Matchup.py +++ b/leeger/model/league/Matchup.py @@ -25,9 +25,9 @@ class Matchup(UniqueId, EqualityCheck, JSONSerializable, JSONDeserializable): matchupType: MatchupType = MatchupType.REGULAR_SEASON teamAHasTiebreaker: Optional[bool] = False teamBHasTiebreaker: Optional[bool] = False - multiWeekMatchupId: Optional[ - str - ] = None # This is used to link matchups that span over multiple weeks + multiWeekMatchupId: Optional[str] = ( + None # This is used to link matchups that span over multiple weeks + ) def __post_init__(self): # Team A and Team B cannot both have the tiebreaker @@ -71,7 +71,9 @@ def equals( ) def __eq__(self, otherMatchup: Matchup) -> bool: - self.__LOGGER.info("Use .equals() for more options when comparing Matchup instances.") + self.__LOGGER.info( + "Use .equals() for more options when comparing Matchup instances." + ) return self.equals(otherMatchup=otherMatchup) def splitToPerformances(self) -> tuple[Performance, Performance]: diff --git a/leeger/model/league/Owner.py b/leeger/model/league/Owner.py index 721a64ca..d2e9702f 100644 --- a/leeger/model/league/Owner.py +++ b/leeger/model/league/Owner.py @@ -38,7 +38,9 @@ def equals( ) def __eq__(self, otherOwner: Owner) -> bool: - self.__LOGGER.info("Use .equals() for more options when comparing Owner instances.") + self.__LOGGER.info( + "Use .equals() for more options when comparing Owner instances." + ) return self.equals(otherOwner=otherOwner) def toJson(self) -> dict: diff --git a/leeger/model/league/Team.py b/leeger/model/league/Team.py index 6f75a740..c778bacf 100644 --- a/leeger/model/league/Team.py +++ b/leeger/model/league/Team.py @@ -42,7 +42,9 @@ def equals( ) def __eq__(self, otherTeam: Team) -> bool: - self.__LOGGER.info("Use .equals() for more options when comparing Team instances.") + self.__LOGGER.info( + "Use .equals() for more options when comparing Team instances." + ) return self.equals(otherTeam=otherTeam) def toJson(self) -> dict: @@ -55,6 +57,8 @@ def toJson(self) -> dict: @staticmethod def fromJson(d: dict) -> Team: - team = Team(ownerId=d["ownerId"], name=d["name"], divisionId=d.get("divisionId")) + team = Team( + ownerId=d["ownerId"], name=d["name"], divisionId=d.get("divisionId") + ) team.id = d["id"] return team diff --git a/leeger/model/league/Week.py b/leeger/model/league/Week.py index 45e434e0..94d13ff2 100644 --- a/leeger/model/league/Week.py +++ b/leeger/model/league/Week.py @@ -62,7 +62,9 @@ def matchupsEqual( ) def __eq__(self, otherWeek: Week) -> bool: - self.__LOGGER.info("Use .equals() for more options when comparing Week instances.") + self.__LOGGER.info( + "Use .equals() for more options when comparing Week instances." + ) return self.equals(otherWeek=otherWeek) @property @@ -102,7 +104,9 @@ def getMatchupWithTeamId(self, teamId: str) -> Matchup: for matchup in self.matchups: if matchup.teamAId == teamId or matchup.teamBId == teamId: return matchup - raise DoesNotExistException(f"Week does not have a matchup with team ID '{teamId}'.") + raise DoesNotExistException( + f"Week does not have a matchup with team ID '{teamId}'." + ) def toJson(self) -> dict: return { diff --git a/leeger/model/league/Year.py b/leeger/model/league/Year.py index fcf913cc..bc67b8e2 100644 --- a/leeger/model/league/Year.py +++ b/leeger/model/league/Year.py @@ -91,12 +91,17 @@ def yearSettingsEqual( "teams": {"ignoreIds": ignoreIds, "ignoreBaseIds": ignoreBaseIds}, "weeks": {"ignoreIds": ignoreIds, "ignoreBaseIds": ignoreBaseIds}, "divisions": {"ignoreIds": ignoreIds, "ignoreBaseIds": ignoreBaseIds}, - "yearSettings": {"ignoreIds": ignoreIds, "ignoreBaseIds": ignoreBaseIds}, + "yearSettings": { + "ignoreIds": ignoreIds, + "ignoreBaseIds": ignoreBaseIds, + }, }, ) def __eq__(self, otherYear: Year) -> bool: - self.__LOGGER.info("Use .equals() for more options when comparing Year instances.") + self.__LOGGER.info( + "Use .equals() for more options when comparing Year instances." + ) return self.equals(otherYear=otherYear) def getTeamByName(self, teamName: str) -> Team: @@ -106,7 +111,9 @@ def getTeamByName(self, teamName: str) -> Team: for team in self.teams: if team.name == teamName: return team - raise DoesNotExistException(f"Year does not have a team with name '{teamName}'.") + raise DoesNotExistException( + f"Year does not have a team with name '{teamName}'." + ) def getWeekByWeekNumber(self, weekNumber: int) -> Week: """ @@ -115,7 +122,9 @@ def getWeekByWeekNumber(self, weekNumber: int) -> Week: for week in self.weeks: if week.weekNumber == weekNumber: return week - raise DoesNotExistException(f"Year does not have a week with week number {weekNumber}.") + raise DoesNotExistException( + f"Year does not have a week with week number {weekNumber}." + ) def toJson(self) -> dict: return { diff --git a/leeger/model/league/YearSettings.py b/leeger/model/league/YearSettings.py index 2949482f..efe8493c 100644 --- a/leeger/model/league/YearSettings.py +++ b/leeger/model/league/YearSettings.py @@ -42,7 +42,9 @@ def equals( ) def __eq__(self, otherYearSettings: YearSettings) -> bool: - self.__LOGGER.info("Use .equals() for more options when comparing YearSettings instances.") + self.__LOGGER.info( + "Use .equals() for more options when comparing YearSettings instances." + ) return self.equals(otherYearSettings=otherYearSettings) def toJson(self) -> dict: diff --git a/leeger/model/league_helper/Performance.py b/leeger/model/league_helper/Performance.py index 8e005d95..8b70de01 100644 --- a/leeger/model/league_helper/Performance.py +++ b/leeger/model/league_helper/Performance.py @@ -46,7 +46,9 @@ def equals( ) def __eq__(self, otherPerformance: Performance) -> bool: - self.__LOGGER.info("Use .equals() for more options when comparing Performance instances.") + self.__LOGGER.info( + "Use .equals() for more options when comparing Performance instances." + ) return self.equals(otherPerformance=otherPerformance) def __add__(self, otherPerformance: Performance): @@ -71,7 +73,9 @@ def __add__(self, otherPerformance: Performance): if self.hasTiebreaker: tiebreakerInfoLost.append(f"Performance {self.id} had tiebreaker") if otherPerformance.hasTiebreaker: - tiebreakerInfoLost.append(f"Performance {otherPerformance.id} had tiebreaker") + tiebreakerInfoLost.append( + f"Performance {otherPerformance.id} had tiebreaker" + ) if tiebreakerInfoLost: self.__LOGGER.warning( f"Combining performances caused loss of tiebreakers: {tiebreakerInfoLost}." diff --git a/leeger/model/stat/AllTimeStatSheet.py b/leeger/model/stat/AllTimeStatSheet.py index 80d96edf..eacff80b 100644 --- a/leeger/model/stat/AllTimeStatSheet.py +++ b/leeger/model/stat/AllTimeStatSheet.py @@ -102,6 +102,8 @@ def preferredOrderWithTitle(self) -> list[tuple[str, dict]]: if self.leagueMedianWins is not None: response.insert(1, ("Total Games", self.totalGames)) response.insert(4, ("League Median Wins", self.leagueMedianWins)) - response.insert(5, ("Opponent League Median Wins", self.opponentLeagueMedianWins)) + response.insert( + 5, ("Opponent League Median Wins", self.opponentLeagueMedianWins) + ) return response diff --git a/leeger/model/stat/YearStatSheet.py b/leeger/model/stat/YearStatSheet.py index 46d90a08..80394b8b 100644 --- a/leeger/model/stat/YearStatSheet.py +++ b/leeger/model/stat/YearStatSheet.py @@ -106,7 +106,9 @@ def preferredOrderWithTitle(self) -> list[tuple[str, dict]]: if self.leagueMedianWins is not None: response.insert(1, ("Total Games", self.totalGames)) response.insert(4, ("League Median Wins", self.leagueMedianWins)) - response.insert(5, ("Opponent League Median Wins", self.opponentLeagueMedianWins)) + response.insert( + 5, ("Opponent League Median Wins", self.opponentLeagueMedianWins) + ) if self.ownerNames is not None: response.insert(0, ("Owner", self.ownerNames)) diff --git a/leeger/util/ConfigReader.py b/leeger/util/ConfigReader.py index 0b147858..c18de2fa 100644 --- a/leeger/util/ConfigReader.py +++ b/leeger/util/ConfigReader.py @@ -10,7 +10,11 @@ class ConfigReader: @staticmethod def get( - section: str, name: str, *, asType: str | list = str, propFile: str = "app.properties" + section: str, + name: str, + *, + asType: str | list = str, + propFile: str = "app.properties", ) -> Optional[str | int | float | bool]: configParser = configparser.ConfigParser( converters={"list": lambda x: [i.strip() for i in x.split(",")]} diff --git a/leeger/util/GeneralUtil.py b/leeger/util/GeneralUtil.py index ae378629..b9b5f791 100644 --- a/leeger/util/GeneralUtil.py +++ b/leeger/util/GeneralUtil.py @@ -25,7 +25,9 @@ def warnForUnusedKwargs( excludeKeys = excludeKeys if excludeKeys is not None else list() # get the list of common kwargs that sometimes linger in kwargs to be passed down and used later. - defaultExcludeKeys = ConfigReader.get("KWARGS", "WARNING_EXCLUDE_KEYS", asType=list) + defaultExcludeKeys = ConfigReader.get( + "KWARGS", "WARNING_EXCLUDE_KEYS", asType=list + ) excludeKeys += defaultExcludeKeys unused_kwargs = [kwarg for kwarg in kwargs.keys() if kwarg not in excludeKeys] @@ -85,7 +87,9 @@ def findDifferentFields( isRootDict=isRootDict, ) ) - elif isinstance(value1, (list, tuple)) and isinstance(value2, (list, tuple)): + elif isinstance(value1, (list, tuple)) and isinstance( + value2, (list, tuple) + ): if len(value1) != len(value2): differentFields.append((fullKey, (value1, value2))) else: diff --git a/leeger/util/equality.py b/leeger/util/equality.py index 154accee..105a3643 100644 --- a/leeger/util/equality.py +++ b/leeger/util/equality.py @@ -55,7 +55,9 @@ def isEqual(field: str, objA: Any, objB: Any) -> bool: if field not in equalityFunctionKwargsMap else equalityFunctionKwargsMap[field] ) - return equalityFunction(getattr(objA, field), getattr(objB, field), **kwargsToPass) + return equalityFunction( + getattr(objA, field), getattr(objB, field), **kwargsToPass + ) return getattr(objA, field) == getattr(objB, field) equal = True diff --git a/leeger/util/excel.py b/leeger/util/excel.py index 806cb7dc..3dfd99ba 100644 --- a/leeger/util/excel.py +++ b/leeger/util/excel.py @@ -107,8 +107,8 @@ def leagueToExcel( workbook.create_sheet("All Time Matchups", index=index) worksheet = workbook["All Time Matchups"] - (allTimeMatchupsStatSheet_, modifiedMatchupIdToOwnerIdMap) = allTimeMatchupsStatSheet( - league, **kwargs.copy() + (allTimeMatchupsStatSheet_, modifiedMatchupIdToOwnerIdMap) = ( + allTimeMatchupsStatSheet(league, **kwargs.copy()) ) modifiedMatchupIdToColorMap: dict = dict() @@ -136,7 +136,9 @@ def leagueToExcel( workbook.create_sheet("All Time Owners", index=index) worksheet = workbook["All Time Owners"] - allTimeOwnerStatsWithTitles = leagueStatSheet(league, **kwargs.copy()).preferredOrderWithTitle() + allTimeOwnerStatsWithTitles = leagueStatSheet( + league, **kwargs.copy() + ).preferredOrderWithTitle() allTimeOwnerStatsWithTitles.insert(0, ("Owner", ownerIdToNameMap)) return _populateWorksheet( @@ -340,7 +342,10 @@ def _populateWorksheet( worksheet[titleCell].fill = PatternFill(patternType="solid", fgColor=MEDIUM_GRAY) worksheet[titleCell].font = Font(bold=True) border = Border( - left=leftSideSolid, right=rightSideSolid, top=topSideSolid, bottom=bottomSideThin + left=leftSideSolid, + right=rightSideSolid, + top=topSideSolid, + bottom=bottomSideThin, ) worksheet[titleCell].border = border worksheet[titleCell].alignment = legendCellAlignment diff --git a/leeger/util/excel_helper.py b/leeger/util/excel_helper.py index f780978a..3ee5c855 100644 --- a/leeger/util/excel_helper.py +++ b/leeger/util/excel_helper.py @@ -12,7 +12,9 @@ def allTimeTeamsStatSheet(league: League, **kwargs) -> list[tuple[str, dict]]: teamIdToNameMap = dict() teamIdToDivisionNameMap = dict() for team in year.teams: - ownerNames[team.id] = LeagueNavigator.getOwnerById(league, team.ownerId).name + ownerNames[team.id] = LeagueNavigator.getOwnerById( + league, team.ownerId + ).name years[team.id] = year.yearNumber teamIdToNameMap[team.id] = team.name if team.divisionId: @@ -39,9 +41,14 @@ def allTimeTeamsStatSheet(league: League, **kwargs) -> list[tuple[str, dict]]: ] if titleStr in allTitlesInCondensedList: # add to stats dict for the existing title - for i, (title_s, stats_d) in enumerate(condensedAllTimeTeamsStatsWithTitles): + for i, (title_s, stats_d) in enumerate( + condensedAllTimeTeamsStatsWithTitles + ): if title_s == titleStr: - condensedAllTimeTeamsStatsWithTitles[i] = (title_s, stats_d | statsDict) + condensedAllTimeTeamsStatsWithTitles[i] = ( + title_s, + stats_d | statsDict, + ) else: condensedAllTimeTeamsStatsWithTitles.append((titleStr, statsDict)) return condensedAllTimeTeamsStatsWithTitles @@ -132,7 +139,11 @@ def allTimeMatchupsStatSheet( yearNumbers: dict[str, int] = dict() for year in league.years: - if allTimeFilters.yearNumberStart <= year.yearNumber <= allTimeFilters.yearNumberEnd: + if ( + allTimeFilters.yearNumberStart + <= year.yearNumber + <= allTimeFilters.yearNumberEnd + ): ( currentYearMatchupStatSheet, currentModifiedMatchupIdToOwnerIdMap, @@ -140,7 +151,9 @@ def allTimeMatchupsStatSheet( year, includeYears=True, includeOwnerIds=True, **kwargs.copy() ) allYearMatchupStatSheets.append(currentYearMatchupStatSheet) - allModifiedMatchupIdToOwnerIdMaps.append(currentModifiedMatchupIdToOwnerIdMap) + allModifiedMatchupIdToOwnerIdMaps.append( + currentModifiedMatchupIdToOwnerIdMap + ) # combine responses into 1 response for yearMatchupStatSheet in allYearMatchupStatSheets: diff --git a/leeger/util/navigator/LeagueNavigator.py b/leeger/util/navigator/LeagueNavigator.py index 4822f453..ade4fb47 100644 --- a/leeger/util/navigator/LeagueNavigator.py +++ b/leeger/util/navigator/LeagueNavigator.py @@ -18,7 +18,9 @@ def getYearByYearNumber(league: League, yearNumber: int) -> Year: for year in league.years: if year.yearNumber == yearNumber: return year - raise DoesNotExistException(f"Year {yearNumber} does not exist in the given League.") + raise DoesNotExistException( + f"Year {yearNumber} does not exist in the given League." + ) @staticmethod def getTeamById(league: League, teamId: str) -> Team: @@ -26,14 +28,18 @@ def getTeamById(league: League, teamId: str) -> Team: for team in year.teams: if team.id == teamId: return team - raise DoesNotExistException(f"Team with ID {teamId} does not exist in the given League.") + raise DoesNotExistException( + f"Team with ID {teamId} does not exist in the given League." + ) @staticmethod def getOwnerById(league: League, ownerId: str) -> Owner: for owner in league.owners: if owner.id == ownerId: return owner - raise DoesNotExistException(f"Owner with ID {ownerId} does not exist in the given League.") + raise DoesNotExistException( + f"Owner with ID {ownerId} does not exist in the given League." + ) @staticmethod def getAllOwnerIds(league: League) -> list[str]: @@ -64,7 +70,9 @@ def getNumberOfGamesPlayed( if allTimeFilters.yearNumberStart == allTimeFilters.yearNumberEnd: yearWeekNumberStartWeekNumberEnd.append( ( - LeagueNavigator.getYearByYearNumber(league, allTimeFilters.yearNumberStart), + LeagueNavigator.getYearByYearNumber( + league, allTimeFilters.yearNumberStart + ), allTimeFilters.weekNumberStart, allTimeFilters.weekNumberEnd, ) @@ -80,9 +88,13 @@ def getNumberOfGamesPlayed( elif year.yearNumber == allTimeFilters.yearNumberEnd: # last year we want, make sure week number end matches what was requested # first week and every week til givenWeekEnd - yearWeekNumberStartWeekNumberEnd.append((year, 1, allTimeFilters.weekNumberEnd)) + yearWeekNumberStartWeekNumberEnd.append( + (year, 1, allTimeFilters.weekNumberEnd) + ) elif ( - allTimeFilters.yearNumberStart < year.yearNumber < allTimeFilters.yearNumberEnd + allTimeFilters.yearNumberStart + < year.yearNumber + < allTimeFilters.yearNumberEnd ): # this year is in our year range, include every week in this year yearWeekNumberStartWeekNumberEnd.append((year, 1, len(year.weeks))) @@ -125,7 +137,9 @@ def getNumberOfGamesPlayed( return ownerIdAndNumberOfGamesPlayed @staticmethod - def getAllScoresInLeague(league: League, simplifyMultiWeekMatchups=False) -> list[float | int]: + def getAllScoresInLeague( + league: League, simplifyMultiWeekMatchups=False + ) -> list[float | int]: """ Returns a list of all scores for the given League. Will count all scores EXCEPT for IGNORE Matchups. diff --git a/leeger/util/navigator/WeekNavigator.py b/leeger/util/navigator/WeekNavigator.py index eaf21019..e498d4a0 100644 --- a/leeger/util/navigator/WeekNavigator.py +++ b/leeger/util/navigator/WeekNavigator.py @@ -8,7 +8,9 @@ class WeekNavigator: """ @staticmethod - def getTeamIdsAndScores(week: Week, weekFilters: WeekFilters) -> dict[str, float | int]: + def getTeamIdsAndScores( + week: Week, weekFilters: WeekFilters + ) -> dict[str, float | int]: """ Returns all scores for each team in the given Week. @@ -50,7 +52,9 @@ def getTeamIdsAndOpponentScores( return teamIdAndScores @classmethod - def getNumberOfValidTeamsInWeek(cls, week: Week, weekFilters: WeekFilters, **kwargs) -> int: + def getNumberOfValidTeamsInWeek( + cls, week: Week, weekFilters: WeekFilters, **kwargs + ) -> int: """ Returns the number of valid teams that are playing in the given week. A valid team is a team that is NOT in a matchup that is marked to be ignored and also matches the given filters. diff --git a/leeger/util/navigator/YearNavigator.py b/leeger/util/navigator/YearNavigator.py index 131f3274..6e108f7f 100644 --- a/leeger/util/navigator/YearNavigator.py +++ b/leeger/util/navigator/YearNavigator.py @@ -22,7 +22,9 @@ def getTeamById(year: Year, teamId: str) -> Team: for team in year.teams: if team.id == teamId: return team - raise DoesNotExistException(f"Team with ID '{teamId}' does not exist in the given Year.") + raise DoesNotExistException( + f"Team with ID '{teamId}' does not exist in the given Year." + ) @staticmethod def getDivisionById(year: Year, divisionId: str) -> Division: @@ -85,7 +87,9 @@ def getNumberOfGamesPlayed( return teamIdAndNumberOfGamesPlayed @staticmethod - def getAllScoresInYear(year: Year, simplifyMultiWeekMatchups=False) -> list[float | int]: + def getAllScoresInYear( + year: Year, simplifyMultiWeekMatchups=False + ) -> list[float | int]: """ Returns a list of all scores for the given Year. Will count all scores EXCEPT for IGNORE Matchups. @@ -110,7 +114,9 @@ def getAllMultiWeekMatchups( """ filters = filters if filters is not None else YearFilters.getForYear(year) if not filters.includeMultiWeekMatchups: - raise ValueError("Multi-Week matchups must be included in this calculation.") + raise ValueError( + "Multi-Week matchups must be included in this calculation." + ) multiWeekMatchupIdToMatchupListMap: dict[str, list[Matchup]] = dict() for i in range(filters.weekNumberStart - 1, filters.weekNumberEnd): @@ -133,13 +139,16 @@ def getAllMatchupsInYear(year: Year, filters: YearFilters = None) -> list[Matchu week = year.weeks[i] for matchup in week.matchups: if matchup.matchupType in filters.includeMatchupTypes and ( - filters.includeMultiWeekMatchups or matchup.multiWeekMatchupId is None + filters.includeMultiWeekMatchups + or matchup.multiWeekMatchupId is None ): allMatchups.append(matchup) return allMatchups @staticmethod - def getAllSimplifiedMatchupsInYear(year: Year, filters: YearFilters = None) -> list[Matchup]: + def getAllSimplifiedMatchupsInYear( + year: Year, filters: YearFilters = None + ) -> list[Matchup]: """ Returns a list of matchups for the given year with multi-week matchups simplified. """ @@ -147,15 +156,19 @@ def getAllSimplifiedMatchupsInYear(year: Year, filters: YearFilters = None) -> l filters = filters if filters is not None else YearFilters.getForYear(year) if not filters.includeMultiWeekMatchups: - raise ValueError("Multi-Week matchups must be included in this calculation.") + raise ValueError( + "Multi-Week matchups must be included in this calculation." + ) # get all non multi-week matchups modifiedFilters = copy.deepcopy(filters) modifiedFilters.includeMultiWeekMatchups = False - allMatchups: list[Matchup] = YearNavigator.getAllMatchupsInYear(year, modifiedFilters) + allMatchups: list[Matchup] = YearNavigator.getAllMatchupsInYear( + year, modifiedFilters + ) # get all multi-week matchups - allMultiWeekMatchups: dict[str, list[Matchup]] = YearNavigator.getAllMultiWeekMatchups( - year, filters + allMultiWeekMatchups: dict[str, list[Matchup]] = ( + YearNavigator.getAllMultiWeekMatchups(year, filters) ) # simplify multi-week matchups diff --git a/leeger/util/stat_sheet.py b/leeger/util/stat_sheet.py index 5ebb257e..d34b3ac6 100644 --- a/leeger/util/stat_sheet.py +++ b/leeger/util/stat_sheet.py @@ -23,18 +23,30 @@ from leeger.calculator.all_time_calculator.SmartWinsAllTimeCalculator import ( SmartWinsAllTimeCalculator, ) -from leeger.calculator.all_time_calculator.SSLAllTimeCalculator import SSLAllTimeCalculator +from leeger.calculator.all_time_calculator.SSLAllTimeCalculator import ( + SSLAllTimeCalculator, +) from leeger.calculator.year_calculator import ( ScoringStandardDeviationYearCalculator, SingleScoreYearCalculator, TeamSummaryYearCalculator, ) from leeger.calculator.year_calculator.AWALYearCalculator import AWALYearCalculator -from leeger.calculator.year_calculator.GameOutcomeYearCalculator import GameOutcomeYearCalculator -from leeger.calculator.year_calculator.PlusMinusYearCalculator import PlusMinusYearCalculator -from leeger.calculator.year_calculator.PointsScoredYearCalculator import PointsScoredYearCalculator -from leeger.calculator.year_calculator.ScoringShareYearCalculator import ScoringShareYearCalculator -from leeger.calculator.year_calculator.SmartWinsYearCalculator import SmartWinsYearCalculator +from leeger.calculator.year_calculator.GameOutcomeYearCalculator import ( + GameOutcomeYearCalculator, +) +from leeger.calculator.year_calculator.PlusMinusYearCalculator import ( + PlusMinusYearCalculator, +) +from leeger.calculator.year_calculator.PointsScoredYearCalculator import ( + PointsScoredYearCalculator, +) +from leeger.calculator.year_calculator.ScoringShareYearCalculator import ( + ScoringShareYearCalculator, +) +from leeger.calculator.year_calculator.SmartWinsYearCalculator import ( + SmartWinsYearCalculator, +) from leeger.calculator.year_calculator.SSLYearCalculator import SSLYearCalculator from leeger.model.league import League, Year from leeger.model.stat.AllTimeStatSheet import AllTimeStatSheet @@ -62,22 +74,30 @@ def leagueStatSheet(league: League, **kwargs) -> AllTimeStatSheet: # Smart Wins smartWins = SmartWinsAllTimeCalculator.getSmartWins(league, **kwargs) smartWinsPerGame = SmartWinsAllTimeCalculator.getSmartWinsPerGame(league, **kwargs) - opponentSmartWins = SmartWinsAllTimeCalculator.getOpponentSmartWins(league, **kwargs) + opponentSmartWins = SmartWinsAllTimeCalculator.getOpponentSmartWins( + league, **kwargs + ) opponentSmartWinsPerGame = SmartWinsAllTimeCalculator.getOpponentSmartWinsPerGame( league, **kwargs ) # Points Scored pointsScored = PointsScoredAllTimeCalculator.getPointsScored(league, **kwargs) - pointsScoredPerGame = PointsScoredAllTimeCalculator.getPointsScoredPerGame(league, **kwargs) - opponentPointsScored = PointsScoredAllTimeCalculator.getOpponentPointsScored(league, **kwargs) - opponentPointsScoredPerGame = PointsScoredAllTimeCalculator.getOpponentPointsScoredPerGame( + pointsScoredPerGame = PointsScoredAllTimeCalculator.getPointsScoredPerGame( + league, **kwargs + ) + opponentPointsScored = PointsScoredAllTimeCalculator.getOpponentPointsScored( league, **kwargs ) + opponentPointsScoredPerGame = ( + PointsScoredAllTimeCalculator.getOpponentPointsScoredPerGame(league, **kwargs) + ) # Scoring Share scoringShare = ScoringShareAllTimeCalculator.getScoringShare(league, **kwargs) - opponentScoringShare = ScoringShareAllTimeCalculator.getOpponentScoringShare(league, **kwargs) + opponentScoringShare = ScoringShareAllTimeCalculator.getOpponentScoringShare( + league, **kwargs + ) maxScoringShare = ScoringShareAllTimeCalculator.getMaxScoringShare(league, **kwargs) minScoringShare = ScoringShareAllTimeCalculator.getMinScoringShare(league, **kwargs) @@ -87,7 +107,9 @@ def leagueStatSheet(league: League, **kwargs) -> AllTimeStatSheet: # Scoring Standard Deviation scoringStandardDeviation = ( - ScoringStandardDeviationAllTimeCalculator.getScoringStandardDeviation(league, **kwargs) + ScoringStandardDeviationAllTimeCalculator.getScoringStandardDeviation( + league, **kwargs + ) ) # Plus Minus @@ -105,10 +127,14 @@ def leagueStatSheet(league: League, **kwargs) -> AllTimeStatSheet: for year in league.years: if year.yearSettings.leagueMedianGames is True: totalGames = TeamSummaryAllTimeCalculator.getTotalGames(league, **kwargs) - leagueMedianWins = GameOutcomeAllTimeCalculator.getLeagueMedianWins(league, **kwargs) - opponentLeagueMedianWins = GameOutcomeAllTimeCalculator.getOpponentLeagueMedianWins( + leagueMedianWins = GameOutcomeAllTimeCalculator.getLeagueMedianWins( league, **kwargs ) + opponentLeagueMedianWins = ( + GameOutcomeAllTimeCalculator.getOpponentLeagueMedianWins( + league, **kwargs + ) + ) break return AllTimeStatSheet( @@ -171,19 +197,27 @@ def yearStatSheet(year: Year, **kwargs) -> YearStatSheet: smartWins = SmartWinsYearCalculator.getSmartWins(year, **kwargs) smartWinsPerGame = SmartWinsYearCalculator.getSmartWinsPerGame(year, **kwargs) opponentSmartWins = SmartWinsYearCalculator.getOpponentSmartWins(year, **kwargs) - opponentSmartWinsPerGame = SmartWinsYearCalculator.getOpponentSmartWinsPerGame(year, **kwargs) + opponentSmartWinsPerGame = SmartWinsYearCalculator.getOpponentSmartWinsPerGame( + year, **kwargs + ) # Points Scored pointsScored = PointsScoredYearCalculator.getPointsScored(year, **kwargs) - pointsScoredPerGame = PointsScoredYearCalculator.getPointsScoredPerGame(year, **kwargs) - opponentPointsScored = PointsScoredYearCalculator.getOpponentPointsScored(year, **kwargs) - opponentPointsScoredPerGame = PointsScoredYearCalculator.getOpponentPointsScoredPerGame( + pointsScoredPerGame = PointsScoredYearCalculator.getPointsScoredPerGame( year, **kwargs ) + opponentPointsScored = PointsScoredYearCalculator.getOpponentPointsScored( + year, **kwargs + ) + opponentPointsScoredPerGame = ( + PointsScoredYearCalculator.getOpponentPointsScoredPerGame(year, **kwargs) + ) # Scoring Share scoringShare = ScoringShareYearCalculator.getScoringShare(year, **kwargs) - opponentScoringShare = ScoringShareYearCalculator.getOpponentScoringShare(year, **kwargs) + opponentScoringShare = ScoringShareYearCalculator.getOpponentScoringShare( + year, **kwargs + ) maxScoringShare = ScoringShareYearCalculator.getMaxScoringShare(year, **kwargs) minScoringShare = ScoringShareYearCalculator.getMinScoringShare(year, **kwargs) @@ -192,8 +226,10 @@ def yearStatSheet(year: Year, **kwargs) -> YearStatSheet: minScore = SingleScoreYearCalculator.getMinScore(year, **kwargs) # Scoring Standard Deviation - scoringStandardDeviation = ScoringStandardDeviationYearCalculator.getScoringStandardDeviation( - year, **kwargs + scoringStandardDeviation = ( + ScoringStandardDeviationYearCalculator.getScoringStandardDeviation( + year, **kwargs + ) ) # Plus Minus @@ -211,8 +247,8 @@ def yearStatSheet(year: Year, **kwargs) -> YearStatSheet: if year.yearSettings.leagueMedianGames is True: totalGames = TeamSummaryYearCalculator.getTotalGames(year, **kwargs) leagueMedianWins = GameOutcomeYearCalculator.getLeagueMedianWins(year, **kwargs) - opponentLeagueMedianWins = GameOutcomeYearCalculator.getOpponentLeagueMedianWins( - year, **kwargs + opponentLeagueMedianWins = ( + GameOutcomeYearCalculator.getOpponentLeagueMedianWins(year, **kwargs) ) return YearStatSheet( diff --git a/leeger/validate/divisionValidation.py b/leeger/validate/divisionValidation.py index 64d0a6b5..466fdc81 100644 --- a/leeger/validate/divisionValidation.py +++ b/leeger/validate/divisionValidation.py @@ -1,4 +1,6 @@ -from leeger.exception.InvalidDivisionFormatException import InvalidDivisionFormatException +from leeger.exception.InvalidDivisionFormatException import ( + InvalidDivisionFormatException, +) from leeger.model.league.Division import Division diff --git a/leeger/validate/leagueValidation.py b/leeger/validate/leagueValidation.py index 7e5791a0..d171a34b 100644 --- a/leeger/validate/leagueValidation.py +++ b/leeger/validate/leagueValidation.py @@ -96,7 +96,9 @@ def checkForDuplicateTeams(league: League) -> None: for year in league.years: for team in year.teams: if id(team) in teamInstanceIds: - raise InvalidLeagueFormatException("Teams must all be unique instances.") + raise InvalidLeagueFormatException( + "Teams must all be unique instances." + ) else: teamInstanceIds.append(id(team)) @@ -120,7 +122,9 @@ def checkNoDuplicateYearNumbers(league: League) -> None: if len(set([year.yearNumber for year in league.years])) != len( [year.yearNumber for year in league.years] ): - raise InvalidLeagueFormatException("Can only have 1 of each year number within a league.") + raise InvalidLeagueFormatException( + "Can only have 1 of each year number within a league." + ) def checkNoDuplicateOwnerNames(league: League) -> None: diff --git a/leeger/validate/matchupValidation.py b/leeger/validate/matchupValidation.py index 821847a5..a3ef374e 100644 --- a/leeger/validate/matchupValidation.py +++ b/leeger/validate/matchupValidation.py @@ -31,7 +31,9 @@ def checkAllTypes(matchup: Matchup) -> None: if not isinstance(matchup.matchupType, MatchupType): raise InvalidMatchupFormatException("matchupType must be type 'MatchupType'.") if not isinstance(matchup.multiWeekMatchupId, (str, type(None))): - raise InvalidMatchupFormatException("multiWeekMatchupId must be 'None' or type 'str'.") + raise InvalidMatchupFormatException( + "multiWeekMatchupId must be 'None' or type 'str'." + ) def checkForIllegalMatchupOutcomes(matchup: Matchup) -> None: @@ -54,4 +56,6 @@ def checkThatTeamIdsAreNotTheSame(matchup: Matchup) -> None: Checks that team A and team B have different IDs """ if matchup.teamAId == matchup.teamBId: - raise InvalidMatchupFormatException("Team A and Team B cannot have the same ID.") + raise InvalidMatchupFormatException( + "Team A and Team B cannot have the same ID." + ) diff --git a/leeger/validate/weekValidation.py b/leeger/validate/weekValidation.py index 7a5705fd..e00656d2 100644 --- a/leeger/validate/weekValidation.py +++ b/leeger/validate/weekValidation.py @@ -57,7 +57,9 @@ def checkWeekHasAtLeastOneMatchup(week: Week) -> None: Checks that the given Week has at least one Matchup. """ if len(week.matchups) == 0: - raise InvalidWeekFormatException(f"Week {week.weekNumber} must have at least 1 matchup.") + raise InvalidWeekFormatException( + f"Week {week.weekNumber} must have at least 1 matchup." + ) def checkWeekHasMatchupsWithNoDuplicateTeamIds(week: Week) -> None: @@ -91,7 +93,9 @@ def checkWeekDoesNotHaveMoreThanOneChampionshipMatchup(week: Week) -> None: ) -def checkWeekWithPlayoffOrChampionshipMatchupDoesNotHaveRegularSeasonMatchup(week: Week) -> None: +def checkWeekWithPlayoffOrChampionshipMatchupDoesNotHaveRegularSeasonMatchup( + week: Week, +) -> None: """ Checks that the given Week has no Regular Season Matchups IF it has a Playoff or Championship Matchup. """ diff --git a/leeger/validate/yearValidation.py b/leeger/validate/yearValidation.py index 7c8ada3e..a10efcaa 100644 --- a/leeger/validate/yearValidation.py +++ b/leeger/validate/yearValidation.py @@ -86,9 +86,13 @@ def checkAllTypes(year: Year) -> None: if not isinstance(year.yearNumber, int): raise InvalidYearFormatException("yearNumber must be type 'int'.") - if not isinstance(year.teams, list) or not all(isinstance(team, Team) for team in year.teams): + if not isinstance(year.teams, list) or not all( + isinstance(team, Team) for team in year.teams + ): raise InvalidYearFormatException("teams must be type 'list[Team]'.") - if not isinstance(year.weeks, list) or not all(isinstance(week, Week) for week in year.weeks): + if not isinstance(year.weeks, list) or not all( + isinstance(week, Week) for week in year.weeks + ): raise InvalidYearFormatException("weeks must be type 'list[Week]'.") if not isinstance(year.divisions, list) or not all( isinstance(division, Division) for division in year.divisions @@ -160,7 +164,9 @@ def checkAtLeastOneWeekInYear(year: Year) -> None: Checks that there is a minimum of 1 week in the given Year. """ if len(year.weeks) == 0: - raise InvalidYearFormatException(f"Year {year.yearNumber} does not have at least 1 week.") + raise InvalidYearFormatException( + f"Year {year.yearNumber} does not have at least 1 week." + ) def checkWeekNumberingInYear(year: Year) -> None: @@ -175,7 +181,9 @@ def checkWeekNumberingInYear(year: Year) -> None: weekNumbers.append(week.weekNumber) if len(set(weekNumbers)) != len(weekNumbers): - raise InvalidYearFormatException(f"Year {year.yearNumber} has duplicate week numbers.") + raise InvalidYearFormatException( + f"Year {year.yearNumber} has duplicate week numbers." + ) if weekNumbers[0] != 1: raise InvalidYearFormatException( @@ -219,7 +227,9 @@ def checkAtLeastTwoTeamsInYear(year: Year) -> None: Checks that there is at least 2 teams in the given Year. """ if len(year.teams) < 2: - raise InvalidYearFormatException(f"Year {year.yearNumber} needs at least 2 teams.") + raise InvalidYearFormatException( + f"Year {year.yearNumber} needs at least 2 teams." + ) def checkGivenYearHasValidYearNumber(year: Year) -> None: @@ -228,7 +238,9 @@ def checkGivenYearHasValidYearNumber(year: Year) -> None: 1920 is the year the NFL was founded, so we'll assume nobody was playing fantasy football before then. """ if year.yearNumber < 1920 or year.yearNumber > 2999: - raise InvalidYearFormatException(f"Year {year.yearNumber} is not in range 1920-2XXX.") + raise InvalidYearFormatException( + f"Year {year.yearNumber} is not in range 1920-2XXX." + ) def checkTeamNamesInYear(year: Year) -> None: @@ -238,8 +250,12 @@ def checkTeamNamesInYear(year: Year) -> None: - when whitespace is removed - when case is uniform """ - if len(set([team.name for team in year.teams])) != len([team.name for team in year.teams]): - raise InvalidYearFormatException(f"Year {year.yearNumber} has teams with duplicate names.") + if len(set([team.name for team in year.teams])) != len( + [team.name for team in year.teams] + ): + raise InvalidYearFormatException( + f"Year {year.yearNumber} has teams with duplicate names." + ) if len(set([team.name.strip().upper() for team in year.teams])) != len( [team.name for team in year.teams] ): @@ -302,7 +318,9 @@ def checkMultiWeekMatchupsAreInConsecutiveWeeks(year: Year): # skip first week since we can't end or invalidate any multi-week matchups after just 1 week if i != 0: - previousWeekMWMIDs = weekNumberToMultiWeekMatchupIdListMap[week.weekNumber - 1] + previousWeekMWMIDs = weekNumberToMultiWeekMatchupIdListMap[ + week.weekNumber - 1 + ] currentWeekMWMIDs = weekNumberToMultiWeekMatchupIdListMap[week.weekNumber] for mwmid in previousWeekMWMIDs: @@ -343,7 +361,10 @@ def checkMultiWeekMatchupsAreInMoreThanOneWeekOrAreNotTheMostRecentWeek(year: Ye isMostRecentWeekInYear, ] - for mwmid, countAndMostRecentWeek in multiWeekMatchupIdToCountAndMostRecentWeekMap.items(): + for ( + mwmid, + countAndMostRecentWeek, + ) in multiWeekMatchupIdToCountAndMostRecentWeekMap.items(): count, isMostRecentWeek = countAndMostRecentWeek if count == 1 and not isMostRecentWeek: raise InvalidYearFormatException( @@ -355,14 +376,15 @@ def checkMultiWeekMatchupsWithSameIdHaveSameMatchupType(year: Year): """ Checks that all multi-week matchups with the same ID have the same MatchupType. """ - multiWeekMatchupIdToMatchupListMap: dict[ - str, list[Matchup] - ] = YearNavigator.getAllMultiWeekMatchups(year) + multiWeekMatchupIdToMatchupListMap: dict[str, list[Matchup]] = ( + YearNavigator.getAllMultiWeekMatchups(year) + ) for mwmid, matchupList in multiWeekMatchupIdToMatchupListMap.items(): if len(matchupList) > 0: if not all( - matchup.matchupType == matchupList[0].matchupType for matchup in matchupList + matchup.matchupType == matchupList[0].matchupType + for matchup in matchupList ): raise InvalidYearFormatException( f"Multi-week matchups with ID '{mwmid}' do not all have the same matchup type." @@ -373,9 +395,9 @@ def checkMultiWeekMatchupsWithSameIdHaveSameTeamIds(year: Year): """ Checks that all multi-week matchups with the same ID have the same team A and team B """ - multiWeekMatchupIdToMatchupListMap: dict[ - str, list[Matchup] - ] = YearNavigator.getAllMultiWeekMatchups(year) + multiWeekMatchupIdToMatchupListMap: dict[str, list[Matchup]] = ( + YearNavigator.getAllMultiWeekMatchups(year) + ) for mwmid, matchupList in multiWeekMatchupIdToMatchupListMap.items(): if len(matchupList) > 0: @@ -393,9 +415,9 @@ def checkMultiWeekMatchupsWithSameIdHaveSameTiebreakers(year: Year): """ Checks that all multi-week matchups with the same ID have the same tiebreakers """ - multiWeekMatchupIdToMatchupListMap: dict[ - str, list[Matchup] - ] = YearNavigator.getAllMultiWeekMatchups(year) + multiWeekMatchupIdToMatchupListMap: dict[str, list[Matchup]] = ( + YearNavigator.getAllMultiWeekMatchups(year) + ) for mwmid, matchupList in multiWeekMatchupIdToMatchupListMap.items(): if len(matchupList) > 0: @@ -468,4 +490,6 @@ def checkDivisionsHaveNoDuplicateIds(year: Year): allDivisionIds = [division.id for division in year.divisions] if len(set(allDivisionIds)) != len(allDivisionIds): - raise InvalidYearFormatException(f"Year {year.yearNumber} has duplicate division IDs.") + raise InvalidYearFormatException( + f"Year {year.yearNumber} has duplicate division IDs." + ) diff --git a/pyproject.toml b/pyproject.toml index 1be4d82c..0866b674 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,2 @@ -[tool.black] -line-length = 100 -skip-magic-trailing-comma = true -include = '\.py$' -quiet = true - -[tool.isort] -profile = "black" -line_length = 100 - -[autoflake] -ignore_init_module_imports = true -in_place = true \ No newline at end of file +[tool.ruff.lint] +select = ["I001"] diff --git a/requirements.dev.txt b/requirements.dev.txt index 42eb42da..c7677572 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -1,7 +1,4 @@ wheel~=0.42.0 -black~=23.3.0 -autoflake~=2.1.1 -isort~=5.12.0 -pipreqs~=0.4.13 pytest~=7.4.3 twine~=5.1.1 +ruff~=0.5.7 diff --git a/setup.py b/setup.py index e08cd7cf..318c04b3 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,9 @@ long_description=readme, license="MIT", url="https://github.com/joeyagreco/leeger", - packages=setuptools.find_packages(exclude=("test", "doc", "example", "img", ".github")), + packages=setuptools.find_packages( + exclude=("test", "doc", "example", "img", ".github") + ), install_requires=required_packages, include_package_data=True, python_requires=f">={minimum_python_version_required}", diff --git a/test/test_calculator/test_all_time_calculator/test_AWALAllTimeCalculator.py b/test/test_calculator/test_all_time_calculator/test_AWALAllTimeCalculator.py index b4793aa7..22dba398 100644 --- a/test/test_calculator/test_all_time_calculator/test_AWALAllTimeCalculator.py +++ b/test/test_calculator/test_all_time_calculator/test_AWALAllTimeCalculator.py @@ -1,5 +1,4 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams, getTeamsFromOwners from leeger.calculator.all_time_calculator import AWALAllTimeCalculator from leeger.enum.MatchupType import MatchupType @@ -9,6 +8,7 @@ from leeger.model.league.Week import Week from leeger.model.league.Year import Year from leeger.util.Deci import Deci +from test.helper.prototypes import getNDefaultOwnersAndTeams, getTeamsFromOwners class TestAWALAllTimeCalculator(unittest.TestCase): @@ -17,21 +17,39 @@ def test_getAWAL_happyPath(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -54,23 +72,47 @@ def test_getAWAL_leagueMedianGamesIsOn_addsLeagueMedianWinsToAWAL(self): teamsC = getTeamsFromOwners(owners) yearSettings = YearSettings(leagueMedianGames=True) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) - yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a], yearSettings=yearSettings) + yearA = Year( + yearNumber=2000, teams=teamsA, weeks=[week1_a], yearSettings=yearSettings + ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b], yearSettings=yearSettings) + yearB = Year( + yearNumber=2001, teams=teamsB, weeks=[week1_b], yearSettings=yearSettings + ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) - yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c], yearSettings=yearSettings) + yearC = Year( + yearNumber=2002, teams=teamsC, weeks=[week1_c], yearSettings=yearSettings + ) league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) @@ -88,8 +130,12 @@ def test_getAWAL_leagueMedianGamesIsOn_addsLeagueMedianWinsToAWAL(self): def test_getAWAL_noneIfNoGamesPlayed(self): owners, teamsA = getNDefaultOwnersAndTeams(3) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=3, teamBScore=4) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=3, teamBScore=4 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) @@ -109,9 +155,15 @@ def test_getAWAL_onlyPostSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) @@ -139,9 +191,15 @@ def test_getAWAL_onlyPostSeasonIsTrue(self): week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -163,9 +221,15 @@ def test_getAWAL_onlyRegularSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) @@ -193,9 +257,15 @@ def test_getAWAL_onlyRegularSeasonIsTrue(self): week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -217,9 +287,15 @@ def test_getAWAL_onlyChampionshipIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) @@ -247,9 +323,15 @@ def test_getAWAL_onlyChampionshipIsTrue(self): week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -271,31 +353,57 @@ def test_getAWAL_yearNumberStartGivenWeekNumberStartGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = AWALAllTimeCalculator.getAWAL(league, yearNumberStart=2001, weekNumberStart=2) + response = AWALAllTimeCalculator.getAWAL( + league, yearNumberStart=2001, weekNumberStart=2 + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -311,31 +419,57 @@ def test_getAWAL_yearNumberEndGivenWeekNumberEndGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = AWALAllTimeCalculator.getAWAL(league, yearNumberEnd=2001, weekNumberEnd=2) + response = AWALAllTimeCalculator.getAWAL( + league, yearNumberEnd=2001, weekNumberEnd=2 + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -353,32 +487,60 @@ def test_getAWAL_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGivenWe teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) response = AWALAllTimeCalculator.getAWAL( - league, yearNumberStart=2001, weekNumberStart=1, yearNumberEnd=2001, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=1, + yearNumberEnd=2001, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) @@ -395,21 +557,39 @@ def test_getAWALPerGame_happyPath(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -432,23 +612,47 @@ def test_getAWALPerGame_leagueMedianGamesIsOn(self): teamsC = getTeamsFromOwners(owners) yearSettings = YearSettings(leagueMedianGames=True) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) - yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a], yearSettings=yearSettings) + yearA = Year( + yearNumber=2000, teams=teamsA, weeks=[week1_a], yearSettings=yearSettings + ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b], yearSettings=yearSettings) + yearB = Year( + yearNumber=2001, teams=teamsB, weeks=[week1_b], yearSettings=yearSettings + ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) - yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c], yearSettings=yearSettings) + yearC = Year( + yearNumber=2002, teams=teamsC, weeks=[week1_c], yearSettings=yearSettings + ) league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) @@ -466,8 +670,12 @@ def test_getAWALPerGame_leagueMedianGamesIsOn(self): def test_getAWALPerGame_noneIfNoGamesPlayed(self): owners, teamsA = getNDefaultOwnersAndTeams(3) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=3, teamBScore=4) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=3, teamBScore=4 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) @@ -487,9 +695,15 @@ def test_getAWALPerGame_onlyPostSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) @@ -517,9 +731,15 @@ def test_getAWALPerGame_onlyPostSeasonIsTrue(self): week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -541,9 +761,15 @@ def test_getAWALPerGame_onlyRegularSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) @@ -571,9 +797,15 @@ def test_getAWALPerGame_onlyRegularSeasonIsTrue(self): week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -595,9 +827,15 @@ def test_getAWALPerGame_onlyChampionshipIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) @@ -625,9 +863,15 @@ def test_getAWALPerGame_onlyChampionshipIsTrue(self): week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -649,25 +893,49 @@ def test_getAWALPerGame_yearNumberStartGivenWeekNumberStartGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -691,31 +959,57 @@ def test_getAWALPerGame_yearNumberEndGivenWeekNumberEndGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = AWALAllTimeCalculator.getAWALPerGame(league, yearNumberEnd=2001, weekNumberEnd=2) + response = AWALAllTimeCalculator.getAWALPerGame( + league, yearNumberEnd=2001, weekNumberEnd=2 + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -733,32 +1027,60 @@ def test_getAWALPerGame_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEnd teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) response = AWALAllTimeCalculator.getAWALPerGame( - league, yearNumberStart=2001, weekNumberStart=1, yearNumberEnd=2001, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=1, + yearNumberEnd=2001, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) @@ -775,21 +1097,39 @@ def test_getOpponentAWAL_happyPath(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -812,23 +1152,47 @@ def test_getOpponentAWAL_leagueMedianGamesIsOn_countsLeagueMedianGames(self): teamsC = getTeamsFromOwners(owners) yearSettings = YearSettings(leagueMedianGames=True) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) - yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a], yearSettings=yearSettings) + yearA = Year( + yearNumber=2000, teams=teamsA, weeks=[week1_a], yearSettings=yearSettings + ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b], yearSettings=yearSettings) + yearB = Year( + yearNumber=2001, teams=teamsB, weeks=[week1_b], yearSettings=yearSettings + ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) - yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c], yearSettings=yearSettings) + yearC = Year( + yearNumber=2002, teams=teamsC, weeks=[week1_c], yearSettings=yearSettings + ) league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) @@ -847,8 +1211,12 @@ def test_getOpponentAWAL_leagueMedianGamesIsOn_countsLeagueMedianGames(self): def test_getOpponentAWAL_noneIfNoGamesPlayed(self): owners, teamsA = getNDefaultOwnersAndTeams(3) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=3, teamBScore=4) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=3, teamBScore=4 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) @@ -868,9 +1236,15 @@ def test_getOpponentAWAL_onlyPostSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) @@ -898,9 +1272,15 @@ def test_getOpponentAWAL_onlyPostSeasonIsTrue(self): week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -922,9 +1302,15 @@ def test_getOpponentAWAL_onlyRegularSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) @@ -952,9 +1338,15 @@ def test_getOpponentAWAL_onlyRegularSeasonIsTrue(self): week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -976,9 +1368,15 @@ def test_getOpponentAWAL_onlyChampionshipIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) @@ -1006,9 +1404,15 @@ def test_getOpponentAWAL_onlyChampionshipIsTrue(self): week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -1030,25 +1434,49 @@ def test_getOpponentAWAL_yearNumberStartGivenWeekNumberStartGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -1072,25 +1500,49 @@ def test_getOpponentAWAL_yearNumberEndGivenWeekNumberEndGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -1116,32 +1568,60 @@ def test_getOpponentAWAL_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEn teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) response = AWALAllTimeCalculator.getOpponentAWAL( - league, yearNumberStart=2001, weekNumberStart=1, yearNumberEnd=2001, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=1, + yearNumberEnd=2001, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) @@ -1158,21 +1638,39 @@ def test_getOpponentAWALPerGame_happyPath(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -1195,23 +1693,47 @@ def test_getOpponentAWALPerGame_leagueMedianGamesIsOn(self): teamsC = getTeamsFromOwners(owners) yearSettings = YearSettings(leagueMedianGames=True) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) - yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a], yearSettings=yearSettings) + yearA = Year( + yearNumber=2000, teams=teamsA, weeks=[week1_a], yearSettings=yearSettings + ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b], yearSettings=yearSettings) + yearB = Year( + yearNumber=2001, teams=teamsB, weeks=[week1_b], yearSettings=yearSettings + ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) - yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c], yearSettings=yearSettings) + yearC = Year( + yearNumber=2002, teams=teamsC, weeks=[week1_c], yearSettings=yearSettings + ) league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) @@ -1229,8 +1751,12 @@ def test_getOpponentAWALPerGame_leagueMedianGamesIsOn(self): def test_getOpponentAWALPerGame_noneIfNoGamesPlayed(self): owners, teamsA = getNDefaultOwnersAndTeams(3) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=3, teamBScore=4) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=3, teamBScore=4 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) @@ -1250,9 +1776,15 @@ def test_getOpponentAWALPerGame_onlyPostSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) @@ -1280,15 +1812,23 @@ def test_getOpponentAWALPerGame_onlyPostSeasonIsTrue(self): week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = AWALAllTimeCalculator.getOpponentAWALPerGame(league, onlyPostSeason=True) + response = AWALAllTimeCalculator.getOpponentAWALPerGame( + league, onlyPostSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -1304,9 +1844,15 @@ def test_getOpponentAWALPerGame_onlyRegularSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) @@ -1334,15 +1880,23 @@ def test_getOpponentAWALPerGame_onlyRegularSeasonIsTrue(self): week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = AWALAllTimeCalculator.getOpponentAWALPerGame(league, onlyRegularSeason=True) + response = AWALAllTimeCalculator.getOpponentAWALPerGame( + league, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -1358,9 +1912,15 @@ def test_getOpponentAWALPerGame_onlyChampionshipIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) @@ -1388,15 +1948,23 @@ def test_getOpponentAWALPerGame_onlyChampionshipIsTrue(self): week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = AWALAllTimeCalculator.getOpponentAWALPerGame(league, onlyChampionship=True) + response = AWALAllTimeCalculator.getOpponentAWALPerGame( + league, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -1412,25 +1980,49 @@ def test_getOpponentAWALPerGame_yearNumberStartGivenWeekNumberStartGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -1454,25 +2046,49 @@ def test_getOpponentAWALPerGame_yearNumberEndGivenWeekNumberEndGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -1498,32 +2114,60 @@ def test_getOpponentAWALPerGame_yearNumberStartGivenWeekNumberStartGivenAndYearN teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) response = AWALAllTimeCalculator.getOpponentAWALPerGame( - league, yearNumberStart=2001, weekNumberStart=1, yearNumberEnd=2001, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=1, + yearNumberEnd=2001, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) diff --git a/test/test_calculator/test_all_time_calculator/test_GameOutcomeAllTimeCalculator.py b/test/test_calculator/test_all_time_calculator/test_GameOutcomeAllTimeCalculator.py index 657a9a8d..fb23a760 100644 --- a/test/test_calculator/test_all_time_calculator/test_GameOutcomeAllTimeCalculator.py +++ b/test/test_calculator/test_all_time_calculator/test_GameOutcomeAllTimeCalculator.py @@ -1,5 +1,4 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams, getTeamsFromOwners from leeger.calculator.all_time_calculator.GameOutcomeAllTimeCalculator import ( GameOutcomeAllTimeCalculator, @@ -11,6 +10,7 @@ from leeger.model.league.Week import Week from leeger.model.league.Year import Year from leeger.util.Deci import Deci +from test.helper.prototypes import getNDefaultOwnersAndTeams, getTeamsFromOwners class TestGameOutcomeAllTimeCalculator(unittest.TestCase): @@ -19,7 +19,9 @@ def test_getWins_happyPath(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -39,7 +41,9 @@ def test_getWins_happyPath(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -59,7 +63,9 @@ def test_getWins_happyPath(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -93,7 +99,9 @@ def test_getWins_multiWeekMatchups(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -115,7 +123,9 @@ def test_getWins_multiWeekMatchups(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -135,7 +145,9 @@ def test_getWins_multiWeekMatchups(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -167,8 +179,12 @@ def test_getWins_multiWeekMatchups(self): def test_getWins_noneIfNoGamesPlayed(self): owners, teamsA = getNDefaultOwnersAndTeams(3) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) @@ -188,7 +204,9 @@ def test_getWins_onlyPostSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -208,7 +226,9 @@ def test_getWins_onlyPostSeasonIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -228,7 +248,9 @@ def test_getWins_onlyPostSeasonIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -262,7 +284,9 @@ def test_getWins_onlyRegularSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -282,7 +306,9 @@ def test_getWins_onlyRegularSeasonIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -302,7 +328,9 @@ def test_getWins_onlyRegularSeasonIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -336,7 +364,9 @@ def test_getWins_onlyChampionshipIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -356,7 +386,9 @@ def test_getWins_onlyChampionshipIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -376,7 +408,9 @@ def test_getWins_onlyChampionshipIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -410,7 +444,9 @@ def test_getWins_yearNumberStartGivenWeekNumberStartGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -430,7 +466,9 @@ def test_getWins_yearNumberStartGivenWeekNumberStartGiven(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -450,7 +488,9 @@ def test_getWins_yearNumberStartGivenWeekNumberStartGiven(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -486,7 +526,9 @@ def test_getWins_yearNumberEndGivenWeekNumberEndGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -506,7 +548,9 @@ def test_getWins_yearNumberEndGivenWeekNumberEndGiven(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -526,7 +570,9 @@ def test_getWins_yearNumberEndGivenWeekNumberEndGiven(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -548,7 +594,9 @@ def test_getWins_yearNumberEndGivenWeekNumberEndGiven(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = GameOutcomeAllTimeCalculator.getWins(league, yearNumberEnd=2001, weekNumberEnd=2) + response = GameOutcomeAllTimeCalculator.getWins( + league, yearNumberEnd=2001, weekNumberEnd=2 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -563,7 +611,9 @@ def test_getWins_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGivenWe teamsC = getTeamsFromOwners(owners) teamsD = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -583,7 +633,9 @@ def test_getWins_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGivenWe week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -603,7 +655,9 @@ def test_getWins_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGivenWe week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -623,7 +677,9 @@ def test_getWins_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGivenWe week3_c = Week(weekNumber=3, matchups=[matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c, week2_c, week3_c]) - matchup1_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) + matchup1_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) matchup2_d = Matchup( teamAId=teamsD[0].id, teamBId=teamsD[1].id, @@ -646,7 +702,11 @@ def test_getWins_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGivenWe league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC, yearD]) response = GameOutcomeAllTimeCalculator.getWins( - league, yearNumberStart=2001, weekNumberStart=2, yearNumberEnd=2002, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=2, + yearNumberEnd=2002, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) @@ -659,7 +719,9 @@ def test_getLosses_happyPath(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -679,7 +741,9 @@ def test_getLosses_happyPath(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -699,7 +763,9 @@ def test_getLosses_happyPath(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -733,7 +799,9 @@ def test_getLosses_multiWeekMatchups(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -755,7 +823,9 @@ def test_getLosses_multiWeekMatchups(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -775,7 +845,9 @@ def test_getLosses_multiWeekMatchups(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -807,8 +879,12 @@ def test_getLosses_multiWeekMatchups(self): def test_getLosses_noneIfNoGamesPlayed(self): owners, teamsA = getNDefaultOwnersAndTeams(3) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) @@ -828,7 +904,9 @@ def test_getLosses_onlyPostSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -848,7 +926,9 @@ def test_getLosses_onlyPostSeasonIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -868,7 +948,9 @@ def test_getLosses_onlyPostSeasonIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -902,7 +984,9 @@ def test_getLosses_onlyRegularSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -922,7 +1006,9 @@ def test_getLosses_onlyRegularSeasonIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -942,7 +1028,9 @@ def test_getLosses_onlyRegularSeasonIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -964,7 +1052,9 @@ def test_getLosses_onlyRegularSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = GameOutcomeAllTimeCalculator.getLosses(league, onlyRegularSeason=True) + response = GameOutcomeAllTimeCalculator.getLosses( + league, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -976,7 +1066,9 @@ def test_getLosses_onlyChampionshipIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -996,7 +1088,9 @@ def test_getLosses_onlyChampionshipIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -1016,7 +1110,9 @@ def test_getLosses_onlyChampionshipIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -1050,7 +1146,9 @@ def test_getLosses_yearNumberStartGivenWeekNumberStartGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -1070,7 +1168,9 @@ def test_getLosses_yearNumberStartGivenWeekNumberStartGiven(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -1090,7 +1190,9 @@ def test_getLosses_yearNumberStartGivenWeekNumberStartGiven(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -1126,7 +1228,9 @@ def test_getLosses_yearNumberEndGivenWeekNumberEndGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -1146,7 +1250,9 @@ def test_getLosses_yearNumberEndGivenWeekNumberEndGiven(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -1166,7 +1272,9 @@ def test_getLosses_yearNumberEndGivenWeekNumberEndGiven(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -1205,7 +1313,9 @@ def test_getLosses_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGiven teamsC = getTeamsFromOwners(owners) teamsD = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -1225,7 +1335,9 @@ def test_getLosses_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGiven week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -1245,7 +1357,9 @@ def test_getLosses_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGiven week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -1265,7 +1379,9 @@ def test_getLosses_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGiven week3_c = Week(weekNumber=3, matchups=[matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c, week2_c, week3_c]) - matchup1_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) + matchup1_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) matchup2_d = Matchup( teamAId=teamsD[0].id, teamBId=teamsD[1].id, @@ -1288,7 +1404,11 @@ def test_getLosses_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGiven league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC, yearD]) response = GameOutcomeAllTimeCalculator.getLosses( - league, yearNumberStart=2001, weekNumberStart=2, yearNumberEnd=2002, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=2, + yearNumberEnd=2002, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) @@ -1301,7 +1421,9 @@ def test_getTies_happyPath(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -1321,7 +1443,9 @@ def test_getTies_happyPath(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=1) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=1 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -1341,7 +1465,9 @@ def test_getTies_happyPath(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -1375,7 +1501,9 @@ def test_getTies_multiWeekMatchups(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -1395,7 +1523,9 @@ def test_getTies_multiWeekMatchups(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=1) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=1 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -1415,7 +1545,9 @@ def test_getTies_multiWeekMatchups(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -1447,8 +1579,12 @@ def test_getTies_multiWeekMatchups(self): def test_getTies_noneIfNoGamesPlayed(self): owners, teamsA = getNDefaultOwnersAndTeams(3) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1) - matchup2_a = Matchup(teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=1) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1 + ) + matchup2_a = Matchup( + teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=1 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) @@ -1468,7 +1604,9 @@ def test_getTies_onlyPostSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -1488,7 +1626,9 @@ def test_getTies_onlyPostSeasonIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=1) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=1 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -1508,7 +1648,9 @@ def test_getTies_onlyPostSeasonIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -1542,7 +1684,9 @@ def test_getTies_onlyRegularSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -1562,7 +1706,9 @@ def test_getTies_onlyRegularSeasonIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=1) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=1 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -1582,7 +1728,9 @@ def test_getTies_onlyRegularSeasonIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -1616,7 +1764,9 @@ def test_getTies_onlyChampionshipIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -1636,7 +1786,9 @@ def test_getTies_onlyChampionshipIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=1) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=1 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -1656,7 +1808,9 @@ def test_getTies_onlyChampionshipIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -1690,7 +1844,9 @@ def test_getTies_yearNumberStartGivenWeekNumberStartGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -1710,7 +1866,9 @@ def test_getTies_yearNumberStartGivenWeekNumberStartGiven(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=1) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=1 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -1730,7 +1888,9 @@ def test_getTies_yearNumberStartGivenWeekNumberStartGiven(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -1766,7 +1926,9 @@ def test_getTies_yearNumberEndGivenWeekNumberEndGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -1786,7 +1948,9 @@ def test_getTies_yearNumberEndGivenWeekNumberEndGiven(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=1) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=1 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -1806,7 +1970,9 @@ def test_getTies_yearNumberEndGivenWeekNumberEndGiven(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -1828,7 +1994,9 @@ def test_getTies_yearNumberEndGivenWeekNumberEndGiven(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = GameOutcomeAllTimeCalculator.getTies(league, yearNumberEnd=2001, weekNumberEnd=2) + response = GameOutcomeAllTimeCalculator.getTies( + league, yearNumberEnd=2001, weekNumberEnd=2 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -1843,7 +2011,9 @@ def test_getTies_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGivenWe teamsC = getTeamsFromOwners(owners) teamsD = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -1863,7 +2033,9 @@ def test_getTies_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGivenWe week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=1) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=1 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -1883,7 +2055,9 @@ def test_getTies_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGivenWe week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -1903,7 +2077,9 @@ def test_getTies_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGivenWe week3_c = Week(weekNumber=3, matchups=[matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c, week2_c, week3_c]) - matchup1_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) + matchup1_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) matchup2_d = Matchup( teamAId=teamsD[0].id, teamBId=teamsD[1].id, @@ -1926,7 +2102,11 @@ def test_getTies_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGivenWe league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC, yearD]) response = GameOutcomeAllTimeCalculator.getTies( - league, yearNumberStart=2001, weekNumberStart=2, yearNumberEnd=2002, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=2, + yearNumberEnd=2002, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) @@ -1939,7 +2119,9 @@ def test_getWinPercentage_happyPath(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -1959,7 +2141,9 @@ def test_getWinPercentage_happyPath(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -1979,7 +2163,9 @@ def test_getWinPercentage_happyPath(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -2014,9 +2200,15 @@ def test_getWinPercentage_leagueMedianGamesIsOn_happyPath(self): teamsC = getTeamsFromOwners(owners) yearSettings = YearSettings(leagueMedianGames=True) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup3_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) week3_a = Week(weekNumber=3, matchups=[matchup3_a]) @@ -2027,9 +2219,15 @@ def test_getWinPercentage_leagueMedianGamesIsOn_happyPath(self): yearSettings=yearSettings, ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1) - matchup3_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1 + ) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1 + ) + matchup3_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) week3_b = Week(weekNumber=3, matchups=[matchup3_b]) @@ -2040,9 +2238,15 @@ def test_getWinPercentage_leagueMedianGamesIsOn_happyPath(self): yearSettings=yearSettings, ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=2, teamBScore=1) - matchup3_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=2, teamBScore=1 + ) + matchup3_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c]) week2_c = Week(weekNumber=2, matchups=[matchup2_c]) week3_c = Week(weekNumber=3, matchups=[matchup3_c]) @@ -2067,7 +2271,9 @@ def test_getWinPercentage_multiWeekMatchups(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -2089,7 +2295,9 @@ def test_getWinPercentage_multiWeekMatchups(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=1) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=1 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -2109,7 +2317,9 @@ def test_getWinPercentage_multiWeekMatchups(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -2141,15 +2351,21 @@ def test_getWinPercentage_multiWeekMatchups(self): def test_getWinPercentage_noneIfNoGamesPlayed(self): owners, teamsA = getNDefaultOwnersAndTeams(3) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) league = League(name="TEST", owners=owners, years=[yearA]) - response = GameOutcomeAllTimeCalculator.getWinPercentage(league, weekNumberEnd=1) + response = GameOutcomeAllTimeCalculator.getWinPercentage( + league, weekNumberEnd=1 + ) self.assertIsInstance(response, dict) self.assertEqual(3, len(response.keys())) @@ -2162,7 +2378,9 @@ def test_getWinPercentage_onlyPostSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=2, teamBScore=1) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=2, teamBScore=1 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -2182,7 +2400,9 @@ def test_getWinPercentage_onlyPostSeasonIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -2202,7 +2422,9 @@ def test_getWinPercentage_onlyPostSeasonIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -2224,7 +2446,9 @@ def test_getWinPercentage_onlyPostSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = GameOutcomeAllTimeCalculator.getWinPercentage(league, onlyPostSeason=True) + response = GameOutcomeAllTimeCalculator.getWinPercentage( + league, onlyPostSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -2236,7 +2460,9 @@ def test_getWinPercentage_onlyRegularSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -2256,7 +2482,9 @@ def test_getWinPercentage_onlyRegularSeasonIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -2276,7 +2504,9 @@ def test_getWinPercentage_onlyRegularSeasonIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -2298,7 +2528,9 @@ def test_getWinPercentage_onlyRegularSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = GameOutcomeAllTimeCalculator.getWinPercentage(league, onlyRegularSeason=True) + response = GameOutcomeAllTimeCalculator.getWinPercentage( + league, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -2310,7 +2542,9 @@ def test_getWinPercentage_onlyChampionshipIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -2330,7 +2564,9 @@ def test_getWinPercentage_onlyChampionshipIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -2350,7 +2586,9 @@ def test_getWinPercentage_onlyChampionshipIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -2372,7 +2610,9 @@ def test_getWinPercentage_onlyChampionshipIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = GameOutcomeAllTimeCalculator.getWinPercentage(league, onlyChampionship=True) + response = GameOutcomeAllTimeCalculator.getWinPercentage( + league, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -2384,7 +2624,9 @@ def test_getWinPercentage_yearNumberStartGivenWeekNumberStartGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -2404,7 +2646,9 @@ def test_getWinPercentage_yearNumberStartGivenWeekNumberStartGiven(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -2424,7 +2668,9 @@ def test_getWinPercentage_yearNumberStartGivenWeekNumberStartGiven(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=2, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=2, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -2460,7 +2706,9 @@ def test_getWinPercentage_yearNumberEndGivenWeekNumberEndGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=2, teamBScore=1) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=2, teamBScore=1 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -2480,7 +2728,9 @@ def test_getWinPercentage_yearNumberEndGivenWeekNumberEndGiven(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -2500,7 +2750,9 @@ def test_getWinPercentage_yearNumberEndGivenWeekNumberEndGiven(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -2539,7 +2791,9 @@ def test_getWinPercentage_yearNumberStartGivenWeekNumberStartGivenAndYearNumberE teamsC = getTeamsFromOwners(owners) teamsD = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -2559,7 +2813,9 @@ def test_getWinPercentage_yearNumberStartGivenWeekNumberStartGivenAndYearNumberE week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -2579,7 +2835,9 @@ def test_getWinPercentage_yearNumberStartGivenWeekNumberStartGivenAndYearNumberE week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=2, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=2, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -2599,7 +2857,9 @@ def test_getWinPercentage_yearNumberStartGivenWeekNumberStartGivenAndYearNumberE week3_c = Week(weekNumber=3, matchups=[matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c, week2_c, week3_c]) - matchup1_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) + matchup1_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) matchup2_d = Matchup( teamAId=teamsD[0].id, teamBId=teamsD[1].id, @@ -2622,7 +2882,11 @@ def test_getWinPercentage_yearNumberStartGivenWeekNumberStartGivenAndYearNumberE league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC, yearD]) response = GameOutcomeAllTimeCalculator.getWinPercentage( - league, yearNumberStart=2001, weekNumberStart=2, yearNumberEnd=2002, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=2, + yearNumberEnd=2002, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) @@ -2635,7 +2899,9 @@ def test_getWAL_happyPath(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -2655,7 +2921,9 @@ def test_getWAL_happyPath(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -2675,7 +2943,9 @@ def test_getWAL_happyPath(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -2710,9 +2980,15 @@ def test_getWAL_leagueMedianGamesIsTrue_happyPath(self): teamsC = getTeamsFromOwners(owners) yearSettings = YearSettings(leagueMedianGames=True) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup3_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) week3_a = Week(weekNumber=3, matchups=[matchup3_a]) @@ -2723,9 +2999,15 @@ def test_getWAL_leagueMedianGamesIsTrue_happyPath(self): yearSettings=yearSettings, ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1) - matchup3_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1 + ) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1 + ) + matchup3_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) week3_b = Week(weekNumber=3, matchups=[matchup3_b]) @@ -2736,9 +3018,15 @@ def test_getWAL_leagueMedianGamesIsTrue_happyPath(self): yearSettings=yearSettings, ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) - matchup2_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=2, teamBScore=1) - matchup3_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) + matchup2_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=2, teamBScore=1 + ) + matchup3_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c]) week2_c = Week(weekNumber=2, matchups=[matchup2_c]) week3_c = Week(weekNumber=3, matchups=[matchup3_c]) @@ -2763,7 +3051,9 @@ def test_getWAL_multiWeekMatchups(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -2785,7 +3075,9 @@ def test_getWAL_multiWeekMatchups(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -2805,7 +3097,9 @@ def test_getWAL_multiWeekMatchups(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -2837,8 +3131,12 @@ def test_getWAL_multiWeekMatchups(self): def test_getWAL_noneIfNoGamesPlayed(self): owners, teamsA = getNDefaultOwnersAndTeams(3) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) @@ -2858,7 +3156,9 @@ def test_getWAL_onlyPostSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=2, teamBScore=1) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=2, teamBScore=1 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -2878,7 +3178,9 @@ def test_getWAL_onlyPostSeasonIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -2898,7 +3200,9 @@ def test_getWAL_onlyPostSeasonIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -2932,7 +3236,9 @@ def test_getWAL_onlyRegularSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -2952,7 +3258,9 @@ def test_getWAL_onlyRegularSeasonIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -2972,7 +3280,9 @@ def test_getWAL_onlyRegularSeasonIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -3006,7 +3316,9 @@ def test_getWAL_onlyChampionshipIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -3026,7 +3338,9 @@ def test_getWAL_onlyChampionshipIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -3046,7 +3360,9 @@ def test_getWAL_onlyChampionshipIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -3080,7 +3396,9 @@ def test_getWAL_yearNumberStartGivenWeekNumberStartGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -3100,7 +3418,9 @@ def test_getWAL_yearNumberStartGivenWeekNumberStartGiven(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -3120,7 +3440,9 @@ def test_getWAL_yearNumberStartGivenWeekNumberStartGiven(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -3156,7 +3478,9 @@ def test_getWAL_yearNumberEndGivenWeekNumberEndGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -3176,7 +3500,9 @@ def test_getWAL_yearNumberEndGivenWeekNumberEndGiven(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -3196,7 +3522,9 @@ def test_getWAL_yearNumberEndGivenWeekNumberEndGiven(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -3218,7 +3546,9 @@ def test_getWAL_yearNumberEndGivenWeekNumberEndGiven(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = GameOutcomeAllTimeCalculator.getWAL(league, yearNumberEnd=2001, weekNumberEnd=2) + response = GameOutcomeAllTimeCalculator.getWAL( + league, yearNumberEnd=2001, weekNumberEnd=2 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -3233,7 +3563,9 @@ def test_getWAL_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGivenWee teamsC = getTeamsFromOwners(owners) teamsD = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -3253,7 +3585,9 @@ def test_getWAL_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGivenWee week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -3273,7 +3607,9 @@ def test_getWAL_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGivenWee week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -3293,7 +3629,9 @@ def test_getWAL_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGivenWee week3_c = Week(weekNumber=3, matchups=[matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c, week2_c, week3_c]) - matchup1_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) + matchup1_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) matchup2_d = Matchup( teamAId=teamsD[0].id, teamBId=teamsD[1].id, @@ -3316,7 +3654,11 @@ def test_getWAL_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGivenWee league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC, yearD]) response = GameOutcomeAllTimeCalculator.getWAL( - league, yearNumberStart=2001, weekNumberStart=2, yearNumberEnd=2002, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=2, + yearNumberEnd=2002, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) @@ -3329,7 +3671,9 @@ def test_getWALPerGame_happyPath(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -3349,7 +3693,9 @@ def test_getWALPerGame_happyPath(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -3369,7 +3715,9 @@ def test_getWALPerGame_happyPath(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -3404,9 +3752,15 @@ def test_getWALPerGame_leagueMedianGamesIsOn_happyPath(self): teamsC = getTeamsFromOwners(owners) yearSettings = YearSettings(leagueMedianGames=True) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup3_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) week3_a = Week(weekNumber=3, matchups=[matchup3_a]) @@ -3417,9 +3771,15 @@ def test_getWALPerGame_leagueMedianGamesIsOn_happyPath(self): yearSettings=yearSettings, ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1) - matchup3_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1 + ) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1 + ) + matchup3_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) week3_b = Week(weekNumber=3, matchups=[matchup3_b]) @@ -3430,9 +3790,15 @@ def test_getWALPerGame_leagueMedianGamesIsOn_happyPath(self): yearSettings=yearSettings, ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) - matchup2_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=2, teamBScore=1) - matchup3_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) + matchup2_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=2, teamBScore=1 + ) + matchup3_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c]) week2_c = Week(weekNumber=2, matchups=[matchup2_c]) week3_c = Week(weekNumber=3, matchups=[matchup3_c]) @@ -3457,7 +3823,9 @@ def test_getWALPerGame_multiWeekMatchups(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -3479,7 +3847,9 @@ def test_getWALPerGame_multiWeekMatchups(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -3499,7 +3869,9 @@ def test_getWALPerGame_multiWeekMatchups(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -3531,8 +3903,12 @@ def test_getWALPerGame_multiWeekMatchups(self): def test_getWALPerGame_noneIfNoGamesPlayed(self): owners, teamsA = getNDefaultOwnersAndTeams(3) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) @@ -3552,7 +3928,9 @@ def test_getWALPerGame_onlyPostSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=2, teamBScore=1) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=2, teamBScore=1 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -3572,7 +3950,9 @@ def test_getWALPerGame_onlyPostSeasonIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -3592,7 +3972,9 @@ def test_getWALPerGame_onlyPostSeasonIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -3614,7 +3996,9 @@ def test_getWALPerGame_onlyPostSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = GameOutcomeAllTimeCalculator.getWALPerGame(league, onlyPostSeason=True) + response = GameOutcomeAllTimeCalculator.getWALPerGame( + league, onlyPostSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -3626,7 +4010,9 @@ def test_getWALPerGame_onlyRegularSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -3646,7 +4032,9 @@ def test_getWALPerGame_onlyRegularSeasonIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -3666,7 +4054,9 @@ def test_getWALPerGame_onlyRegularSeasonIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -3688,7 +4078,9 @@ def test_getWALPerGame_onlyRegularSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = GameOutcomeAllTimeCalculator.getWALPerGame(league, onlyRegularSeason=True) + response = GameOutcomeAllTimeCalculator.getWALPerGame( + league, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -3700,7 +4092,9 @@ def test_getWALPerGame_onlyChampionshipIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -3720,7 +4114,9 @@ def test_getWALPerGame_onlyChampionshipIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -3740,7 +4136,9 @@ def test_getWALPerGame_onlyChampionshipIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -3762,7 +4160,9 @@ def test_getWALPerGame_onlyChampionshipIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = GameOutcomeAllTimeCalculator.getWALPerGame(league, onlyChampionship=True) + response = GameOutcomeAllTimeCalculator.getWALPerGame( + league, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -3774,7 +4174,9 @@ def test_getWALPerGame_yearNumberStartGivenWeekNumberStartGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -3794,7 +4196,9 @@ def test_getWALPerGame_yearNumberStartGivenWeekNumberStartGiven(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -3814,7 +4218,9 @@ def test_getWALPerGame_yearNumberStartGivenWeekNumberStartGiven(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -3850,7 +4256,9 @@ def test_getWALPerGame_yearNumberEndGivenWeekNumberEndGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -3870,7 +4278,9 @@ def test_getWALPerGame_yearNumberEndGivenWeekNumberEndGiven(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -3890,7 +4300,9 @@ def test_getWALPerGame_yearNumberEndGivenWeekNumberEndGiven(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -3929,7 +4341,9 @@ def test_getWALPerGame_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndG teamsC = getTeamsFromOwners(owners) teamsD = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -3949,7 +4363,9 @@ def test_getWALPerGame_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndG week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -3969,7 +4385,9 @@ def test_getWALPerGame_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndG week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -3989,7 +4407,9 @@ def test_getWALPerGame_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndG week3_c = Week(weekNumber=3, matchups=[matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c, week2_c, week3_c]) - matchup1_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) + matchup1_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) matchup2_d = Matchup( teamAId=teamsD[0].id, teamBId=teamsD[1].id, @@ -4012,7 +4432,11 @@ def test_getWALPerGame_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndG league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC, yearD]) response = GameOutcomeAllTimeCalculator.getWALPerGame( - league, yearNumberStart=2001, weekNumberStart=2, yearNumberEnd=2002, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=2, + yearNumberEnd=2002, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) @@ -4027,9 +4451,15 @@ def test_getLeagueMedianWins_happyPath(self): yearSettings = YearSettings(leagueMedianGames=True) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup3_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) week3_a = Week(weekNumber=3, matchups=[matchup3_a]) @@ -4040,9 +4470,15 @@ def test_getLeagueMedianWins_happyPath(self): yearSettings=yearSettings, ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup3_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) week3_b = Week(weekNumber=3, matchups=[matchup3_b]) @@ -4053,9 +4489,15 @@ def test_getLeagueMedianWins_happyPath(self): yearSettings=yearSettings, ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup3_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c]) week2_c = Week(weekNumber=2, matchups=[matchup2_c]) week3_c = Week(weekNumber=3, matchups=[matchup3_c]) @@ -4075,16 +4517,24 @@ def test_getLeagueMedianWins_happyPath(self): self.assertEqual(0, response[owners[0].id]) self.assertEqual(9, response[owners[1].id]) - def test_getLeagueMedianWins_yearsHaveLeagueMedianGamesOff_returnsZeroForEachTeam(self): + def test_getLeagueMedianWins_yearsHaveLeagueMedianGamesOff_returnsZeroForEachTeam( + self, + ): owners, teamsA = getNDefaultOwnersAndTeams(2) teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) yearSettings = YearSettings(leagueMedianGames=False) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup3_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) week3_a = Week(weekNumber=3, matchups=[matchup3_a]) @@ -4095,9 +4545,15 @@ def test_getLeagueMedianWins_yearsHaveLeagueMedianGamesOff_returnsZeroForEachTea yearSettings=yearSettings, ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup3_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) week3_b = Week(weekNumber=3, matchups=[matchup3_b]) @@ -4108,9 +4564,15 @@ def test_getLeagueMedianWins_yearsHaveLeagueMedianGamesOff_returnsZeroForEachTea yearSettings=yearSettings, ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup3_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c]) week2_c = Week(weekNumber=2, matchups=[matchup2_c]) week3_c = Week(weekNumber=3, matchups=[matchup3_c]) @@ -4136,9 +4598,15 @@ def test_getLeagueMedianWins_tieForLeagueMedian_happyPath(self): teamsC = getTeamsFromOwners(owners) yearSettings = YearSettings(leagueMedianGames=True) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup3_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1 + ) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) week3_a = Week(weekNumber=3, matchups=[matchup3_a]) @@ -4149,9 +4617,15 @@ def test_getLeagueMedianWins_tieForLeagueMedian_happyPath(self): yearSettings=yearSettings, ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=1) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup3_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=1 + ) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) week3_b = Week(weekNumber=3, matchups=[matchup3_b]) @@ -4162,9 +4636,15 @@ def test_getLeagueMedianWins_tieForLeagueMedian_happyPath(self): yearSettings=yearSettings, ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) - matchup2_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup3_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) + matchup2_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c]) week2_c = Week(weekNumber=2, matchups=[matchup2_c]) week3_c = Week(weekNumber=3, matchups=[matchup3_c]) @@ -4187,18 +4667,27 @@ def test_getLeagueMedianWins_tieForLeagueMedian_happyPath(self): def test_getLeagueMedianWins_noneIfNoGamesPlayed(self): owners, teamsA = getNDefaultOwnersAndTeams(3) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) yearSettings = YearSettings(leagueMedianGames=True) yearA = Year( - yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a], yearSettings=yearSettings + yearNumber=2000, + teams=teamsA, + weeks=[week1_a, week2_a], + yearSettings=yearSettings, ) league = League(name="TEST", owners=owners, years=[yearA]) - response = GameOutcomeAllTimeCalculator.getLeagueMedianWins(league, weekNumberEnd=1) + response = GameOutcomeAllTimeCalculator.getLeagueMedianWins( + league, weekNumberEnd=1 + ) self.assertIsInstance(response, dict) self.assertEqual(3, len(response.keys())) @@ -4211,7 +4700,9 @@ def test_getLeagueMedianWins_onlyPostSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -4231,7 +4722,9 @@ def test_getLeagueMedianWins_onlyPostSeasonIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -4251,7 +4744,9 @@ def test_getLeagueMedianWins_onlyPostSeasonIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -4273,7 +4768,9 @@ def test_getLeagueMedianWins_onlyPostSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = GameOutcomeAllTimeCalculator.getLeagueMedianWins(league, onlyPostSeason=True) + response = GameOutcomeAllTimeCalculator.getLeagueMedianWins( + league, onlyPostSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -4286,7 +4783,9 @@ def test_getLeagueMedianWins_onlyRegularSeasonIsTrue(self): teamsC = getTeamsFromOwners(owners) yearSettings = YearSettings(leagueMedianGames=True) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -4311,7 +4810,9 @@ def test_getLeagueMedianWins_onlyRegularSeasonIsTrue(self): yearSettings=yearSettings, ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -4336,7 +4837,9 @@ def test_getLeagueMedianWins_onlyRegularSeasonIsTrue(self): yearSettings=yearSettings, ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -4363,7 +4866,9 @@ def test_getLeagueMedianWins_onlyRegularSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = GameOutcomeAllTimeCalculator.getLeagueMedianWins(league, onlyRegularSeason=True) + response = GameOutcomeAllTimeCalculator.getLeagueMedianWins( + league, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -4375,7 +4880,9 @@ def test_getLeagueMedianWins_onlyChampionshipIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -4395,7 +4902,9 @@ def test_getLeagueMedianWins_onlyChampionshipIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -4415,7 +4924,9 @@ def test_getLeagueMedianWins_onlyChampionshipIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -4437,7 +4948,9 @@ def test_getLeagueMedianWins_onlyChampionshipIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = GameOutcomeAllTimeCalculator.getLeagueMedianWins(league, onlyChampionship=True) + response = GameOutcomeAllTimeCalculator.getLeagueMedianWins( + league, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -4449,9 +4962,15 @@ def test_getLeagueMedianWins_yearNumberStartGivenWeekNumberStartGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup3_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) week3_a = Week(weekNumber=3, matchups=[matchup3_a]) @@ -4464,9 +4983,15 @@ def test_getLeagueMedianWins_yearNumberStartGivenWeekNumberStartGiven(self): yearSettings=yearSettings, ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup3_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) week3_b = Week(weekNumber=3, matchups=[matchup3_b]) @@ -4477,9 +5002,15 @@ def test_getLeagueMedianWins_yearNumberStartGivenWeekNumberStartGiven(self): yearSettings=yearSettings, ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup3_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c]) week2_c = Week(weekNumber=2, matchups=[matchup2_c]) week3_c = Week(weekNumber=3, matchups=[matchup3_c]) @@ -4506,9 +5037,15 @@ def test_getLeagueMedianWins_yearNumberEndGivenWeekNumberEndGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup3_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) week3_a = Week(weekNumber=3, matchups=[matchup3_a]) @@ -4521,9 +5058,15 @@ def test_getLeagueMedianWins_yearNumberEndGivenWeekNumberEndGiven(self): yearSettings=yearSettings, ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup3_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) week3_b = Week(weekNumber=3, matchups=[matchup3_b]) @@ -4534,9 +5077,15 @@ def test_getLeagueMedianWins_yearNumberEndGivenWeekNumberEndGiven(self): yearSettings=yearSettings, ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup3_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c]) week2_c = Week(weekNumber=2, matchups=[matchup2_c]) week3_c = Week(weekNumber=3, matchups=[matchup3_c]) @@ -4567,9 +5116,15 @@ def test_getLeagueMedianWins_yearNumberStartGivenWeekNumberStartGivenAndYearNumb teamsD = getTeamsFromOwners(owners) yearSettings = YearSettings(leagueMedianGames=True) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup3_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) week3_a = Week(weekNumber=3, matchups=[matchup3_a]) @@ -4580,9 +5135,15 @@ def test_getLeagueMedianWins_yearNumberStartGivenWeekNumberStartGivenAndYearNumb yearSettings=yearSettings, ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup3_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) week3_b = Week(weekNumber=3, matchups=[matchup3_b]) @@ -4593,9 +5154,15 @@ def test_getLeagueMedianWins_yearNumberStartGivenWeekNumberStartGivenAndYearNumb yearSettings=yearSettings, ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup3_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c]) week2_c = Week(weekNumber=2, matchups=[matchup2_c]) week3_c = Week(weekNumber=3, matchups=[matchup3_c]) @@ -4606,9 +5173,15 @@ def test_getLeagueMedianWins_yearNumberStartGivenWeekNumberStartGivenAndYearNumb yearSettings=yearSettings, ) - matchup1_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) - matchup2_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) - matchup3_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) + matchup1_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) week1_d = Week(weekNumber=1, matchups=[matchup1_d]) week2_d = Week(weekNumber=2, matchups=[matchup2_d]) week3_d = Week(weekNumber=3, matchups=[matchup3_d]) @@ -4617,7 +5190,11 @@ def test_getLeagueMedianWins_yearNumberStartGivenWeekNumberStartGivenAndYearNumb league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC, yearD]) response = GameOutcomeAllTimeCalculator.getLeagueMedianWins( - league, yearNumberStart=2001, weekNumberStart=2, yearNumberEnd=2002, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=2, + yearNumberEnd=2002, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) @@ -4632,9 +5209,15 @@ def test_getOpponentLeagueMedianWins_happyPath(self): yearSettings = YearSettings(leagueMedianGames=True) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup3_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) week3_a = Week(weekNumber=3, matchups=[matchup3_a]) @@ -4645,9 +5228,15 @@ def test_getOpponentLeagueMedianWins_happyPath(self): yearSettings=yearSettings, ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup3_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) week3_b = Week(weekNumber=3, matchups=[matchup3_b]) @@ -4658,9 +5247,15 @@ def test_getOpponentLeagueMedianWins_happyPath(self): yearSettings=yearSettings, ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup3_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c]) week2_c = Week(weekNumber=2, matchups=[matchup2_c]) week3_c = Week(weekNumber=3, matchups=[matchup3_c]) @@ -4680,16 +5275,24 @@ def test_getOpponentLeagueMedianWins_happyPath(self): self.assertEqual(9, response[owners[0].id]) self.assertEqual(0, response[owners[1].id]) - def test_getOpponentLeagueMedianWins_yearsHaveLeagueMedianGamesOff_returnsZeroForEachTeam(self): + def test_getOpponentLeagueMedianWins_yearsHaveLeagueMedianGamesOff_returnsZeroForEachTeam( + self, + ): owners, teamsA = getNDefaultOwnersAndTeams(2) teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) yearSettings = YearSettings(leagueMedianGames=False) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup3_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) week3_a = Week(weekNumber=3, matchups=[matchup3_a]) @@ -4700,9 +5303,15 @@ def test_getOpponentLeagueMedianWins_yearsHaveLeagueMedianGamesOff_returnsZeroFo yearSettings=yearSettings, ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup3_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) week3_b = Week(weekNumber=3, matchups=[matchup3_b]) @@ -4713,9 +5322,15 @@ def test_getOpponentLeagueMedianWins_yearsHaveLeagueMedianGamesOff_returnsZeroFo yearSettings=yearSettings, ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup3_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c]) week2_c = Week(weekNumber=2, matchups=[matchup2_c]) week3_c = Week(weekNumber=3, matchups=[matchup3_c]) @@ -4741,9 +5356,15 @@ def test_getOpponentLeagueMedianWins_tieForLeagueMedian_happyPath(self): teamsC = getTeamsFromOwners(owners) yearSettings = YearSettings(leagueMedianGames=True) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup3_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1 + ) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) week3_a = Week(weekNumber=3, matchups=[matchup3_a]) @@ -4754,9 +5375,15 @@ def test_getOpponentLeagueMedianWins_tieForLeagueMedian_happyPath(self): yearSettings=yearSettings, ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=1) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup3_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=1 + ) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) week3_b = Week(weekNumber=3, matchups=[matchup3_b]) @@ -4767,9 +5394,15 @@ def test_getOpponentLeagueMedianWins_tieForLeagueMedian_happyPath(self): yearSettings=yearSettings, ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) - matchup2_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup3_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) + matchup2_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c]) week2_c = Week(weekNumber=2, matchups=[matchup2_c]) week3_c = Week(weekNumber=3, matchups=[matchup3_c]) @@ -4792,18 +5425,27 @@ def test_getOpponentLeagueMedianWins_tieForLeagueMedian_happyPath(self): def test_getOpponentLeagueMedianWins_noneIfNoGamesPlayed(self): owners, teamsA = getNDefaultOwnersAndTeams(3) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) yearSettings = YearSettings(leagueMedianGames=True) yearA = Year( - yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a], yearSettings=yearSettings + yearNumber=2000, + teams=teamsA, + weeks=[week1_a, week2_a], + yearSettings=yearSettings, ) league = League(name="TEST", owners=owners, years=[yearA]) - response = GameOutcomeAllTimeCalculator.getOpponentLeagueMedianWins(league, weekNumberEnd=1) + response = GameOutcomeAllTimeCalculator.getOpponentLeagueMedianWins( + league, weekNumberEnd=1 + ) self.assertIsInstance(response, dict) self.assertEqual(3, len(response.keys())) @@ -4816,7 +5458,9 @@ def test_getOpponentLeagueMedianWins_onlyPostSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -4836,7 +5480,9 @@ def test_getOpponentLeagueMedianWins_onlyPostSeasonIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -4856,7 +5502,9 @@ def test_getOpponentLeagueMedianWins_onlyPostSeasonIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -4893,7 +5541,9 @@ def test_getOpponentLeagueMedianWins_onlyRegularSeasonIsTrue(self): teamsC = getTeamsFromOwners(owners) yearSettings = YearSettings(leagueMedianGames=True) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -4918,7 +5568,9 @@ def test_getOpponentLeagueMedianWins_onlyRegularSeasonIsTrue(self): yearSettings=yearSettings, ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -4943,7 +5595,9 @@ def test_getOpponentLeagueMedianWins_onlyRegularSeasonIsTrue(self): yearSettings=yearSettings, ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -4984,7 +5638,9 @@ def test_getOpponentLeagueMedianWins_onlyChampionshipIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -5004,7 +5660,9 @@ def test_getOpponentLeagueMedianWins_onlyChampionshipIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -5024,7 +5682,9 @@ def test_getOpponentLeagueMedianWins_onlyChampionshipIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -5060,9 +5720,15 @@ def test_getOpponentLeagueMedianWins_yearNumberStartGivenWeekNumberStartGiven(se teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup3_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) week3_a = Week(weekNumber=3, matchups=[matchup3_a]) @@ -5075,9 +5741,15 @@ def test_getOpponentLeagueMedianWins_yearNumberStartGivenWeekNumberStartGiven(se yearSettings=yearSettings, ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup3_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) week3_b = Week(weekNumber=3, matchups=[matchup3_b]) @@ -5088,9 +5760,15 @@ def test_getOpponentLeagueMedianWins_yearNumberStartGivenWeekNumberStartGiven(se yearSettings=yearSettings, ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup3_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c]) week2_c = Week(weekNumber=2, matchups=[matchup2_c]) week3_c = Week(weekNumber=3, matchups=[matchup3_c]) @@ -5117,9 +5795,15 @@ def test_getOpponentLeagueMedianWins_yearNumberEndGivenWeekNumberEndGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup3_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) week3_a = Week(weekNumber=3, matchups=[matchup3_a]) @@ -5132,9 +5816,15 @@ def test_getOpponentLeagueMedianWins_yearNumberEndGivenWeekNumberEndGiven(self): yearSettings=yearSettings, ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup3_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) week3_b = Week(weekNumber=3, matchups=[matchup3_b]) @@ -5145,9 +5835,15 @@ def test_getOpponentLeagueMedianWins_yearNumberEndGivenWeekNumberEndGiven(self): yearSettings=yearSettings, ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup3_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c]) week2_c = Week(weekNumber=2, matchups=[matchup2_c]) week3_c = Week(weekNumber=3, matchups=[matchup3_c]) @@ -5178,9 +5874,15 @@ def test_getOpponentLeagueMedianWins_yearNumberStartGivenWeekNumberStartGivenAnd teamsD = getTeamsFromOwners(owners) yearSettings = YearSettings(leagueMedianGames=True) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup3_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) week3_a = Week(weekNumber=3, matchups=[matchup3_a]) @@ -5191,9 +5893,15 @@ def test_getOpponentLeagueMedianWins_yearNumberStartGivenWeekNumberStartGivenAnd yearSettings=yearSettings, ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup3_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) week3_b = Week(weekNumber=3, matchups=[matchup3_b]) @@ -5204,9 +5912,15 @@ def test_getOpponentLeagueMedianWins_yearNumberStartGivenWeekNumberStartGivenAnd yearSettings=yearSettings, ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup3_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c]) week2_c = Week(weekNumber=2, matchups=[matchup2_c]) week3_c = Week(weekNumber=3, matchups=[matchup3_c]) @@ -5217,9 +5931,15 @@ def test_getOpponentLeagueMedianWins_yearNumberStartGivenWeekNumberStartGivenAnd yearSettings=yearSettings, ) - matchup1_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) - matchup2_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) - matchup3_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) + matchup1_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) week1_d = Week(weekNumber=1, matchups=[matchup1_d]) week2_d = Week(weekNumber=2, matchups=[matchup2_d]) week3_d = Week(weekNumber=3, matchups=[matchup3_d]) @@ -5228,7 +5948,11 @@ def test_getOpponentLeagueMedianWins_yearNumberStartGivenWeekNumberStartGivenAnd league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC, yearD]) response = GameOutcomeAllTimeCalculator.getOpponentLeagueMedianWins( - league, yearNumberStart=2001, weekNumberStart=2, yearNumberEnd=2002, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=2, + yearNumberEnd=2002, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) diff --git a/test/test_calculator/test_all_time_calculator/test_PlusMinusAllTimeCalculator.py b/test/test_calculator/test_all_time_calculator/test_PlusMinusAllTimeCalculator.py index 5cb74e3c..d1b037bc 100644 --- a/test/test_calculator/test_all_time_calculator/test_PlusMinusAllTimeCalculator.py +++ b/test/test_calculator/test_all_time_calculator/test_PlusMinusAllTimeCalculator.py @@ -1,5 +1,4 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams, getTeamsFromOwners from leeger.calculator.all_time_calculator.PlusMinusAllTimeCalculator import ( PlusMinusAllTimeCalculator, @@ -10,6 +9,7 @@ from leeger.model.league.Week import Week from leeger.model.league.Year import Year from leeger.util.Deci import Deci +from test.helper.prototypes import getNDefaultOwnersAndTeams, getTeamsFromOwners class TestPlusMinusAllTimeCalculator(unittest.TestCase): @@ -261,7 +261,9 @@ def test_getPlusMinus_onlyRegularSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = PlusMinusAllTimeCalculator.getPlusMinus(league, onlyRegularSeason=True) + response = PlusMinusAllTimeCalculator.getPlusMinus( + league, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -339,7 +341,9 @@ def test_getPlusMinus_onlyChampionshipIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = PlusMinusAllTimeCalculator.getPlusMinus(league, onlyChampionship=True) + response = PlusMinusAllTimeCalculator.getPlusMinus( + league, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -610,7 +614,11 @@ def test_getPlusMinus_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGi league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) response = PlusMinusAllTimeCalculator.getPlusMinus( - league, yearNumberStart=2001, weekNumberStart=1, yearNumberEnd=2001, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=1, + yearNumberEnd=2001, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) diff --git a/test/test_calculator/test_all_time_calculator/test_PointsScoredAllTimeCalculator.py b/test/test_calculator/test_all_time_calculator/test_PointsScoredAllTimeCalculator.py index dc8c2712..499d39bd 100644 --- a/test/test_calculator/test_all_time_calculator/test_PointsScoredAllTimeCalculator.py +++ b/test/test_calculator/test_all_time_calculator/test_PointsScoredAllTimeCalculator.py @@ -1,5 +1,4 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams, getTeamsFromOwners from leeger.calculator.all_time_calculator.PointsScoredAllTimeCalculator import ( PointsScoredAllTimeCalculator, @@ -10,6 +9,7 @@ from leeger.model.league.Week import Week from leeger.model.league.Year import Year from leeger.util.Deci import Deci +from test.helper.prototypes import getNDefaultOwnersAndTeams, getTeamsFromOwners class TestPointsScoredAllTimeCalculator(unittest.TestCase): @@ -107,7 +107,9 @@ def test_getPointsScored_noneIfNoGamesPlayed(self): league = League(name="TEST", owners=owners, years=[yearA]) - response = PointsScoredAllTimeCalculator.getPointsScored(league, weekNumberEnd=1) + response = PointsScoredAllTimeCalculator.getPointsScored( + league, weekNumberEnd=1 + ) self.assertIsInstance(response, dict) self.assertEqual(3, len(response.keys())) @@ -260,7 +262,9 @@ def test_getPointsScored_onlyRegularSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = PointsScoredAllTimeCalculator.getPointsScored(league, onlyRegularSeason=True) + response = PointsScoredAllTimeCalculator.getPointsScored( + league, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -338,7 +342,9 @@ def test_getPointsScored_onlyChampionshipIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = PointsScoredAllTimeCalculator.getPointsScored(league, onlyChampionship=True) + response = PointsScoredAllTimeCalculator.getPointsScored( + league, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -609,7 +615,11 @@ def test_getPointsScored_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEn league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) response = PointsScoredAllTimeCalculator.getPointsScored( - league, yearNumberStart=2001, weekNumberStart=1, yearNumberEnd=2001, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=1, + yearNumberEnd=2001, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) @@ -715,7 +725,9 @@ def test_getPointsScoredPerGame_noneIfNoGamesPlayed(self): league = League(name="TEST", owners=owners, years=[yearA]) - response = PointsScoredAllTimeCalculator.getPointsScoredPerGame(league, weekNumberEnd=1) + response = PointsScoredAllTimeCalculator.getPointsScoredPerGame( + league, weekNumberEnd=1 + ) self.assertIsInstance(response, dict) self.assertEqual(3, len(response.keys())) @@ -1221,7 +1233,11 @@ def test_getPointsScoredPerGame_yearNumberStartGivenWeekNumberStartGivenAndYearN league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) response = PointsScoredAllTimeCalculator.getPointsScoredPerGame( - league, yearNumberStart=2001, weekNumberStart=1, yearNumberEnd=2001, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=1, + yearNumberEnd=2001, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) @@ -1327,7 +1343,9 @@ def test_getOpponentPointsScored_noneIfNoGamesPlayed(self): league = League(name="TEST", owners=owners, years=[yearA]) - response = PointsScoredAllTimeCalculator.getOpponentPointsScored(league, weekNumberEnd=1) + response = PointsScoredAllTimeCalculator.getOpponentPointsScored( + league, weekNumberEnd=1 + ) self.assertIsInstance(response, dict) self.assertEqual(3, len(response.keys())) @@ -1833,7 +1851,11 @@ def test_getOpponentPointsScored_yearNumberStartGivenWeekNumberStartGivenAndYear league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) response = PointsScoredAllTimeCalculator.getOpponentPointsScored( - league, yearNumberStart=2001, weekNumberStart=1, yearNumberEnd=2001, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=1, + yearNumberEnd=2001, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) @@ -2187,7 +2209,9 @@ def test_getOpponentPointsScoredPerGame_onlyChampionshipIsTrue(self): self.assertEqual(Deci("5.5"), response[owners[4].id]) self.assertEqual(Deci("4.4"), response[owners[5].id]) - def test_getOpponentPointsScoredPerGame_yearNumberStartGivenWeekNumberStartGiven(self): + def test_getOpponentPointsScoredPerGame_yearNumberStartGivenWeekNumberStartGiven( + self, + ): owners, teamsA = getNDefaultOwnersAndTeams(6) teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) @@ -2447,7 +2471,11 @@ def test_getOpponentPointsScoredPerGame_yearNumberStartGivenWeekNumberStartGiven league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) response = PointsScoredAllTimeCalculator.getOpponentPointsScoredPerGame( - league, yearNumberStart=2001, weekNumberStart=1, yearNumberEnd=2001, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=1, + yearNumberEnd=2001, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) diff --git a/test/test_calculator/test_all_time_calculator/test_SSLAllTimeCalculator.py b/test/test_calculator/test_all_time_calculator/test_SSLAllTimeCalculator.py index 0a7aa112..d4ce6ce1 100644 --- a/test/test_calculator/test_all_time_calculator/test_SSLAllTimeCalculator.py +++ b/test/test_calculator/test_all_time_calculator/test_SSLAllTimeCalculator.py @@ -1,13 +1,15 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams, getTeamsFromOwners -from leeger.calculator.all_time_calculator.SSLAllTimeCalculator import SSLAllTimeCalculator +from leeger.calculator.all_time_calculator.SSLAllTimeCalculator import ( + SSLAllTimeCalculator, +) from leeger.enum.MatchupType import MatchupType from leeger.model.league.League import League from leeger.model.league.Matchup import Matchup from leeger.model.league.Week import Week from leeger.model.league.Year import Year from leeger.util.Deci import Deci +from test.helper.prototypes import getNDefaultOwnersAndTeams, getTeamsFromOwners class TestSSLAllTimeCalculator(unittest.TestCase): @@ -15,9 +17,13 @@ def test_getAdjustedTeamScore_happyPath(self): owners, teamsA = getNDefaultOwnersAndTeams(2) teamsB = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) @@ -43,9 +49,13 @@ def test_getAdjustedTeamScore_happyPath(self): def test_getAdjustedTeamScore_noneIfNoGamesPlayed(self): owners, teamsA = getNDefaultOwnersAndTeams(3) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) - matchup2_a = Matchup(teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=2) + matchup2_a = Matchup( + teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=2 + ) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) @@ -62,7 +72,9 @@ def test_getAdjustedTeamScore_onlyPostSeasonIsTrue(self): owners, teamsA = getNDefaultOwnersAndTeams(2) teamsB = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) matchup2_a = Matchup( teamAId=teamsA[0].id, @@ -94,7 +106,9 @@ def test_getAdjustedTeamScore_onlyPostSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB]) - response = SSLAllTimeCalculator.getAdjustedTeamScore(league, onlyPostSeason=True) + response = SSLAllTimeCalculator.getAdjustedTeamScore( + league, onlyPostSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -105,9 +119,13 @@ def test_getAdjustedTeamScore_onlyRegularSeasonIsTrue(self): owners, teamsA = getNDefaultOwnersAndTeams(2) teamsB = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) matchup3_a = Matchup( teamAId=teamsA[0].id, @@ -127,7 +145,9 @@ def test_getAdjustedTeamScore_onlyRegularSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB]) - response = SSLAllTimeCalculator.getAdjustedTeamScore(league, onlyRegularSeason=True) + response = SSLAllTimeCalculator.getAdjustedTeamScore( + league, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -138,9 +158,13 @@ def test_getAdjustedTeamScore_onlyChampionshipIsTrue(self): owners, teamsA = getNDefaultOwnersAndTeams(2) teamsB = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) matchup3_a = Matchup( teamAId=teamsA[0].id, @@ -164,7 +188,9 @@ def test_getAdjustedTeamScore_onlyChampionshipIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB]) - response = SSLAllTimeCalculator.getAdjustedTeamScore(league, onlyChampionship=True) + response = SSLAllTimeCalculator.getAdjustedTeamScore( + league, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -186,9 +212,13 @@ def test_getAdjustedTeamScore_yearNumberStartGivenWeekNumberStartGiven(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a]) yearA = Year(yearNumber=1999, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) matchup3_b = Matchup( teamAId=teamsB[0].id, @@ -236,9 +266,13 @@ def test_getAdjustedTeamScore_yearNumberEndGivenWeekNumberEndGiven(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a]) yearA = Year(yearNumber=1999, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) matchup3_b = Matchup( teamAId=teamsB[0].id, @@ -288,9 +322,13 @@ def test_getAdjustedTeamScore_yearNumberStartGivenWeekNumberStartGivenAndYearNum week1_a = Week(weekNumber=1, matchups=[matchup1_a]) yearA = Year(yearNumber=1999, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) matchup3_b = Matchup( teamAId=teamsB[0].id, @@ -323,7 +361,11 @@ def test_getAdjustedTeamScore_yearNumberStartGivenWeekNumberStartGivenAndYearNum league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) response = SSLAllTimeCalculator.getAdjustedTeamScore( - league, yearNumberStart=2000, weekNumberStart=2, yearNumberEnd=2001, weekNumberEnd=1 + league, + yearNumberStart=2000, + weekNumberStart=2, + yearNumberEnd=2001, + weekNumberEnd=1, ) self.assertIsInstance(response, dict) @@ -335,9 +377,13 @@ def test_getAdjustedTeamSuccess_happyPath(self): owners, teamsA = getNDefaultOwnersAndTeams(2) teamsB = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) @@ -363,9 +409,13 @@ def test_getAdjustedTeamSuccess_happyPath(self): def test_getAdjustedTeamSuccess_noneIfNoGamesPlayed(self): owners, teamsA = getNDefaultOwnersAndTeams(3) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) - matchup2_a = Matchup(teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=2) + matchup2_a = Matchup( + teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=2 + ) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) @@ -382,7 +432,9 @@ def test_getAdjustedTeamSuccess_onlyPostSeasonIsTrue(self): owners, teamsA = getNDefaultOwnersAndTeams(2) teamsB = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) matchup2_a = Matchup( teamAId=teamsA[0].id, @@ -414,7 +466,9 @@ def test_getAdjustedTeamSuccess_onlyPostSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB]) - response = SSLAllTimeCalculator.getAdjustedTeamSuccess(league, onlyPostSeason=True) + response = SSLAllTimeCalculator.getAdjustedTeamSuccess( + league, onlyPostSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -425,9 +479,13 @@ def test_getAdjustedTeamSuccess_onlyRegularSeasonIsTrue(self): owners, teamsA = getNDefaultOwnersAndTeams(2) teamsB = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) matchup3_a = Matchup( teamAId=teamsA[0].id, @@ -447,7 +505,9 @@ def test_getAdjustedTeamSuccess_onlyRegularSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB]) - response = SSLAllTimeCalculator.getAdjustedTeamSuccess(league, onlyRegularSeason=True) + response = SSLAllTimeCalculator.getAdjustedTeamSuccess( + league, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -458,9 +518,13 @@ def test_getAdjustedTeamSuccess_onlyChampionshipIsTrue(self): owners, teamsA = getNDefaultOwnersAndTeams(2) teamsB = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) matchup3_a = Matchup( teamAId=teamsA[0].id, @@ -484,7 +548,9 @@ def test_getAdjustedTeamSuccess_onlyChampionshipIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB]) - response = SSLAllTimeCalculator.getAdjustedTeamSuccess(league, onlyChampionship=True) + response = SSLAllTimeCalculator.getAdjustedTeamSuccess( + league, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -506,9 +572,13 @@ def test_getAdjustedTeamSuccess_yearNumberStartGivenWeekNumberStartGiven(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a]) yearA = Year(yearNumber=1999, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) matchup3_b = Matchup( teamAId=teamsB[0].id, @@ -556,9 +626,13 @@ def test_getAdjustedTeamSuccess_yearNumberEndGivenWeekNumberEndGiven(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a]) yearA = Year(yearNumber=1999, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) matchup3_b = Matchup( teamAId=teamsB[0].id, @@ -608,9 +682,13 @@ def test_getAdjustedTeamSuccess_yearNumberStartGivenWeekNumberStartGivenAndYearN week1_a = Week(weekNumber=1, matchups=[matchup1_a]) yearA = Year(yearNumber=1999, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) matchup3_b = Matchup( teamAId=teamsB[0].id, @@ -643,7 +721,11 @@ def test_getAdjustedTeamSuccess_yearNumberStartGivenWeekNumberStartGivenAndYearN league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) response = SSLAllTimeCalculator.getAdjustedTeamSuccess( - league, yearNumberStart=2000, weekNumberStart=2, yearNumberEnd=2001, weekNumberEnd=1 + league, + yearNumberStart=2000, + weekNumberStart=2, + yearNumberEnd=2001, + weekNumberEnd=1, ) self.assertIsInstance(response, dict) @@ -655,9 +737,13 @@ def test_getAdjustedTeamLuck_happyPath(self): owners, teamsA = getNDefaultOwnersAndTeams(2) teamsB = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) @@ -683,9 +769,13 @@ def test_getAdjustedTeamLuck_happyPath(self): def test_getAdjustedTeamLuck_noneIfNoGamesPlayed(self): owners, teamsA = getNDefaultOwnersAndTeams(3) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) - matchup2_a = Matchup(teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=2) + matchup2_a = Matchup( + teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=2 + ) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) @@ -702,7 +792,9 @@ def test_getAdjustedTeamLuck_onlyPostSeasonIsTrue(self): owners, teamsA = getNDefaultOwnersAndTeams(2) teamsB = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) matchup2_a = Matchup( teamAId=teamsA[0].id, @@ -745,9 +837,13 @@ def test_getAdjustedTeamLuck_onlyRegularSeasonIsTrue(self): owners, teamsA = getNDefaultOwnersAndTeams(2) teamsB = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) matchup3_a = Matchup( teamAId=teamsA[0].id, @@ -767,7 +863,9 @@ def test_getAdjustedTeamLuck_onlyRegularSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB]) - response = SSLAllTimeCalculator.getAdjustedTeamLuck(league, onlyRegularSeason=True) + response = SSLAllTimeCalculator.getAdjustedTeamLuck( + league, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -778,9 +876,13 @@ def test_getAdjustedTeamLuck_onlyChampionshipIsTrue(self): owners, teamsA = getNDefaultOwnersAndTeams(2) teamsB = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) matchup3_a = Matchup( teamAId=teamsA[0].id, @@ -804,7 +906,9 @@ def test_getAdjustedTeamLuck_onlyChampionshipIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB]) - response = SSLAllTimeCalculator.getAdjustedTeamLuck(league, onlyChampionship=True) + response = SSLAllTimeCalculator.getAdjustedTeamLuck( + league, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -826,9 +930,13 @@ def test_getAdjustedTeamLuck_yearNumberStartGivenWeekNumberStartGiven(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a]) yearA = Year(yearNumber=1999, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) matchup3_b = Matchup( teamAId=teamsB[0].id, @@ -876,9 +984,13 @@ def test_getAdjustedTeamLuck_yearNumberEndGivenWeekNumberEndGiven(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a]) yearA = Year(yearNumber=1999, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) matchup3_b = Matchup( teamAId=teamsB[0].id, @@ -928,9 +1040,13 @@ def test_getAdjustedTeamLuck_yearNumberStartGivenWeekNumberStartGivenAndYearNumb week1_a = Week(weekNumber=1, matchups=[matchup1_a]) yearA = Year(yearNumber=1999, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) matchup3_b = Matchup( teamAId=teamsB[0].id, @@ -963,7 +1079,11 @@ def test_getAdjustedTeamLuck_yearNumberStartGivenWeekNumberStartGivenAndYearNumb league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) response = SSLAllTimeCalculator.getAdjustedTeamLuck( - league, yearNumberStart=2000, weekNumberStart=2, yearNumberEnd=2001, weekNumberEnd=1 + league, + yearNumberStart=2000, + weekNumberStart=2, + yearNumberEnd=2001, + weekNumberEnd=1, ) self.assertIsInstance(response, dict) diff --git a/test/test_calculator/test_all_time_calculator/test_ScoringShareAllTimeCalculator.py b/test/test_calculator/test_all_time_calculator/test_ScoringShareAllTimeCalculator.py index 8d67cd0a..d02d7e1a 100644 --- a/test/test_calculator/test_all_time_calculator/test_ScoringShareAllTimeCalculator.py +++ b/test/test_calculator/test_all_time_calculator/test_ScoringShareAllTimeCalculator.py @@ -1,6 +1,5 @@ import math import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams, getTeamsFromOwners from leeger.calculator.all_time_calculator.ScoringShareAllTimeCalculator import ( ScoringShareAllTimeCalculator, @@ -11,6 +10,7 @@ from leeger.model.league.Week import Week from leeger.model.league.Year import Year from leeger.util.Deci import Deci +from test.helper.prototypes import getNDefaultOwnersAndTeams, getTeamsFromOwners class TestScoringShareAllTimeCalculator(unittest.TestCase): @@ -109,7 +109,9 @@ def test_getScoringShare_noneIfNoGamesPlayed(self): league = League(name="TEST", owners=owners, years=[yearA]) - response = ScoringShareAllTimeCalculator.getScoringShare(league, weekNumberEnd=1) + response = ScoringShareAllTimeCalculator.getScoringShare( + league, weekNumberEnd=1 + ) self.assertIsInstance(response, dict) self.assertEqual(3, len(response.keys())) @@ -130,20 +132,36 @@ def test_getScoringShare_noPointsScoredInYears(self): teamBScore=0, matchupType=MatchupType.IGNORE, ) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=0, teamBScore=0) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=0, teamBScore=0 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=0, teamBScore=0) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=0, teamBScore=0) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=0, teamBScore=0 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=0, teamBScore=0 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=0, teamBScore=0) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=0, teamBScore=0) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=0, teamBScore=0) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=0, teamBScore=0 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=0, teamBScore=0 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=0, teamBScore=0 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -227,7 +245,9 @@ def test_getScoringShare_onlyPostSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = ScoringShareAllTimeCalculator.getScoringShare(league, onlyPostSeason=True) + response = ScoringShareAllTimeCalculator.getScoringShare( + league, onlyPostSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -306,7 +326,9 @@ def test_getScoringShare_onlyRegularSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = ScoringShareAllTimeCalculator.getScoringShare(league, onlyRegularSeason=True) + response = ScoringShareAllTimeCalculator.getScoringShare( + league, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -386,7 +408,9 @@ def test_getScoringShare_onlyChampionshipIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = ScoringShareAllTimeCalculator.getScoringShare(league, onlyChampionship=True) + response = ScoringShareAllTimeCalculator.getScoringShare( + league, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -661,7 +685,11 @@ def test_getScoringShare_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEn league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) response = ScoringShareAllTimeCalculator.getScoringShare( - league, yearNumberStart=2001, weekNumberStart=1, yearNumberEnd=2001, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=1, + yearNumberEnd=2001, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) @@ -770,7 +798,9 @@ def test_getOpponentScoringShare_noneIfNoGamesPlayed(self): league = League(name="TEST", owners=owners, years=[yearA]) - response = ScoringShareAllTimeCalculator.getOpponentScoringShare(league, weekNumberEnd=1) + response = ScoringShareAllTimeCalculator.getOpponentScoringShare( + league, weekNumberEnd=1 + ) self.assertIsInstance(response, dict) self.assertEqual(3, len(response.keys())) @@ -791,19 +821,33 @@ def test_getOpponentScoringShare_noPointsScoredInYears(self): teamBScore=0, matchupType=MatchupType.IGNORE, ) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=0, teamBScore=0) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=0, teamBScore=0 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=0, teamBScore=0) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=0, teamBScore=0) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=0, teamBScore=0 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=0, teamBScore=0 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=0, teamBScore=0) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=0, teamBScore=0) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=0, teamBScore=0 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=0, teamBScore=0 + ) matchup3_c = Matchup( teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=0, teamBScore=00 ) @@ -1330,7 +1374,11 @@ def test_getOpponentScoringShare_yearNumberStartGivenWeekNumberStartGivenAndYear league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) response = ScoringShareAllTimeCalculator.getOpponentScoringShare( - league, yearNumberStart=2001, weekNumberStart=1, yearNumberEnd=2001, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=1, + yearNumberEnd=2001, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) @@ -1356,14 +1404,24 @@ def test_getMaxScoringShare_happyPath(self): teamBScore=100, matchupType=MatchupType.IGNORE, ) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=0, teamBScore=0) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=0, teamBScore=0 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=4, teamBScore=3) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=0) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=4, teamBScore=3 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=0 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) @@ -1417,14 +1475,24 @@ def test_getMaxScoringShare_noneIfNoGamesPlayed(self): teamBScore=100, matchupType=MatchupType.IGNORE, ) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=4, teamBScore=3) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=3, teamBScore=0) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=4, teamBScore=3 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=3, teamBScore=0 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=4, teamBScore=3) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=0) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=4, teamBScore=3 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=0 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) @@ -1473,21 +1541,39 @@ def test_getMaxScoringShare_noPointsScoredInYears(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=0, teamBScore=0) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=0, teamBScore=0) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=0, teamBScore=0 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=0, teamBScore=0 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=0, teamBScore=0) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=0, teamBScore=0) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=0, teamBScore=0 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=0, teamBScore=0 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=0, teamBScore=0) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=0, teamBScore=0) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=0, teamBScore=0) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=0, teamBScore=0 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=0, teamBScore=0 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=0, teamBScore=0 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -1515,11 +1601,15 @@ def test_getMaxScoringShare_onlyPostSeasonIsTrue(self): matchup2_a = Matchup( teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=100, teamBScore=0 ) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=0, teamBScore=0) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=0, teamBScore=0 + ) matchup2_b = Matchup( teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=0, teamBScore=100 ) @@ -1558,7 +1648,9 @@ def test_getMaxScoringShare_onlyPostSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = ScoringShareAllTimeCalculator.getMaxScoringShare(league, onlyPostSeason=True) + response = ScoringShareAllTimeCalculator.getMaxScoringShare( + league, onlyPostSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -1574,9 +1666,15 @@ def test_getMaxScoringShare_onlyRegularSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=1, teamBScore=1) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=1, teamBScore=1) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=1, teamBScore=1 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=1, teamBScore=1 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) @@ -1634,7 +1732,9 @@ def test_getMaxScoringShare_onlyRegularSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = ScoringShareAllTimeCalculator.getMaxScoringShare(league, onlyRegularSeason=True) + response = ScoringShareAllTimeCalculator.getMaxScoringShare( + league, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -1656,11 +1756,15 @@ def test_getMaxScoringShare_onlyChampionshipIsTrue(self): matchup2_a = Matchup( teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=100, teamBScore=0 ) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=0, teamBScore=0) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=0, teamBScore=0 + ) matchup2_b = Matchup( teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=0, teamBScore=100 ) @@ -1698,7 +1802,9 @@ def test_getMaxScoringShare_onlyChampionshipIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = ScoringShareAllTimeCalculator.getMaxScoringShare(league, onlyChampionship=True) + response = ScoringShareAllTimeCalculator.getMaxScoringShare( + league, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -1720,19 +1826,31 @@ def test_getMaxScoringShare_yearNumberStartGivenWeekNumberStartGiven(self): matchup2_a = Matchup( teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=100, teamBScore=0 ) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=0, teamBScore=0) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=0, teamBScore=0) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=0, teamBScore=0 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=0, teamBScore=0 + ) matchup3_b = Matchup( teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=100, teamBScore=100 ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=4, teamBScore=3) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=0) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=4, teamBScore=3 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=0 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) @@ -1781,15 +1899,27 @@ def test_getMaxScoringShare_yearNumberEndGivenWeekNumberEndGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=4, teamBScore=3) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=0) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=4, teamBScore=3 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=0 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=0, teamBScore=0) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=0, teamBScore=3) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=3) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=0, teamBScore=0 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=0, teamBScore=3 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=3 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) matchup4_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=100, teamBScore=0 @@ -1797,12 +1927,18 @@ def test_getMaxScoringShare_yearNumberEndGivenWeekNumberEndGiven(self): matchup5_b = Matchup( teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=100, teamBScore=0 ) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=0, teamBScore=0) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=0, teamBScore=0) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=0, teamBScore=0 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=0, teamBScore=0 + ) matchup3_c = Matchup( teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=100, teamBScore=100 ) @@ -1837,7 +1973,9 @@ def test_getMaxScoringShare_yearNumberStartGivenWeekNumberStartGivenAndYearNumbe matchup2_a = Matchup( teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=100, teamBScore=0 ) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) @@ -1847,20 +1985,38 @@ def test_getMaxScoringShare_yearNumberStartGivenWeekNumberStartGivenAndYearNumbe matchup2_b = Matchup( teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=0, teamBScore=100 ) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=4, teamBScore=3) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=0) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=4, teamBScore=3 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=0 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=0, teamBScore=0) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=0, teamBScore=3) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=3) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=0, teamBScore=0 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=0, teamBScore=3 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=3 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) - matchup4_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=0, teamBScore=0) - matchup5_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=0, teamBScore=0) + matchup4_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=0, teamBScore=0 + ) + matchup5_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=0, teamBScore=0 + ) matchup6_c = Matchup( teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=100, teamBScore=100 ) @@ -1870,7 +2026,11 @@ def test_getMaxScoringShare_yearNumberStartGivenWeekNumberStartGivenAndYearNumbe league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) response = ScoringShareAllTimeCalculator.getMaxScoringShare( - league, yearNumberStart=2001, weekNumberStart=2, yearNumberEnd=2002, weekNumberEnd=1 + league, + yearNumberStart=2001, + weekNumberStart=2, + yearNumberEnd=2002, + weekNumberEnd=1, ) self.assertIsInstance(response, dict) @@ -1887,21 +2047,39 @@ def test_getMinScoringShare_happyPath(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=0, teamBScore=1) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=0, teamBScore=1) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=1) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=0, teamBScore=1 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=0, teamBScore=1 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=1 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=0) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=1, teamBScore=0) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=1, teamBScore=0) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=0 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=1, teamBScore=0 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=1, teamBScore=0 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=5, teamBScore=6) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=5, teamBScore=6 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -1930,14 +2108,24 @@ def test_getMinScoringShare_noneIfNoGamesPlayed(self): teamBScore=100, matchupType=MatchupType.IGNORE, ) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=4, teamBScore=3) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=3, teamBScore=0) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=4, teamBScore=3 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=3, teamBScore=0 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=4, teamBScore=3) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=0) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=4, teamBScore=3 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=0 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) @@ -1986,21 +2174,39 @@ def test_getMinScoringShare_noPointsScoredInYears(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=0, teamBScore=0) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=0, teamBScore=0) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=0, teamBScore=0 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=0, teamBScore=0 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=0, teamBScore=0) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=0, teamBScore=0) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=0, teamBScore=0 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=0, teamBScore=0 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=0, teamBScore=0) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=0, teamBScore=0) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=0, teamBScore=0) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=0, teamBScore=0 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=0, teamBScore=0 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=0, teamBScore=0 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -2028,11 +2234,15 @@ def test_getMinScoringShare_onlyPostSeasonIsTrue(self): matchup2_a = Matchup( teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=100, teamBScore=0 ) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=0, teamBScore=0) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=0, teamBScore=0 + ) matchup2_b = Matchup( teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=0, teamBScore=100 ) @@ -2071,7 +2281,9 @@ def test_getMinScoringShare_onlyPostSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = ScoringShareAllTimeCalculator.getMinScoringShare(league, onlyPostSeason=True) + response = ScoringShareAllTimeCalculator.getMinScoringShare( + league, onlyPostSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -2087,9 +2299,15 @@ def test_getMinScoringShare_onlyRegularSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=1, teamBScore=1) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=1, teamBScore=1) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=1, teamBScore=1 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=1, teamBScore=1 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) @@ -2147,7 +2365,9 @@ def test_getMinScoringShare_onlyRegularSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = ScoringShareAllTimeCalculator.getMinScoringShare(league, onlyRegularSeason=True) + response = ScoringShareAllTimeCalculator.getMinScoringShare( + league, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -2169,11 +2389,15 @@ def test_getMinScoringShare_onlyChampionshipIsTrue(self): matchup2_a = Matchup( teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=100, teamBScore=0 ) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=0, teamBScore=0) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=0, teamBScore=0 + ) matchup2_b = Matchup( teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=0, teamBScore=100 ) @@ -2211,7 +2435,9 @@ def test_getMinScoringShare_onlyChampionshipIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = ScoringShareAllTimeCalculator.getMinScoringShare(league, onlyChampionship=True) + response = ScoringShareAllTimeCalculator.getMinScoringShare( + league, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -2233,25 +2459,43 @@ def test_getMinScoringShare_yearNumberStartGivenWeekNumberStartGiven(self): matchup2_a = Matchup( teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=100, teamBScore=0 ) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=0, teamBScore=0) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=0, teamBScore=0) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=0, teamBScore=0 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=0, teamBScore=0 + ) matchup3_b = Matchup( teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=100, teamBScore=100 ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=2, teamBScore=2) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=1, teamBScore=1) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=2, teamBScore=2 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=1, teamBScore=1 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=2, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=1, teamBScore=1) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=2, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=2, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=1, teamBScore=1 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=2, teamBScore=2 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -2275,15 +2519,27 @@ def test_getMinScoringShare_yearNumberEndGivenWeekNumberEndGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=2, teamBScore=2) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=2, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=1 + ) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=2, teamBScore=2 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=2, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=1, teamBScore=1) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=2, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=1, teamBScore=1 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=2, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) matchup4_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=100, teamBScore=0 @@ -2291,12 +2547,18 @@ def test_getMinScoringShare_yearNumberEndGivenWeekNumberEndGiven(self): matchup5_b = Matchup( teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=100, teamBScore=0 ) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=0, teamBScore=0) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=0, teamBScore=0) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=0, teamBScore=0 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=0, teamBScore=0 + ) matchup3_c = Matchup( teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=100, teamBScore=100 ) @@ -2331,7 +2593,9 @@ def test_getMinScoringShare_yearNumberStartGivenWeekNumberStartGivenAndYearNumbe matchup2_a = Matchup( teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=100, teamBScore=0 ) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=0, teamBScore=0 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) @@ -2341,20 +2605,38 @@ def test_getMinScoringShare_yearNumberStartGivenWeekNumberStartGivenAndYearNumbe matchup2_b = Matchup( teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=0, teamBScore=100 ) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=0, teamBScore=0 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=1) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=2, teamBScore=2) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=2, teamBScore=2) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=1 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=2, teamBScore=2 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=2, teamBScore=2 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=2, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=1, teamBScore=1) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=2, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=2, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=1, teamBScore=1 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=2, teamBScore=2 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) - matchup4_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=0, teamBScore=0) - matchup5_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=0, teamBScore=0) + matchup4_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=0, teamBScore=0 + ) + matchup5_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=0, teamBScore=0 + ) matchup6_c = Matchup( teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=100, teamBScore=100 ) @@ -2364,7 +2646,11 @@ def test_getMinScoringShare_yearNumberStartGivenWeekNumberStartGivenAndYearNumbe league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) response = ScoringShareAllTimeCalculator.getMinScoringShare( - league, yearNumberStart=2001, weekNumberStart=2, yearNumberEnd=2002, weekNumberEnd=1 + league, + yearNumberStart=2001, + weekNumberStart=2, + yearNumberEnd=2002, + weekNumberEnd=1, ) self.assertIsInstance(response, dict) diff --git a/test/test_calculator/test_all_time_calculator/test_ScoringStandardDeviationAllTimeCalculator.py b/test/test_calculator/test_all_time_calculator/test_ScoringStandardDeviationAllTimeCalculator.py index 7c666ba2..203b18b5 100644 --- a/test/test_calculator/test_all_time_calculator/test_ScoringStandardDeviationAllTimeCalculator.py +++ b/test/test_calculator/test_all_time_calculator/test_ScoringStandardDeviationAllTimeCalculator.py @@ -1,6 +1,5 @@ import math import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams, getTeamsFromOwners from leeger.calculator.all_time_calculator.ScoringStandardDeviationAllTimeCalculator import ( ScoringStandardDeviationAllTimeCalculator, @@ -11,6 +10,7 @@ from leeger.model.league.Week import Week from leeger.model.league.Year import Year from leeger.util.Deci import Deci +from test.helper.prototypes import getNDefaultOwnersAndTeams, getTeamsFromOwners class TestScoringStandardDeviationAllTimeCalculator(unittest.TestCase): @@ -81,16 +81,28 @@ def test_getScoringStandardDeviation_happyPath(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = ScoringStandardDeviationAllTimeCalculator.getScoringStandardDeviation(league) + response = ( + ScoringStandardDeviationAllTimeCalculator.getScoringStandardDeviation( + league + ) + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) self.assertEqual(Deci("0.05"), response[owners[0].id]) self.assertEqual(Deci("0.05"), response[owners[1].id]) - self.assertEqual(Deci("0.08164965809277260327324280249"), response[owners[2].id]) - self.assertEqual(Deci("0.08164965809277260327324280249"), response[owners[3].id]) - self.assertEqual(Deci("0.08164965809277260327324280249"), response[owners[4].id]) - self.assertEqual(Deci("0.08164965809277260327324280249"), response[owners[5].id]) + self.assertEqual( + Deci("0.08164965809277260327324280249"), response[owners[2].id] + ) + self.assertEqual( + Deci("0.08164965809277260327324280249"), response[owners[3].id] + ) + self.assertEqual( + Deci("0.08164965809277260327324280249"), response[owners[4].id] + ) + self.assertEqual( + Deci("0.08164965809277260327324280249"), response[owners[5].id] + ) def test_getScoringStandardDeviation_multiWeekMatchups(self): owners, teamsA = getNDefaultOwnersAndTeams(6) @@ -143,16 +155,28 @@ def test_getScoringStandardDeviation_multiWeekMatchups(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = ScoringStandardDeviationAllTimeCalculator.getScoringStandardDeviation(league) + response = ( + ScoringStandardDeviationAllTimeCalculator.getScoringStandardDeviation( + league + ) + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) self.assertEqual(Deci("0.5"), response[owners[0].id]) self.assertTrue(math.isclose(Deci("1"), response[owners[1].id])) - self.assertEqual(Deci("0.08164965809277260327324280249"), response[owners[2].id]) - self.assertEqual(Deci("0.08164965809277260327324280249"), response[owners[3].id]) - self.assertEqual(Deci("0.08164965809277260327324280249"), response[owners[4].id]) - self.assertEqual(Deci("0.08164965809277260327324280249"), response[owners[5].id]) + self.assertEqual( + Deci("0.08164965809277260327324280249"), response[owners[2].id] + ) + self.assertEqual( + Deci("0.08164965809277260327324280249"), response[owners[3].id] + ) + self.assertEqual( + Deci("0.08164965809277260327324280249"), response[owners[4].id] + ) + self.assertEqual( + Deci("0.08164965809277260327324280249"), response[owners[5].id] + ) def test_getScoringStandardDeviation_noneIfNoGamesPlayed(self): owners, teamsA = getNDefaultOwnersAndTeams(3) @@ -170,8 +194,10 @@ def test_getScoringStandardDeviation_noneIfNoGamesPlayed(self): league = League(name="TEST", owners=owners, years=[yearA]) - response = ScoringStandardDeviationAllTimeCalculator.getScoringStandardDeviation( - league, weekNumberEnd=1 + response = ( + ScoringStandardDeviationAllTimeCalculator.getScoringStandardDeviation( + league, weekNumberEnd=1 + ) ) self.assertIsInstance(response, dict) @@ -247,8 +273,10 @@ def test_getScoringStandardDeviation_onlyPostSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = ScoringStandardDeviationAllTimeCalculator.getScoringStandardDeviation( - league, onlyPostSeason=True + response = ( + ScoringStandardDeviationAllTimeCalculator.getScoringStandardDeviation( + league, onlyPostSeason=True + ) ) self.assertIsInstance(response, dict) @@ -327,8 +355,10 @@ def test_getScoringStandardDeviation_onlyRegularSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = ScoringStandardDeviationAllTimeCalculator.getScoringStandardDeviation( - league, onlyRegularSeason=True + response = ( + ScoringStandardDeviationAllTimeCalculator.getScoringStandardDeviation( + league, onlyRegularSeason=True + ) ) self.assertIsInstance(response, dict) @@ -407,8 +437,10 @@ def test_getScoringStandardDeviation_onlyChampionshipIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = ScoringStandardDeviationAllTimeCalculator.getScoringStandardDeviation( - league, onlyChampionship=True + response = ( + ScoringStandardDeviationAllTimeCalculator.getScoringStandardDeviation( + league, onlyChampionship=True + ) ) self.assertIsInstance(response, dict) @@ -497,8 +529,10 @@ def test_getScoringStandardDeviation_yearNumberStartGivenWeekNumberStartGiven(se league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = ScoringStandardDeviationAllTimeCalculator.getScoringStandardDeviation( - league, yearNumberStart=2001, weekNumberStart=2 + response = ( + ScoringStandardDeviationAllTimeCalculator.getScoringStandardDeviation( + league, yearNumberStart=2001, weekNumberStart=2 + ) ) self.assertIsInstance(response, dict) @@ -587,18 +621,28 @@ def test_getScoringStandardDeviation_yearNumberEndGivenWeekNumberEndGiven(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = ScoringStandardDeviationAllTimeCalculator.getScoringStandardDeviation( - league, yearNumberEnd=2001, weekNumberEnd=2 + response = ( + ScoringStandardDeviationAllTimeCalculator.getScoringStandardDeviation( + league, yearNumberEnd=2001, weekNumberEnd=2 + ) ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) self.assertEqual(Deci("0"), response[owners[0].id]) self.assertEqual(Deci("0"), response[owners[1].id]) - self.assertEqual(Deci("0.04714045207910316829338962414"), response[owners[2].id]) - self.assertEqual(Deci("0.04714045207910316829338962414"), response[owners[3].id]) - self.assertEqual(Deci("0.04714045207910316829338962414"), response[owners[4].id]) - self.assertEqual(Deci("0.04714045207910316829338962414"), response[owners[5].id]) + self.assertEqual( + Deci("0.04714045207910316829338962414"), response[owners[2].id] + ) + self.assertEqual( + Deci("0.04714045207910316829338962414"), response[owners[3].id] + ) + self.assertEqual( + Deci("0.04714045207910316829338962414"), response[owners[4].id] + ) + self.assertEqual( + Deci("0.04714045207910316829338962414"), response[owners[5].id] + ) def test_getScoringShare_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGivenWeekNumberEndGiven( self, @@ -679,8 +723,14 @@ def test_getScoringShare_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEn league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = ScoringStandardDeviationAllTimeCalculator.getScoringStandardDeviation( - league, yearNumberStart=2001, weekNumberStart=1, yearNumberEnd=2001, weekNumberEnd=2 + response = ( + ScoringStandardDeviationAllTimeCalculator.getScoringStandardDeviation( + league, + yearNumberStart=2001, + weekNumberStart=1, + yearNumberEnd=2001, + weekNumberEnd=2, + ) ) self.assertIsInstance(response, dict) diff --git a/test/test_calculator/test_all_time_calculator/test_SingleScoreAllTimeCalculator.py b/test/test_calculator/test_all_time_calculator/test_SingleScoreAllTimeCalculator.py index d26faaaa..559d125a 100644 --- a/test/test_calculator/test_all_time_calculator/test_SingleScoreAllTimeCalculator.py +++ b/test/test_calculator/test_all_time_calculator/test_SingleScoreAllTimeCalculator.py @@ -1,5 +1,4 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams, getTeamsFromOwners from leeger.calculator.all_time_calculator.SingleScoreAllTimeCalculator import ( SingleScoreAllTimeCalculator, @@ -9,6 +8,7 @@ from leeger.model.league.Matchup import Matchup from leeger.model.league.Week import Week from leeger.model.league.Year import Year +from test.helper.prototypes import getNDefaultOwnersAndTeams, getTeamsFromOwners class TestSingleScoreAllTimeCalculator(unittest.TestCase): @@ -259,7 +259,9 @@ def test_getMaxScore_onlyRegularSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = SingleScoreAllTimeCalculator.getMaxScore(league, onlyRegularSeason=True) + response = SingleScoreAllTimeCalculator.getMaxScore( + league, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -337,7 +339,9 @@ def test_getMaxScore_onlyChampionshipIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = SingleScoreAllTimeCalculator.getMaxScore(league, onlyChampionship=True) + response = SingleScoreAllTimeCalculator.getMaxScore( + league, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -608,7 +612,11 @@ def test_getMaxScore_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGiv league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) response = SingleScoreAllTimeCalculator.getMaxScore( - league, yearNumberStart=2001, weekNumberStart=1, yearNumberEnd=2001, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=1, + yearNumberEnd=2001, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) @@ -867,7 +875,9 @@ def test_getMinScore_onlyRegularSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = SingleScoreAllTimeCalculator.getMinScore(league, onlyRegularSeason=True) + response = SingleScoreAllTimeCalculator.getMinScore( + league, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -945,7 +955,9 @@ def test_getMinScore_onlyChampionshipIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = SingleScoreAllTimeCalculator.getMinScore(league, onlyChampionship=True) + response = SingleScoreAllTimeCalculator.getMinScore( + league, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -1216,7 +1228,11 @@ def test_getMinScore_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGiv league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) response = SingleScoreAllTimeCalculator.getMinScore( - league, yearNumberStart=2001, weekNumberStart=1, yearNumberEnd=2001, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=1, + yearNumberEnd=2001, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) diff --git a/test/test_calculator/test_all_time_calculator/test_SmartWinsAllTimeCalculator.py b/test/test_calculator/test_all_time_calculator/test_SmartWinsAllTimeCalculator.py index bd4b5c33..c0e6e961 100644 --- a/test/test_calculator/test_all_time_calculator/test_SmartWinsAllTimeCalculator.py +++ b/test/test_calculator/test_all_time_calculator/test_SmartWinsAllTimeCalculator.py @@ -1,6 +1,5 @@ import math import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams, getTeamsFromOwners from leeger.calculator.all_time_calculator.SmartWinsAllTimeCalculator import ( SmartWinsAllTimeCalculator, @@ -11,6 +10,7 @@ from leeger.model.league.Week import Week from leeger.model.league.Year import Year from leeger.util.Deci import Deci +from test.helper.prototypes import getNDefaultOwnersAndTeams, getTeamsFromOwners class TestSmartWinsAllTimeCalculator(unittest.TestCase): @@ -26,20 +26,36 @@ def test_getSmartWins_happyPath(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -49,7 +65,9 @@ def test_getSmartWins_happyPath(self): self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) - self.assertEqual(Deci("0.06666666666666666666666666666"), response[owners[0].id]) + self.assertEqual( + Deci("0.06666666666666666666666666666"), response[owners[0].id] + ) self.assertEqual(Deci("0.3333333333333333333333333334"), response[owners[1].id]) self.assertEqual(Deci("0.9999999999999999999999999999"), response[owners[2].id]) self.assertEqual(Deci("1.9"), response[owners[3].id]) @@ -68,8 +86,12 @@ def test_getSmartWins_multiWeekMatchups(self): teamBScore=2, multiWeekMatchupId="1", ) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) matchup4_a = Matchup( @@ -79,14 +101,24 @@ def test_getSmartWins_multiWeekMatchups(self): teamBScore=2, multiWeekMatchupId="1", ) - matchup5_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup6_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup5_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week2_a = Week(weekNumber=2, matchups=[matchup4_a, matchup5_a, matchup6_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) @@ -106,8 +138,12 @@ def test_getSmartWins_multiWeekMatchups(self): def test_getSmartWins_noneIfNoGamesPlayed(self): owners, teamsA = getNDefaultOwnersAndTeams(3) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=3, teamBScore=4) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=3, teamBScore=4 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) @@ -151,9 +187,15 @@ def test_getSmartWins_onlyPostSeasonIsTrue(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) @@ -187,7 +229,9 @@ def test_getSmartWins_onlyPostSeasonIsTrue(self): self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) - self.assertEqual(Deci("0.03333333333333333333333333333"), response[owners[0].id]) + self.assertEqual( + Deci("0.03333333333333333333333333333"), response[owners[0].id] + ) self.assertEqual(Deci("0.1666666666666666666666666667"), response[owners[1].id]) self.assertEqual(Deci("0.6666666666666666666666666666"), response[owners[2].id]) self.assertEqual(Deci("1.266666666666666666666666667"), response[owners[3].id]) @@ -223,9 +267,15 @@ def test_getSmartWins_onlyRegularSeasonIsTrue(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) @@ -255,11 +305,15 @@ def test_getSmartWins_onlyRegularSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = SmartWinsAllTimeCalculator.getSmartWins(league, onlyRegularSeason=True) + response = SmartWinsAllTimeCalculator.getSmartWins( + league, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) - self.assertEqual(Deci("0.03333333333333333333333333333"), response[owners[0].id]) + self.assertEqual( + Deci("0.03333333333333333333333333333"), response[owners[0].id] + ) self.assertEqual(Deci("0.1666666666666666666666666667"), response[owners[1].id]) self.assertEqual(Deci("0.3333333333333333333333333333"), response[owners[2].id]) self.assertEqual(Deci("0.6333333333333333333333333333"), response[owners[3].id]) @@ -295,9 +349,15 @@ def test_getSmartWins_onlyChampionshipIsTrue(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) @@ -327,7 +387,9 @@ def test_getSmartWins_onlyChampionshipIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = SmartWinsAllTimeCalculator.getSmartWins(league, onlyChampionship=True) + response = SmartWinsAllTimeCalculator.getSmartWins( + league, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -367,13 +429,25 @@ def test_getSmartWins_yearNumberStartGivenWeekNumberStartGiven(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) @@ -409,7 +483,9 @@ def test_getSmartWins_yearNumberStartGivenWeekNumberStartGiven(self): self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) - self.assertEqual(Deci("0.09523809523809523809523809524"), response[owners[0].id]) + self.assertEqual( + Deci("0.09523809523809523809523809524"), response[owners[0].id] + ) self.assertEqual(Deci("0.3809523809523809523809523810"), response[owners[1].id]) self.assertEqual(Deci("0.7142857142857142857142857142"), response[owners[2].id]) self.assertEqual(Deci("1.285714285714285714285714286"), response[owners[3].id]) @@ -445,13 +521,25 @@ def test_getSmartWins_yearNumberEndGivenWeekNumberEndGiven(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) @@ -487,7 +575,9 @@ def test_getSmartWins_yearNumberEndGivenWeekNumberEndGiven(self): self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) - self.assertEqual(Deci("0.09523809523809523809523809524"), response[owners[0].id]) + self.assertEqual( + Deci("0.09523809523809523809523809524"), response[owners[0].id] + ) self.assertEqual(Deci("0.3809523809523809523809523810"), response[owners[1].id]) self.assertEqual(Deci("1.071428571428571428571428571"), response[owners[2].id]) self.assertEqual(Deci("1.928571428571428571428571429"), response[owners[3].id]) @@ -525,13 +615,25 @@ def test_getSmartWins_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGi week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) @@ -562,12 +664,18 @@ def test_getSmartWins_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndGi league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) response = SmartWinsAllTimeCalculator.getSmartWins( - league, yearNumberStart=2001, weekNumberStart=1, yearNumberEnd=2001, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=1, + yearNumberEnd=2001, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) - self.assertEqual(Deci("0.09523809523809523809523809524"), response[owners[0].id]) + self.assertEqual( + Deci("0.09523809523809523809523809524"), response[owners[0].id] + ) self.assertEqual(Deci("0.3809523809523809523809523810"), response[owners[1].id]) self.assertEqual(Deci("0.7142857142857142857142857142"), response[owners[2].id]) self.assertEqual(Deci("1.285714285714285714285714286"), response[owners[3].id]) @@ -586,20 +694,36 @@ def test_getSmartWinsPerGame_happyPath(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -609,7 +733,9 @@ def test_getSmartWinsPerGame_happyPath(self): self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) - self.assertEqual(Deci("0.03333333333333333333333333333"), response[owners[0].id]) + self.assertEqual( + Deci("0.03333333333333333333333333333"), response[owners[0].id] + ) self.assertEqual(Deci("0.1666666666666666666666666667"), response[owners[1].id]) self.assertEqual(Deci("0.3333333333333333333333333333"), response[owners[2].id]) self.assertEqual(Deci("0.6333333333333333333333333333"), response[owners[3].id]) @@ -628,8 +754,12 @@ def test_getSmartWinsPerGame_multiWeekMatchups(self): teamBScore=2, multiWeekMatchupId="1", ) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) matchup4_a = Matchup( @@ -639,14 +769,24 @@ def test_getSmartWinsPerGame_multiWeekMatchups(self): teamBScore=2, multiWeekMatchupId="1", ) - matchup5_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup6_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup5_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week2_a = Week(weekNumber=2, matchups=[matchup4_a, matchup5_a, matchup6_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) @@ -666,15 +806,21 @@ def test_getSmartWinsPerGame_multiWeekMatchups(self): def test_getSmartWinsPerGame_noneIfNoGamesPlayed(self): owners, teamsA = getNDefaultOwnersAndTeams(3) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=3, teamBScore=4) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=3, teamBScore=4 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) league = League(name="TEST", owners=owners, years=[yearA]) - response = SmartWinsAllTimeCalculator.getSmartWinsPerGame(league, weekNumberEnd=1) + response = SmartWinsAllTimeCalculator.getSmartWinsPerGame( + league, weekNumberEnd=1 + ) self.assertIsInstance(response, dict) self.assertEqual(3, len(response.keys())) @@ -711,9 +857,15 @@ def test_getSmartWinsPerGame_onlyPostSeasonIsTrue(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) @@ -743,11 +895,15 @@ def test_getSmartWinsPerGame_onlyPostSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = SmartWinsAllTimeCalculator.getSmartWinsPerGame(league, onlyPostSeason=True) + response = SmartWinsAllTimeCalculator.getSmartWinsPerGame( + league, onlyPostSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) - self.assertEqual(Deci("0.03333333333333333333333333333"), response[owners[0].id]) + self.assertEqual( + Deci("0.03333333333333333333333333333"), response[owners[0].id] + ) self.assertEqual(Deci("0.1666666666666666666666666667"), response[owners[1].id]) self.assertEqual(Deci("0.3333333333333333333333333333"), response[owners[2].id]) self.assertEqual(Deci("0.6333333333333333333333333335"), response[owners[3].id]) @@ -783,9 +939,15 @@ def test_getSmartWinsPerGame_onlyRegularSeasonIsTrue(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) @@ -815,11 +977,15 @@ def test_getSmartWinsPerGame_onlyRegularSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = SmartWinsAllTimeCalculator.getSmartWinsPerGame(league, onlyRegularSeason=True) + response = SmartWinsAllTimeCalculator.getSmartWinsPerGame( + league, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) - self.assertEqual(Deci("0.03333333333333333333333333333"), response[owners[0].id]) + self.assertEqual( + Deci("0.03333333333333333333333333333"), response[owners[0].id] + ) self.assertEqual(Deci("0.1666666666666666666666666667"), response[owners[1].id]) self.assertEqual(Deci("0.3333333333333333333333333333"), response[owners[2].id]) self.assertEqual(Deci("0.6333333333333333333333333333"), response[owners[3].id]) @@ -855,9 +1021,15 @@ def test_getSmartWinsPerGame_onlyChampionshipIsTrue(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) @@ -887,7 +1059,9 @@ def test_getSmartWinsPerGame_onlyChampionshipIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = SmartWinsAllTimeCalculator.getSmartWinsPerGame(league, onlyChampionship=True) + response = SmartWinsAllTimeCalculator.getSmartWinsPerGame( + league, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -927,13 +1101,25 @@ def test_getSmartWinsPerGame_yearNumberStartGivenWeekNumberStartGiven(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) @@ -969,7 +1155,9 @@ def test_getSmartWinsPerGame_yearNumberStartGivenWeekNumberStartGiven(self): self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) - self.assertEqual(Deci("0.04761904761904761904761904762"), response[owners[0].id]) + self.assertEqual( + Deci("0.04761904761904761904761904762"), response[owners[0].id] + ) self.assertEqual(Deci("0.1904761904761904761904761905"), response[owners[1].id]) self.assertEqual(Deci("0.3571428571428571428571428571"), response[owners[2].id]) self.assertEqual(Deci("0.642857142857142857142857143"), response[owners[3].id]) @@ -1005,13 +1193,25 @@ def test_getSmartWinsPerGame_yearNumberEndGivenWeekNumberEndGiven(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) @@ -1047,7 +1247,9 @@ def test_getSmartWinsPerGame_yearNumberEndGivenWeekNumberEndGiven(self): self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) - self.assertEqual(Deci("0.04761904761904761904761904762"), response[owners[0].id]) + self.assertEqual( + Deci("0.04761904761904761904761904762"), response[owners[0].id] + ) self.assertEqual(Deci("0.1904761904761904761904761905"), response[owners[1].id]) self.assertEqual(Deci("0.357142857142857142857142857"), response[owners[2].id]) self.assertEqual(Deci("0.642857142857142857142857143"), response[owners[3].id]) @@ -1085,13 +1287,25 @@ def test_getSmartWinsPerGame_yearNumberStartGivenWeekNumberStartGivenAndYearNumb week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) @@ -1122,12 +1336,18 @@ def test_getSmartWinsPerGame_yearNumberStartGivenWeekNumberStartGivenAndYearNumb league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) response = SmartWinsAllTimeCalculator.getSmartWinsPerGame( - league, yearNumberStart=2001, weekNumberStart=1, yearNumberEnd=2001, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=1, + yearNumberEnd=2001, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) - self.assertEqual(Deci("0.04761904761904761904761904762"), response[owners[0].id]) + self.assertEqual( + Deci("0.04761904761904761904761904762"), response[owners[0].id] + ) self.assertEqual(Deci("0.1904761904761904761904761905"), response[owners[1].id]) self.assertEqual(Deci("0.3571428571428571428571428571"), response[owners[2].id]) self.assertEqual(Deci("0.642857142857142857142857143"), response[owners[3].id]) @@ -1146,20 +1366,36 @@ def test_getOpponentSmartWins_happyPath(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -1170,7 +1406,9 @@ def test_getOpponentSmartWins_happyPath(self): self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) self.assertEqual(Deci("0.3333333333333333333333333334"), response[owners[0].id]) - self.assertEqual(Deci("0.06666666666666666666666666666"), response[owners[1].id]) + self.assertEqual( + Deci("0.06666666666666666666666666666"), response[owners[1].id] + ) self.assertEqual(Deci("1.9"), response[owners[2].id]) self.assertEqual(Deci("0.9999999999999999999999999999"), response[owners[3].id]) self.assertEqual(Deci("2.8"), response[owners[4].id]) @@ -1188,8 +1426,12 @@ def test_getOpponentSmartWins_multiWeekMatchups(self): teamBScore=2, multiWeekMatchupId="1", ) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) matchup4_a = Matchup( @@ -1199,14 +1441,24 @@ def test_getOpponentSmartWins_multiWeekMatchups(self): teamBScore=2, multiWeekMatchupId="1", ) - matchup5_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup6_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup5_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week2_a = Week(weekNumber=2, matchups=[matchup4_a, matchup5_a, matchup6_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) @@ -1226,15 +1478,21 @@ def test_getOpponentSmartWins_multiWeekMatchups(self): def test_getOpponentSmartWins_noneIfNoGamesPlayed(self): owners, teamsA = getNDefaultOwnersAndTeams(3) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=3, teamBScore=4) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=3, teamBScore=4 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) league = League(name="TEST", owners=owners, years=[yearA]) - response = SmartWinsAllTimeCalculator.getOpponentSmartWins(league, weekNumberEnd=1) + response = SmartWinsAllTimeCalculator.getOpponentSmartWins( + league, weekNumberEnd=1 + ) self.assertIsInstance(response, dict) self.assertEqual(3, len(response.keys())) @@ -1271,9 +1529,15 @@ def test_getOpponentSmartWins_onlyPostSeasonIsTrue(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) @@ -1303,12 +1567,16 @@ def test_getOpponentSmartWins_onlyPostSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = SmartWinsAllTimeCalculator.getOpponentSmartWins(league, onlyPostSeason=True) + response = SmartWinsAllTimeCalculator.getOpponentSmartWins( + league, onlyPostSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) self.assertEqual(Deci("0.1666666666666666666666666667"), response[owners[0].id]) - self.assertEqual(Deci("0.03333333333333333333333333333"), response[owners[1].id]) + self.assertEqual( + Deci("0.03333333333333333333333333333"), response[owners[1].id] + ) self.assertEqual(Deci("1.266666666666666666666666667"), response[owners[2].id]) self.assertEqual(Deci("0.6666666666666666666666666666"), response[owners[3].id]) self.assertEqual(Deci("1.866666666666666666666666667"), response[owners[4].id]) @@ -1343,9 +1611,15 @@ def test_getOpponentSmartWins_onlyRegularSeasonIsTrue(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) @@ -1375,12 +1649,16 @@ def test_getOpponentSmartWins_onlyRegularSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = SmartWinsAllTimeCalculator.getOpponentSmartWins(league, onlyRegularSeason=True) + response = SmartWinsAllTimeCalculator.getOpponentSmartWins( + league, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) self.assertEqual(Deci("0.1666666666666666666666666667"), response[owners[0].id]) - self.assertEqual(Deci("0.03333333333333333333333333333"), response[owners[1].id]) + self.assertEqual( + Deci("0.03333333333333333333333333333"), response[owners[1].id] + ) self.assertEqual(Deci("0.6333333333333333333333333333"), response[owners[2].id]) self.assertEqual(Deci("0.3333333333333333333333333333"), response[owners[3].id]) self.assertEqual(Deci("0.9333333333333333333333333333"), response[owners[4].id]) @@ -1415,9 +1693,15 @@ def test_getOpponentSmartWins_onlyChampionshipIsTrue(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) @@ -1447,7 +1731,9 @@ def test_getOpponentSmartWins_onlyChampionshipIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = SmartWinsAllTimeCalculator.getOpponentSmartWins(league, onlyChampionship=True) + response = SmartWinsAllTimeCalculator.getOpponentSmartWins( + league, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -1487,13 +1773,25 @@ def test_getOpponentSmartWins_yearNumberStartGivenWeekNumberStartGiven(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) @@ -1530,7 +1828,9 @@ def test_getOpponentSmartWins_yearNumberStartGivenWeekNumberStartGiven(self): self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) self.assertEqual(Deci("0.3809523809523809523809523810"), response[owners[0].id]) - self.assertEqual(Deci("0.09523809523809523809523809524"), response[owners[1].id]) + self.assertEqual( + Deci("0.09523809523809523809523809524"), response[owners[1].id] + ) self.assertEqual(Deci("1.285714285714285714285714286"), response[owners[2].id]) self.assertEqual(Deci("0.7142857142857142857142857142"), response[owners[3].id]) self.assertEqual(Deci("1.857142857142857142857142857"), response[owners[4].id]) @@ -1565,13 +1865,25 @@ def test_getOpponentSmartWins_yearNumberEndGivenWeekNumberEndGiven(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) @@ -1608,7 +1920,9 @@ def test_getOpponentSmartWins_yearNumberEndGivenWeekNumberEndGiven(self): self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) self.assertEqual(Deci("0.3809523809523809523809523810"), response[owners[0].id]) - self.assertEqual(Deci("0.09523809523809523809523809524"), response[owners[1].id]) + self.assertEqual( + Deci("0.09523809523809523809523809524"), response[owners[1].id] + ) self.assertEqual(Deci("1.928571428571428571428571429"), response[owners[2].id]) self.assertEqual(Deci("1.071428571428571428571428571"), response[owners[3].id]) self.assertEqual(Deci("2.785714285714285714285714286"), response[owners[4].id]) @@ -1645,13 +1959,25 @@ def test_getOpponentSmartWins_yearNumberStartGivenWeekNumberStartGivenAndYearNum week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) @@ -1682,13 +2008,19 @@ def test_getOpponentSmartWins_yearNumberStartGivenWeekNumberStartGivenAndYearNum league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) response = SmartWinsAllTimeCalculator.getOpponentSmartWins( - league, yearNumberStart=2001, weekNumberStart=1, yearNumberEnd=2001, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=1, + yearNumberEnd=2001, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) self.assertEqual(Deci("0.3809523809523809523809523810"), response[owners[0].id]) - self.assertEqual(Deci("0.09523809523809523809523809524"), response[owners[1].id]) + self.assertEqual( + Deci("0.09523809523809523809523809524"), response[owners[1].id] + ) self.assertEqual(Deci("1.285714285714285714285714286"), response[owners[2].id]) self.assertEqual(Deci("0.7142857142857142857142857142"), response[owners[3].id]) self.assertEqual(Deci("1.857142857142857142857142857"), response[owners[4].id]) @@ -1706,20 +2038,36 @@ def test_getOpponentSmartWinsPerGame_happyPath(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4) - matchup3_c = Matchup(teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[2].id, teamBId=teamsC[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_c = Matchup( + teamAId=teamsC[4].id, teamBId=teamsC[5].id, teamAScore=4, teamBScore=5 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c, matchup2_c, matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c]) @@ -1730,7 +2078,9 @@ def test_getOpponentSmartWinsPerGame_happyPath(self): self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) self.assertEqual(Deci("0.1666666666666666666666666667"), response[owners[0].id]) - self.assertEqual(Deci("0.03333333333333333333333333333"), response[owners[1].id]) + self.assertEqual( + Deci("0.03333333333333333333333333333"), response[owners[1].id] + ) self.assertEqual(Deci("0.6333333333333333333333333333"), response[owners[2].id]) self.assertEqual(Deci("0.3333333333333333333333333333"), response[owners[3].id]) self.assertEqual(Deci("0.9333333333333333333333333333"), response[owners[4].id]) @@ -1748,8 +2098,12 @@ def test_getOpponentSmartWinsPerGame_multiWeekMatchups(self): teamBScore=2, multiWeekMatchupId="1", ) - matchup2_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup3_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup2_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) matchup4_a = Matchup( @@ -1759,14 +2113,24 @@ def test_getOpponentSmartWinsPerGame_multiWeekMatchups(self): teamBScore=2, multiWeekMatchupId="1", ) - matchup5_a = Matchup(teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4) - matchup6_a = Matchup(teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5) + matchup5_a = Matchup( + teamAId=teamsA[2].id, teamBId=teamsA[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_a = Matchup( + teamAId=teamsA[4].id, teamBId=teamsA[5].id, teamAScore=4, teamBScore=5 + ) week2_a = Week(weekNumber=2, matchups=[matchup4_a, matchup5_a, matchup6_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) @@ -1786,15 +2150,21 @@ def test_getOpponentSmartWinsPerGame_multiWeekMatchups(self): def test_getOpponentSmartWinsPerGame_noneIfNoGamesPlayed(self): owners, teamsA = getNDefaultOwnersAndTeams(3) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=3, teamBScore=4) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=3, teamBScore=4 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) league = League(name="TEST", owners=owners, years=[yearA]) - response = SmartWinsAllTimeCalculator.getOpponentSmartWinsPerGame(league, weekNumberEnd=1) + response = SmartWinsAllTimeCalculator.getOpponentSmartWinsPerGame( + league, weekNumberEnd=1 + ) self.assertIsInstance(response, dict) self.assertEqual(3, len(response.keys())) @@ -1831,9 +2201,15 @@ def test_getOpponentSmartWinsPerGame_onlyPostSeasonIsTrue(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) @@ -1870,7 +2246,9 @@ def test_getOpponentSmartWinsPerGame_onlyPostSeasonIsTrue(self): self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) self.assertEqual(Deci("0.1666666666666666666666666667"), response[owners[0].id]) - self.assertEqual(Deci("0.03333333333333333333333333333"), response[owners[1].id]) + self.assertEqual( + Deci("0.03333333333333333333333333333"), response[owners[1].id] + ) self.assertEqual(Deci("0.6333333333333333333333333335"), response[owners[2].id]) self.assertEqual(Deci("0.3333333333333333333333333333"), response[owners[3].id]) self.assertEqual(Deci("0.9333333333333333333333333335"), response[owners[4].id]) @@ -1905,9 +2283,15 @@ def test_getOpponentSmartWinsPerGame_onlyRegularSeasonIsTrue(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) @@ -1944,7 +2328,9 @@ def test_getOpponentSmartWinsPerGame_onlyRegularSeasonIsTrue(self): self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) self.assertEqual(Deci("0.1666666666666666666666666667"), response[owners[0].id]) - self.assertEqual(Deci("0.03333333333333333333333333333"), response[owners[1].id]) + self.assertEqual( + Deci("0.03333333333333333333333333333"), response[owners[1].id] + ) self.assertEqual(Deci("0.6333333333333333333333333333"), response[owners[2].id]) self.assertEqual(Deci("0.3333333333333333333333333333"), response[owners[3].id]) self.assertEqual(Deci("0.9333333333333333333333333333"), response[owners[4].id]) @@ -1979,9 +2365,15 @@ def test_getOpponentSmartWinsPerGame_onlyChampionshipIsTrue(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b]) @@ -2053,13 +2445,25 @@ def test_getOpponentSmartWinsPerGame_yearNumberStartGivenWeekNumberStartGiven(se week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) @@ -2096,7 +2500,9 @@ def test_getOpponentSmartWinsPerGame_yearNumberStartGivenWeekNumberStartGiven(se self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) self.assertEqual(Deci("0.1904761904761904761904761905"), response[owners[0].id]) - self.assertEqual(Deci("0.04761904761904761904761904762"), response[owners[1].id]) + self.assertEqual( + Deci("0.04761904761904761904761904762"), response[owners[1].id] + ) self.assertEqual(Deci("0.642857142857142857142857143"), response[owners[2].id]) self.assertEqual(Deci("0.3571428571428571428571428571"), response[owners[3].id]) self.assertEqual(Deci("0.9285714285714285714285714285"), response[owners[4].id]) @@ -2131,13 +2537,25 @@ def test_getOpponentSmartWinsPerGame_yearNumberEndGivenWeekNumberEndGiven(self): week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) @@ -2174,7 +2592,9 @@ def test_getOpponentSmartWinsPerGame_yearNumberEndGivenWeekNumberEndGiven(self): self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) self.assertEqual(Deci("0.1904761904761904761904761905"), response[owners[0].id]) - self.assertEqual(Deci("0.04761904761904761904761904762"), response[owners[1].id]) + self.assertEqual( + Deci("0.04761904761904761904761904762"), response[owners[1].id] + ) self.assertEqual(Deci("0.642857142857142857142857143"), response[owners[2].id]) self.assertEqual(Deci("0.357142857142857142857142857"), response[owners[3].id]) self.assertEqual(Deci("0.9285714285714285714285714287"), response[owners[4].id]) @@ -2211,13 +2631,25 @@ def test_getOpponentSmartWinsPerGame_yearNumberStartGivenWeekNumberStartGivenAnd week1_a = Week(weekNumber=1, matchups=[matchup1_a, matchup2_a, matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup3_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup3_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b, matchup2_b, matchup3_b]) - matchup4_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup5_b = Matchup(teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4) - matchup6_b = Matchup(teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5) + matchup4_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup5_b = Matchup( + teamAId=teamsB[2].id, teamBId=teamsB[3].id, teamAScore=3, teamBScore=4 + ) + matchup6_b = Matchup( + teamAId=teamsB[4].id, teamBId=teamsB[5].id, teamAScore=4, teamBScore=5 + ) week2_b = Week(weekNumber=2, matchups=[matchup4_b, matchup5_b, matchup6_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b]) @@ -2248,13 +2680,19 @@ def test_getOpponentSmartWinsPerGame_yearNumberStartGivenWeekNumberStartGivenAnd league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) response = SmartWinsAllTimeCalculator.getOpponentSmartWinsPerGame( - league, yearNumberStart=2001, weekNumberStart=1, yearNumberEnd=2001, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=1, + yearNumberEnd=2001, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) self.assertEqual(Deci("0.1904761904761904761904761905"), response[owners[0].id]) - self.assertEqual(Deci("0.04761904761904761904761904762"), response[owners[1].id]) + self.assertEqual( + Deci("0.04761904761904761904761904762"), response[owners[1].id] + ) self.assertEqual(Deci("0.642857142857142857142857143"), response[owners[2].id]) self.assertEqual(Deci("0.3571428571428571428571428571"), response[owners[3].id]) self.assertEqual(Deci("0.9285714285714285714285714285"), response[owners[4].id]) diff --git a/test/test_calculator/test_all_time_calculator/test_TeamSummaryAllTimeCalculator.py b/test/test_calculator/test_all_time_calculator/test_TeamSummaryAllTimeCalculator.py index 7ae2b6d6..1a61d4f9 100644 --- a/test/test_calculator/test_all_time_calculator/test_TeamSummaryAllTimeCalculator.py +++ b/test/test_calculator/test_all_time_calculator/test_TeamSummaryAllTimeCalculator.py @@ -1,5 +1,4 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams, getTeamsFromOwners from leeger.calculator.all_time_calculator import TeamSummaryAllTimeCalculator from leeger.enum.MatchupType import MatchupType @@ -8,6 +7,7 @@ from leeger.model.league.Matchup import Matchup from leeger.model.league.Week import Week from leeger.model.league.Year import Year +from test.helper.prototypes import getNDefaultOwnersAndTeams, getTeamsFromOwners class TestTeamSummaryAllTimeCalculator(unittest.TestCase): @@ -16,7 +16,9 @@ def test_getGamesPlayed_happyPath(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -36,7 +38,9 @@ def test_getGamesPlayed_happyPath(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -56,7 +60,9 @@ def test_getGamesPlayed_happyPath(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -90,7 +96,9 @@ def test_getGamesPlayed_multiWeekMatchups(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -112,7 +120,9 @@ def test_getGamesPlayed_multiWeekMatchups(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -132,7 +142,9 @@ def test_getGamesPlayed_multiWeekMatchups(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -164,8 +176,12 @@ def test_getGamesPlayed_multiWeekMatchups(self): def test_getGamesPlayed_zeroIfNoGamesPlayed(self): owners, teamsA = getNDefaultOwnersAndTeams(3) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) @@ -185,7 +201,9 @@ def test_getGamesPlayed_onlyPostSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -205,7 +223,9 @@ def test_getGamesPlayed_onlyPostSeasonIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -225,7 +245,9 @@ def test_getGamesPlayed_onlyPostSeasonIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -247,7 +269,9 @@ def test_getGamesPlayed_onlyPostSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = TeamSummaryAllTimeCalculator.getGamesPlayed(league, onlyPostSeason=True) + response = TeamSummaryAllTimeCalculator.getGamesPlayed( + league, onlyPostSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -259,7 +283,9 @@ def test_getGamesPlayed_onlyRegularSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -279,7 +305,9 @@ def test_getGamesPlayed_onlyRegularSeasonIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -299,7 +327,9 @@ def test_getGamesPlayed_onlyRegularSeasonIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -321,7 +351,9 @@ def test_getGamesPlayed_onlyRegularSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = TeamSummaryAllTimeCalculator.getGamesPlayed(league, onlyRegularSeason=True) + response = TeamSummaryAllTimeCalculator.getGamesPlayed( + league, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -333,7 +365,9 @@ def test_getGamesPlayed_onlyChampionshipIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -353,7 +387,9 @@ def test_getGamesPlayed_onlyChampionshipIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -373,7 +409,9 @@ def test_getGamesPlayed_onlyChampionshipIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -395,7 +433,9 @@ def test_getGamesPlayed_onlyChampionshipIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = TeamSummaryAllTimeCalculator.getGamesPlayed(league, onlyChampionship=True) + response = TeamSummaryAllTimeCalculator.getGamesPlayed( + league, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -407,7 +447,9 @@ def test_getGamesPlayed_yearNumberStartGivenWeekNumberStartGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -427,7 +469,9 @@ def test_getGamesPlayed_yearNumberStartGivenWeekNumberStartGiven(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -447,7 +491,9 @@ def test_getGamesPlayed_yearNumberStartGivenWeekNumberStartGiven(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -483,7 +529,9 @@ def test_getGamesPlayed_yearNumberEndGivenWeekNumberEndGiven(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -503,7 +551,9 @@ def test_getGamesPlayed_yearNumberEndGivenWeekNumberEndGiven(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -523,7 +573,9 @@ def test_getGamesPlayed_yearNumberEndGivenWeekNumberEndGiven(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -562,7 +614,9 @@ def test_getGamesPlayed_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEnd teamsC = getTeamsFromOwners(owners) teamsD = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -582,7 +636,9 @@ def test_getGamesPlayed_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEnd week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -602,7 +658,9 @@ def test_getGamesPlayed_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEnd week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -622,7 +680,9 @@ def test_getGamesPlayed_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEnd week3_c = Week(weekNumber=3, matchups=[matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c, week2_c, week3_c]) - matchup1_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) + matchup1_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) matchup2_d = Matchup( teamAId=teamsD[0].id, teamBId=teamsD[1].id, @@ -645,7 +705,11 @@ def test_getGamesPlayed_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEnd league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC, yearD]) response = TeamSummaryAllTimeCalculator.getGamesPlayed( - league, yearNumberStart=2001, weekNumberStart=2, yearNumberEnd=2002, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=2, + yearNumberEnd=2002, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) @@ -658,7 +722,9 @@ def test_totalGames_default_happyPath(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -678,7 +744,9 @@ def test_totalGames_default_happyPath(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -698,7 +766,9 @@ def test_totalGames_default_happyPath(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -733,9 +803,15 @@ def test_getTotalGames_leagueMedianGamesIsOn_happyPath(self): teamsC = getTeamsFromOwners(owners) yearSettings = YearSettings(leagueMedianGames=True) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup3_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) week3_a = Week(weekNumber=3, matchups=[matchup3_a]) @@ -746,9 +822,15 @@ def test_getTotalGames_leagueMedianGamesIsOn_happyPath(self): yearSettings=yearSettings, ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup3_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) week3_b = Week(weekNumber=3, matchups=[matchup3_b]) @@ -759,9 +841,15 @@ def test_getTotalGames_leagueMedianGamesIsOn_happyPath(self): yearSettings=yearSettings, ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup3_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c]) week2_c = Week(weekNumber=2, matchups=[matchup2_c]) week3_c = Week(weekNumber=3, matchups=[matchup3_c]) @@ -786,7 +874,9 @@ def test_getTotalGames_multiWeekMatchups(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -808,7 +898,9 @@ def test_getTotalGames_multiWeekMatchups(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -828,7 +920,9 @@ def test_getTotalGames_multiWeekMatchups(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -860,8 +954,12 @@ def test_getTotalGames_multiWeekMatchups(self): def test_getTotalGames_zeroIfNoGamesPlayed(self): owners, teamsA = getNDefaultOwnersAndTeams(3) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[1].id, teamBId=teamsA[2].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a]) @@ -881,7 +979,9 @@ def test_getTotalGames_onlyPostSeasonIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -901,7 +1001,9 @@ def test_getTotalGames_onlyPostSeasonIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -921,7 +1023,9 @@ def test_getTotalGames_onlyPostSeasonIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -943,7 +1047,9 @@ def test_getTotalGames_onlyPostSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = TeamSummaryAllTimeCalculator.getTotalGames(league, onlyPostSeason=True) + response = TeamSummaryAllTimeCalculator.getTotalGames( + league, onlyPostSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -956,7 +1062,9 @@ def test_getTotalGames_onlyRegularSeasonIsTrue(self): teamsC = getTeamsFromOwners(owners) yearSettings = YearSettings(leagueMedianGames=True) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -981,7 +1089,9 @@ def test_getTotalGames_onlyRegularSeasonIsTrue(self): yearSettings=yearSettings, ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -1006,7 +1116,9 @@ def test_getTotalGames_onlyRegularSeasonIsTrue(self): yearSettings=yearSettings, ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -1033,7 +1145,9 @@ def test_getTotalGames_onlyRegularSeasonIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = TeamSummaryAllTimeCalculator.getTotalGames(league, onlyRegularSeason=True) + response = TeamSummaryAllTimeCalculator.getTotalGames( + league, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -1045,7 +1159,9 @@ def test_getTotalGames_onlyChampionshipIsTrue(self): teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -1065,7 +1181,9 @@ def test_getTotalGames_onlyChampionshipIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -1085,7 +1203,9 @@ def test_getTotalGames_onlyChampionshipIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -1107,7 +1227,9 @@ def test_getTotalGames_onlyChampionshipIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC]) - response = TeamSummaryAllTimeCalculator.getTotalGames(league, onlyChampionship=True) + response = TeamSummaryAllTimeCalculator.getTotalGames( + league, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -1120,9 +1242,15 @@ def test_getTotalGames_yearNumberStartGivenWeekNumberStartGiven(self): teamsC = getTeamsFromOwners(owners) yearSettings = YearSettings(leagueMedianGames=True) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup3_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) week3_a = Week(weekNumber=3, matchups=[matchup3_a]) @@ -1133,9 +1261,15 @@ def test_getTotalGames_yearNumberStartGivenWeekNumberStartGiven(self): yearSettings=yearSettings, ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup3_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) week3_b = Week(weekNumber=3, matchups=[matchup3_b]) @@ -1146,9 +1280,15 @@ def test_getTotalGames_yearNumberStartGivenWeekNumberStartGiven(self): yearSettings=yearSettings, ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup3_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c]) week2_c = Week(weekNumber=2, matchups=[matchup2_c]) week3_c = Week(weekNumber=3, matchups=[matchup3_c]) @@ -1176,9 +1316,15 @@ def test_getTotalGames_yearNumberEndGivenWeekNumberEndGiven(self): teamsC = getTeamsFromOwners(owners) yearSettings = YearSettings(leagueMedianGames=True) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup3_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) week3_a = Week(weekNumber=3, matchups=[matchup3_a]) @@ -1189,9 +1335,15 @@ def test_getTotalGames_yearNumberEndGivenWeekNumberEndGiven(self): yearSettings=yearSettings, ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup3_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) week3_b = Week(weekNumber=3, matchups=[matchup3_b]) @@ -1202,9 +1354,15 @@ def test_getTotalGames_yearNumberEndGivenWeekNumberEndGiven(self): yearSettings=yearSettings, ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup3_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c]) week2_c = Week(weekNumber=2, matchups=[matchup2_c]) week3_c = Week(weekNumber=3, matchups=[matchup3_c]) @@ -1235,9 +1393,15 @@ def test_getTotalGames_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndG teamsD = getTeamsFromOwners(owners) yearSettings = YearSettings(leagueMedianGames=True) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup3_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) week3_a = Week(weekNumber=3, matchups=[matchup3_a]) @@ -1248,9 +1412,15 @@ def test_getTotalGames_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndG yearSettings=yearSettings, ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup3_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) week3_b = Week(weekNumber=3, matchups=[matchup3_b]) @@ -1261,9 +1431,15 @@ def test_getTotalGames_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndG yearSettings=yearSettings, ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup2_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup3_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c]) week2_c = Week(weekNumber=2, matchups=[matchup2_c]) week3_c = Week(weekNumber=3, matchups=[matchup3_c]) @@ -1274,9 +1450,15 @@ def test_getTotalGames_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndG yearSettings=yearSettings, ) - matchup1_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) - matchup2_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) - matchup3_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) + matchup1_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) week1_d = Week(weekNumber=1, matchups=[matchup1_d]) week2_d = Week(weekNumber=2, matchups=[matchup2_d]) week3_d = Week(weekNumber=3, matchups=[matchup3_d]) @@ -1290,7 +1472,11 @@ def test_getTotalGames_yearNumberStartGivenWeekNumberStartGivenAndYearNumberEndG league = League(name="TEST", owners=owners, years=[yearA, yearB, yearC, yearD]) response = TeamSummaryAllTimeCalculator.getTotalGames( - league, yearNumberStart=2001, weekNumberStart=2, yearNumberEnd=2002, weekNumberEnd=2 + league, + yearNumberStart=2001, + weekNumberStart=2, + yearNumberEnd=2002, + weekNumberEnd=2, ) self.assertIsInstance(response, dict) diff --git a/test/test_calculator/test_year_calculator/test_AWALYearCalculator.py b/test/test_calculator/test_year_calculator/test_AWALYearCalculator.py index a587cbc1..e8313d04 100644 --- a/test/test_calculator/test_year_calculator/test_AWALYearCalculator.py +++ b/test/test_calculator/test_year_calculator/test_AWALYearCalculator.py @@ -1,5 +1,4 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams from leeger.calculator.year_calculator.AWALYearCalculator import AWALYearCalculator from leeger.enum.MatchupType import MatchupType @@ -8,27 +7,46 @@ from leeger.model.league.Week import Week from leeger.model.league.Year import Year from leeger.util.Deci import Deci +from test.helper.prototypes import getNDefaultOwnersAndTeams class TestAWALYearCalculator(unittest.TestCase): def test_getAWAL_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week3 = Week(weekNumber=3, matchups=[matchup1, matchup2, matchup3]) @@ -52,27 +70,48 @@ def test_getAWAL_happyPath(self): def test_getAWAL_leagueMedianGamesIsOn_addsLeagueMedianWinsToAWAL(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week3 = Week(weekNumber=3, matchups=[matchup1, matchup2, matchup3]) yearSettings = YearSettings(leagueMedianGames=True) year = Year( - yearNumber=2000, teams=teams, weeks=[week1, week2, week3], yearSettings=yearSettings + yearNumber=2000, + teams=teams, + weeks=[week1, week2, week3], + yearSettings=yearSettings, ) response = AWALYearCalculator.getAWAL(year) @@ -83,12 +122,20 @@ def test_getAWAL_leagueMedianGamesIsOn_addsLeagueMedianWinsToAWAL(self): def test_getAWAL_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) - matchup4 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup5 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup6 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup4 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup5 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup6 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup4, matchup5, matchup6]) year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2]) @@ -107,9 +154,15 @@ def test_getAWAL_noneIfNoGamesPlayed(self): def test_getAWAL_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -181,9 +234,15 @@ def test_getAWAL_onlyPostSeasonIsTrue(self): def test_getAWAL_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -255,9 +314,15 @@ def test_getAWAL_onlyRegularSeasonIsTrue(self): def test_getAWAL_onlyChampionshipIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -329,9 +394,15 @@ def test_getAWAL_onlyChampionshipIsTrue(self): def test_getAWAL_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -403,9 +474,15 @@ def test_getAWAL_weekNumberStartGiven(self): def test_getAWAL_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -477,9 +554,15 @@ def test_getAWAL_weekNumberEndGiven(self): def test_getAWAL_weekNumberStartGivenAndWeekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -551,9 +634,15 @@ def test_getAWAL_weekNumberStartGivenAndWeekNumberEndGiven(self): def test_getAWAL_matchupEndsInTie(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=3) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=3 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -577,9 +666,15 @@ def test_getAWAL_matchupEndsInTie(self): def test_getAWAL_multipleMatchupsEndInTie(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=3) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=3 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -603,9 +698,15 @@ def test_getAWAL_multipleMatchupsEndInTie(self): def test_getAWAL_allMatchupsEndInTie(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=2, teamBScore=2) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=3, teamBScore=3) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=2, teamBScore=2 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=3, teamBScore=3 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -629,9 +730,15 @@ def test_getAWAL_allMatchupsEndInTie(self): def test_getAWAL_allMatchupsEndInTieAndHaveSameScore(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=1, teamBScore=1) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=1, teamBScore=1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=1, teamBScore=1 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=1, teamBScore=1 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -655,14 +762,30 @@ def test_getAWAL_allMatchupsEndInTieAndHaveSameScore(self): def test_getAWAL_sixteenTeams(self): owners, teams = getNDefaultOwnersAndTeams(16) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=5, teamBScore=6) - matchup4 = Matchup(teamAId=teams[6].id, teamBId=teams[7].id, teamAScore=7, teamBScore=8) - matchup5 = Matchup(teamAId=teams[8].id, teamBId=teams[9].id, teamAScore=9, teamBScore=10) - matchup6 = Matchup(teamAId=teams[10].id, teamBId=teams[11].id, teamAScore=11, teamBScore=12) - matchup7 = Matchup(teamAId=teams[12].id, teamBId=teams[13].id, teamAScore=13, teamBScore=14) - matchup8 = Matchup(teamAId=teams[14].id, teamBId=teams[15].id, teamAScore=15, teamBScore=16) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=5, teamBScore=6 + ) + matchup4 = Matchup( + teamAId=teams[6].id, teamBId=teams[7].id, teamAScore=7, teamBScore=8 + ) + matchup5 = Matchup( + teamAId=teams[8].id, teamBId=teams[9].id, teamAScore=9, teamBScore=10 + ) + matchup6 = Matchup( + teamAId=teams[10].id, teamBId=teams[11].id, teamAScore=11, teamBScore=12 + ) + matchup7 = Matchup( + teamAId=teams[12].id, teamBId=teams[13].id, teamAScore=13, teamBScore=14 + ) + matchup8 = Matchup( + teamAId=teams[14].id, teamBId=teams[15].id, teamAScore=15, teamBScore=16 + ) week1 = Week( weekNumber=1, @@ -725,21 +848,39 @@ def test_getAWAL_sixteenTeams(self): def test_getAWALPerGame_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week3 = Week(weekNumber=3, matchups=[matchup1, matchup2, matchup3]) @@ -763,27 +904,48 @@ def test_getAWALPerGame_happyPath(self): def test_getAWALPerGame_leagueMedianGamesIsOn(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week3 = Week(weekNumber=3, matchups=[matchup1, matchup2, matchup3]) yearSettings = YearSettings(leagueMedianGames=True) year = Year( - yearNumber=2000, teams=teams, weeks=[week1, week2, week3], yearSettings=yearSettings + yearNumber=2000, + teams=teams, + weeks=[week1, week2, week3], + yearSettings=yearSettings, ) response = AWALYearCalculator.getAWALPerGame(year) @@ -800,12 +962,20 @@ def test_getAWALPerGame_leagueMedianGamesIsOn(self): def test_getAWALPerGame_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) - matchup4 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup5 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup6 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup4 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup5 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup6 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup4, matchup5, matchup6]) year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2]) @@ -824,9 +994,15 @@ def test_getAWALPerGame_noneIfNoGamesPlayed(self): def test_getAWALPerGame_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -898,9 +1074,15 @@ def test_getAWALPerGame_onlyPostSeasonIsTrue(self): def test_getAWALPerGame_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -972,9 +1154,15 @@ def test_getAWALPerGame_onlyRegularSeasonIsTrue(self): def test_getAWALPerGame_onlyChampionshipIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -1046,9 +1234,15 @@ def test_getAWALPerGame_onlyChampionshipIsTrue(self): def test_getAWALPerGame_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -1120,9 +1314,15 @@ def test_getAWALPerGame_weekNumberStartGiven(self): def test_getAWALPerGame_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -1194,9 +1394,15 @@ def test_getAWALPerGame_weekNumberEndGiven(self): def test_getAWALPerGame_weekNumberStartGivenAndWeekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -1278,7 +1484,9 @@ def test_getAWALPerGame_weekNumberStartGivenAndWeekNumberEndGiven(self): weeks=[week1, week2, week3, week4], ) - response = AWALYearCalculator.getAWALPerGame(year, weekNumberStart=2, weekNumberEnd=3) + response = AWALYearCalculator.getAWALPerGame( + year, weekNumberStart=2, weekNumberEnd=3 + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -1292,9 +1500,15 @@ def test_getAWALPerGame_weekNumberStartGivenAndWeekNumberEndGiven(self): def test_getAWALPerGame_teamsDontPlayEveryWeek(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -1328,21 +1542,39 @@ def test_getAWALPerGame_teamsDontPlayEveryWeek(self): def test_getOpponentAWAL_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week3 = Week(weekNumber=3, matchups=[matchup1, matchup2, matchup3]) @@ -1366,27 +1598,48 @@ def test_getOpponentAWAL_happyPath(self): def test_getOpponentAWAL_leagueMedianGamesIsOn_countsLeagueMedianGames(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week3 = Week(weekNumber=3, matchups=[matchup1, matchup2, matchup3]) yearSettings = YearSettings(leagueMedianGames=True) year = Year( - yearNumber=2000, teams=teams, weeks=[week1, week2, week3], yearSettings=yearSettings + yearNumber=2000, + teams=teams, + weeks=[week1, week2, week3], + yearSettings=yearSettings, ) response = AWALYearCalculator.getOpponentAWAL(year) @@ -1403,12 +1656,20 @@ def test_getOpponentAWAL_leagueMedianGamesIsOn_countsLeagueMedianGames(self): def test_getOpponentAWAL_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) - matchup4 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup5 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup6 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup4 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup5 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup6 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup4, matchup5, matchup6]) year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2]) @@ -1427,9 +1688,15 @@ def test_getOpponentAWAL_noneIfNoGamesPlayed(self): def test_getOpponentAWAL_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -1501,9 +1768,15 @@ def test_getOpponentAWAL_onlyPostSeasonIsTrue(self): def test_getOpponentAWAL_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -1575,9 +1848,15 @@ def test_getOpponentAWAL_onlyRegularSeasonIsTrue(self): def test_getOpponentAWAL_onlyChampionshipIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -1649,9 +1928,15 @@ def test_getOpponentAWAL_onlyChampionshipIsTrue(self): def test_getOpponentAWAL_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -1723,9 +2008,15 @@ def test_getOpponentAWAL_weekNumberStartGiven(self): def test_getOpponentAWAL_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -1797,9 +2088,15 @@ def test_getOpponentAWAL_weekNumberEndGiven(self): def test_getOpponentAWAL_weekNumberStartGivenAndWeekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -1857,7 +2154,9 @@ def test_getOpponentAWAL_weekNumberStartGivenAndWeekNumberEndGiven(self): weeks=[week1, week2, week3], ) - response = AWALYearCalculator.getOpponentAWAL(year, weekNumberStart=2, weekNumberEnd=3) + response = AWALYearCalculator.getOpponentAWAL( + year, weekNumberStart=2, weekNumberEnd=3 + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -1871,9 +2170,15 @@ def test_getOpponentAWAL_weekNumberStartGivenAndWeekNumberEndGiven(self): def test_getOpponentAWAL_matchupEndsInTie(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=3) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=3 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -1897,9 +2202,15 @@ def test_getOpponentAWAL_matchupEndsInTie(self): def test_getOpponentAWAL_multipleMatchupsEndInTie(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=3) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=3 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -1923,9 +2234,15 @@ def test_getOpponentAWAL_multipleMatchupsEndInTie(self): def test_getOpponentAWAL_allMatchupsEndInTie(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=2, teamBScore=2) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=3, teamBScore=3) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=2, teamBScore=2 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=3, teamBScore=3 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -1949,9 +2266,15 @@ def test_getOpponentAWAL_allMatchupsEndInTie(self): def test_getOpponentAWAL_allMatchupsEndInTieAndHaveSameScore(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=1, teamBScore=1) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=1, teamBScore=1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=1, teamBScore=1 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=1, teamBScore=1 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -1975,14 +2298,30 @@ def test_getOpponentAWAL_allMatchupsEndInTieAndHaveSameScore(self): def test_getOpponentAWAL_sixteenTeams(self): owners, teams = getNDefaultOwnersAndTeams(16) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=5, teamBScore=6) - matchup4 = Matchup(teamAId=teams[6].id, teamBId=teams[7].id, teamAScore=7, teamBScore=8) - matchup5 = Matchup(teamAId=teams[8].id, teamBId=teams[9].id, teamAScore=9, teamBScore=10) - matchup6 = Matchup(teamAId=teams[10].id, teamBId=teams[11].id, teamAScore=11, teamBScore=12) - matchup7 = Matchup(teamAId=teams[12].id, teamBId=teams[13].id, teamAScore=13, teamBScore=14) - matchup8 = Matchup(teamAId=teams[14].id, teamBId=teams[15].id, teamAScore=15, teamBScore=16) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=5, teamBScore=6 + ) + matchup4 = Matchup( + teamAId=teams[6].id, teamBId=teams[7].id, teamAScore=7, teamBScore=8 + ) + matchup5 = Matchup( + teamAId=teams[8].id, teamBId=teams[9].id, teamAScore=9, teamBScore=10 + ) + matchup6 = Matchup( + teamAId=teams[10].id, teamBId=teams[11].id, teamAScore=11, teamBScore=12 + ) + matchup7 = Matchup( + teamAId=teams[12].id, teamBId=teams[13].id, teamAScore=13, teamBScore=14 + ) + matchup8 = Matchup( + teamAId=teams[14].id, teamBId=teams[15].id, teamAScore=15, teamBScore=16 + ) week1 = Week( weekNumber=1, @@ -2045,21 +2384,39 @@ def test_getOpponentAWAL_sixteenTeams(self): def test_getOpponentAWALPerGame_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week3 = Week(weekNumber=3, matchups=[matchup1, matchup2, matchup3]) @@ -2083,27 +2440,48 @@ def test_getOpponentAWALPerGame_happyPath(self): def test_getOpponentAWALPerGame_leagueMedianGamesIsOn(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week3 = Week(weekNumber=3, matchups=[matchup1, matchup2, matchup3]) yearSettings = YearSettings(leagueMedianGames=True) year = Year( - yearNumber=2000, teams=teams, weeks=[week1, week2, week3], yearSettings=yearSettings + yearNumber=2000, + teams=teams, + weeks=[week1, week2, week3], + yearSettings=yearSettings, ) response = AWALYearCalculator.getOpponentAWALPerGame(year) @@ -2120,12 +2498,20 @@ def test_getOpponentAWALPerGame_leagueMedianGamesIsOn(self): def test_getOpponentAWALPerGame_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) - matchup4 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup5 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup6 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup4 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup5 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup6 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup4, matchup5, matchup6]) year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2]) @@ -2144,9 +2530,15 @@ def test_getOpponentAWALPerGame_noneIfNoGamesPlayed(self): def test_getOpponentAWALPerGame_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -2218,9 +2610,15 @@ def test_getOpponentAWALPerGame_onlyPostSeasonIsTrue(self): def test_getOpponentAWALPerGame_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -2278,7 +2676,9 @@ def test_getOpponentAWALPerGame_onlyRegularSeasonIsTrue(self): weeks=[week1, week2, week3], ) - response = AWALYearCalculator.getOpponentAWALPerGame(year, onlyRegularSeason=True) + response = AWALYearCalculator.getOpponentAWALPerGame( + year, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -2292,9 +2692,15 @@ def test_getOpponentAWALPerGame_onlyRegularSeasonIsTrue(self): def test_getOpponentAWALPerGame_onlyChampionshipIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -2352,7 +2758,9 @@ def test_getOpponentAWALPerGame_onlyChampionshipIsTrue(self): weeks=[week1, week2, week3], ) - response = AWALYearCalculator.getOpponentAWALPerGame(year, onlyChampionship=True) + response = AWALYearCalculator.getOpponentAWALPerGame( + year, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -2366,9 +2774,15 @@ def test_getOpponentAWALPerGame_onlyChampionshipIsTrue(self): def test_getOpponentAWALPerGame_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -2440,9 +2854,15 @@ def test_getOpponentAWALPerGame_weekNumberStartGiven(self): def test_getOpponentAWALPerGame_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -2514,9 +2934,15 @@ def test_getOpponentAWALPerGame_weekNumberEndGiven(self): def test_getOpponentAWALPerGame_weekNumberStartGivenAndWeekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -2614,9 +3040,15 @@ def test_getOpponentAWALPerGame_weekNumberStartGivenAndWeekNumberEndGiven(self): def test_getOpponentAWALPerGame_teamsDontPlayEveryWeek(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) diff --git a/test/test_calculator/test_year_calculator/test_GameOutcomeYearCalculator.py b/test/test_calculator/test_year_calculator/test_GameOutcomeYearCalculator.py index c0be85b2..fbcc9a9c 100644 --- a/test/test_calculator/test_year_calculator/test_GameOutcomeYearCalculator.py +++ b/test/test_calculator/test_year_calculator/test_GameOutcomeYearCalculator.py @@ -1,20 +1,24 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams -from leeger.calculator.year_calculator.GameOutcomeYearCalculator import GameOutcomeYearCalculator +from leeger.calculator.year_calculator.GameOutcomeYearCalculator import ( + GameOutcomeYearCalculator, +) from leeger.enum.MatchupType import MatchupType from leeger.model.league import YearSettings from leeger.model.league.Matchup import Matchup from leeger.model.league.Week import Week from leeger.model.league.Year import Year from leeger.util.Deci import Deci +from test.helper.prototypes import getNDefaultOwnersAndTeams class TestGameOutcomeYearCalculator(unittest.TestCase): def test_getWins_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) @@ -48,7 +52,9 @@ def test_getWins_multiWeekMatchups(self): ) week2 = Week(weekNumber=2, matchups=[matchup2]) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week3 = Week(weekNumber=3, matchups=[matchup3]) year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) @@ -63,8 +69,12 @@ def test_getWins_multiWeekMatchups(self): def test_getWins_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -82,7 +92,9 @@ def test_getWins_noneIfNoGamesPlayed(self): def test_getWins_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -102,7 +114,9 @@ def test_getWins_onlyPostSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getWins(year, onlyPostSeason=True) @@ -114,8 +128,12 @@ def test_getWins_onlyPostSeasonIsTrue(self): def test_getWins_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -128,7 +146,9 @@ def test_getWins_onlyRegularSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getWins(year, onlyRegularSeason=True) @@ -140,7 +160,9 @@ def test_getWins_onlyRegularSeasonIsTrue(self): def test_getWins_onlyChampionshipIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -160,7 +182,9 @@ def test_getWins_onlyChampionshipIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getWins(year, onlyChampionship=True) @@ -172,8 +196,12 @@ def test_getWins_onlyChampionshipIsTrue(self): def test_getWins_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -186,7 +214,9 @@ def test_getWins_weekNumberStartGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getWins(year, weekNumberStart=2) @@ -198,8 +228,12 @@ def test_getWins_weekNumberStartGiven(self): def test_getWins_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -212,7 +246,9 @@ def test_getWins_weekNumberEndGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getWins(year, weekNumberEnd=2) @@ -224,8 +260,12 @@ def test_getWins_weekNumberEndGiven(self): def test_getWins_weekNumberStartGivenAndWeekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -246,9 +286,15 @@ def test_getWins_weekNumberStartGivenAndWeekNumberEndGiven(self): week3 = Week(weekNumber=3, matchups=[matchup3]) week4 = Week(weekNumber=4, matchups=[matchup4]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3, week4]) + year = Year( + yearNumber=2000, + teams=[teams[0], teams[1]], + weeks=[week1, week2, week3, week4], + ) - response = GameOutcomeYearCalculator.getWins(year, weekNumberStart=2, weekNumberEnd=3) + response = GameOutcomeYearCalculator.getWins( + year, weekNumberStart=2, weekNumberEnd=3 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -258,7 +304,9 @@ def test_getWins_weekNumberStartGivenAndWeekNumberEndGiven(self): def test_getLosses_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) @@ -292,7 +340,9 @@ def test_getLosses_multiWeekMatchups(self): ) week2 = Week(weekNumber=2, matchups=[matchup2]) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week3 = Week(weekNumber=3, matchups=[matchup3]) year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) @@ -307,8 +357,12 @@ def test_getLosses_multiWeekMatchups(self): def test_getLosses_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -326,7 +380,9 @@ def test_getLosses_noneIfNoGamesPlayed(self): def test_getLosses_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -346,7 +402,9 @@ def test_getLosses_onlyPostSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getLosses(year, onlyPostSeason=True) @@ -358,8 +416,12 @@ def test_getLosses_onlyPostSeasonIsTrue(self): def test_getLosses_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -372,7 +434,9 @@ def test_getLosses_onlyRegularSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getLosses(year, onlyRegularSeason=True) @@ -384,7 +448,9 @@ def test_getLosses_onlyRegularSeasonIsTrue(self): def test_getLosses_onlyChampionshipIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -404,7 +470,9 @@ def test_getLosses_onlyChampionshipIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getLosses(year, onlyChampionship=True) @@ -416,8 +484,12 @@ def test_getLosses_onlyChampionshipIsTrue(self): def test_getLosses_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -430,7 +502,9 @@ def test_getLosses_weekNumberStartGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getLosses(year, weekNumberStart=2) @@ -442,8 +516,12 @@ def test_getLosses_weekNumberStartGiven(self): def test_getLosses_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -456,7 +534,9 @@ def test_getLosses_weekNumberEndGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getLosses(year, weekNumberEnd=2) @@ -468,8 +548,12 @@ def test_getLosses_weekNumberEndGiven(self): def test_getLosses_weekNumberStartGivenAndWeekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -490,9 +574,15 @@ def test_getLosses_weekNumberStartGivenAndWeekNumberEndGiven(self): week3 = Week(weekNumber=3, matchups=[matchup3]) week4 = Week(weekNumber=4, matchups=[matchup4]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3, week4]) + year = Year( + yearNumber=2000, + teams=[teams[0], teams[1]], + weeks=[week1, week2, week3, week4], + ) - response = GameOutcomeYearCalculator.getLosses(year, weekNumberStart=2, weekNumberEnd=3) + response = GameOutcomeYearCalculator.getLosses( + year, weekNumberStart=2, weekNumberEnd=3 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -502,7 +592,9 @@ def test_getLosses_weekNumberStartGivenAndWeekNumberEndGiven(self): def test_getTies_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) @@ -536,7 +628,9 @@ def test_getTies_multiWeekMatchups(self): ) week2 = Week(weekNumber=2, matchups=[matchup2]) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) week3 = Week(weekNumber=3, matchups=[matchup3]) year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) @@ -551,8 +645,12 @@ def test_getTies_multiWeekMatchups(self): def test_getTies_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1, teamBScore=1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1, teamBScore=1 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -570,7 +668,9 @@ def test_getTies_noneIfNoGamesPlayed(self): def test_getTies_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -590,7 +690,9 @@ def test_getTies_onlyPostSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getTies(year, onlyPostSeason=True) @@ -602,8 +704,12 @@ def test_getTies_onlyPostSeasonIsTrue(self): def test_getTies_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -616,7 +722,9 @@ def test_getTies_onlyRegularSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getTies(year, onlyRegularSeason=True) @@ -628,7 +736,9 @@ def test_getTies_onlyRegularSeasonIsTrue(self): def test_getTies_onlyChampionshipIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -648,7 +758,9 @@ def test_getTies_onlyChampionshipIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getTies(year, onlyChampionship=True) @@ -660,15 +772,23 @@ def test_getTies_onlyChampionshipIsTrue(self): def test_getTies_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getTies(year, weekNumberStart=2) @@ -680,15 +800,23 @@ def test_getTies_weekNumberStartGiven(self): def test_getTies_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getTies(year, weekNumberEnd=2) @@ -700,19 +828,33 @@ def test_getTies_weekNumberEndGiven(self): def test_getTies_weekNumberStartGivenAndWeekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) - matchup4 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1 + ) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) + matchup4 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) week4 = Week(weekNumber=4, matchups=[matchup4]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3, week4]) + year = Year( + yearNumber=2000, + teams=[teams[0], teams[1]], + weeks=[week1, week2, week3, week4], + ) - response = GameOutcomeYearCalculator.getTies(year, weekNumberStart=2, weekNumberEnd=3) + response = GameOutcomeYearCalculator.getTies( + year, weekNumberStart=2, weekNumberEnd=3 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -722,17 +864,29 @@ def test_getTies_weekNumberStartGivenAndWeekNumberEndGiven(self): def test_getWinPercentage_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup4 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup4 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) week4 = Week(weekNumber=4, matchups=[matchup4]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3, week4]) + year = Year( + yearNumber=2000, + teams=[teams[0], teams[1]], + weeks=[week1, week2, week3, week4], + ) response = GameOutcomeYearCalculator.getWinPercentage(year) @@ -744,10 +898,18 @@ def test_getWinPercentage_happyPath(self): def test_getWinPercentage_leagueMedianGamesIsOn_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup4 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup4 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -790,7 +952,9 @@ def test_getWinPercentage_multiWeekMatchups(self): ) week2 = Week(weekNumber=2, matchups=[matchup2]) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1 + ) week3 = Week(weekNumber=3, matchups=[matchup3]) year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) @@ -805,8 +969,12 @@ def test_getWinPercentage_multiWeekMatchups(self): def test_getWinPercentage_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -824,7 +992,9 @@ def test_getWinPercentage_noneIfNoGamesPlayed(self): def test_getWinPercentage_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -844,7 +1014,9 @@ def test_getWinPercentage_onlyPostSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getWinPercentage(year, onlyPostSeason=True) @@ -856,8 +1028,12 @@ def test_getWinPercentage_onlyPostSeasonIsTrue(self): def test_getWinPercentage_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -870,9 +1046,13 @@ def test_getWinPercentage_onlyRegularSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) - response = GameOutcomeYearCalculator.getWinPercentage(year, onlyRegularSeason=True) + response = GameOutcomeYearCalculator.getWinPercentage( + year, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -882,7 +1062,9 @@ def test_getWinPercentage_onlyRegularSeasonIsTrue(self): def test_getWinPercentage_onlyChampionshipIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -902,9 +1084,13 @@ def test_getWinPercentage_onlyChampionshipIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) - response = GameOutcomeYearCalculator.getWinPercentage(year, onlyChampionship=True) + response = GameOutcomeYearCalculator.getWinPercentage( + year, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -914,8 +1100,12 @@ def test_getWinPercentage_onlyChampionshipIsTrue(self): def test_getWinPercentage_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -928,7 +1118,9 @@ def test_getWinPercentage_weekNumberStartGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getWinPercentage(year, weekNumberStart=2) @@ -940,8 +1132,12 @@ def test_getWinPercentage_weekNumberStartGiven(self): def test_getWinPercentage_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -954,7 +1150,9 @@ def test_getWinPercentage_weekNumberEndGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getWinPercentage(year, weekNumberEnd=2) @@ -966,8 +1164,12 @@ def test_getWinPercentage_weekNumberEndGiven(self): def test_getWinPercentage_weekNumberStartGivenAndWeekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -988,7 +1190,11 @@ def test_getWinPercentage_weekNumberStartGivenAndWeekNumberEndGiven(self): week3 = Week(weekNumber=3, matchups=[matchup3]) week4 = Week(weekNumber=4, matchups=[matchup4]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3, week4]) + year = Year( + yearNumber=2000, + teams=[teams[0], teams[1]], + weeks=[week1, week2, week3, week4], + ) response = GameOutcomeYearCalculator.getWinPercentage( year, weekNumberStart=2, weekNumberEnd=3 @@ -1002,7 +1208,9 @@ def test_getWinPercentage_weekNumberStartGivenAndWeekNumberEndGiven(self): def test_getWAL_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -1022,7 +1230,9 @@ def test_getWAL_happyPath(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getWAL(year) @@ -1034,9 +1244,15 @@ def test_getWAL_happyPath(self): def test_getWAL_leagueMedianGamesIsTrue_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -1078,7 +1294,9 @@ def test_getWAL_multiWeekMatchups(self): ) week2 = Week(weekNumber=2, matchups=[matchup2]) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week3 = Week(weekNumber=3, matchups=[matchup3]) year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) @@ -1093,8 +1311,12 @@ def test_getWAL_multiWeekMatchups(self): def test_getWAL_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -1112,7 +1334,9 @@ def test_getWAL_noneIfNoGamesPlayed(self): def test_getWAL_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -1132,7 +1356,9 @@ def test_getWAL_onlyPostSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getWAL(year, onlyPostSeason=True) @@ -1144,8 +1370,12 @@ def test_getWAL_onlyPostSeasonIsTrue(self): def test_getWAL_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -1158,7 +1388,9 @@ def test_getWAL_onlyRegularSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getWAL(year, onlyRegularSeason=True) @@ -1170,7 +1402,9 @@ def test_getWAL_onlyRegularSeasonIsTrue(self): def test_getWAL_onlyChampionshipIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -1190,7 +1424,9 @@ def test_getWAL_onlyChampionshipIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getWAL(year, onlyChampionship=True) @@ -1202,8 +1438,12 @@ def test_getWAL_onlyChampionshipIsTrue(self): def test_getWAL_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -1216,7 +1456,9 @@ def test_getWAL_weekNumberStartGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getWAL(year, weekNumberStart=2) @@ -1228,8 +1470,12 @@ def test_getWAL_weekNumberStartGiven(self): def test_getWAL_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -1242,7 +1488,9 @@ def test_getWAL_weekNumberEndGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getWAL(year, weekNumberEnd=2) @@ -1254,8 +1502,12 @@ def test_getWAL_weekNumberEndGiven(self): def test_getWAL_weekNumberStartGivenAndWeekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -1276,9 +1528,15 @@ def test_getWAL_weekNumberStartGivenAndWeekNumberEndGiven(self): week3 = Week(weekNumber=3, matchups=[matchup3]) week4 = Week(weekNumber=4, matchups=[matchup4]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3, week4]) + year = Year( + yearNumber=2000, + teams=[teams[0], teams[1]], + weeks=[week1, week2, week3, week4], + ) - response = GameOutcomeYearCalculator.getWAL(year, weekNumberStart=2, weekNumberEnd=3) + response = GameOutcomeYearCalculator.getWAL( + year, weekNumberStart=2, weekNumberEnd=3 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -1288,7 +1546,9 @@ def test_getWAL_weekNumberStartGivenAndWeekNumberEndGiven(self): def test_getWALPerGame_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -1308,7 +1568,9 @@ def test_getWALPerGame_happyPath(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getWALPerGame(year) @@ -1320,9 +1582,15 @@ def test_getWALPerGame_happyPath(self): def test_getWALPerGame_leagueMedianGamesIsOn_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -1330,7 +1598,10 @@ def test_getWALPerGame_leagueMedianGamesIsOn_happyPath(self): yearSettings = YearSettings(leagueMedianGames=True) year = Year( - yearNumber=2000, teams=teams, weeks=[week1, week2, week3], yearSettings=yearSettings + yearNumber=2000, + teams=teams, + weeks=[week1, week2, week3], + yearSettings=yearSettings, ) response = GameOutcomeYearCalculator.getWALPerGame(year) @@ -1361,7 +1632,9 @@ def test_getWALPerGame_multiWeekMatchups(self): ) week2 = Week(weekNumber=2, matchups=[matchup2]) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week3 = Week(weekNumber=3, matchups=[matchup3]) year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) @@ -1376,8 +1649,12 @@ def test_getWALPerGame_multiWeekMatchups(self): def test_getWALPerGame_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -1395,7 +1672,9 @@ def test_getWALPerGame_noneIfNoGamesPlayed(self): def test_getWALPerGame_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -1415,7 +1694,9 @@ def test_getWALPerGame_onlyPostSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getWALPerGame(year, onlyPostSeason=True) @@ -1427,8 +1708,12 @@ def test_getWALPerGame_onlyPostSeasonIsTrue(self): def test_getWALPerGame_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -1441,7 +1726,9 @@ def test_getWALPerGame_onlyRegularSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getWALPerGame(year, onlyRegularSeason=True) @@ -1453,7 +1740,9 @@ def test_getWALPerGame_onlyRegularSeasonIsTrue(self): def test_getWALPerGame_onlyChampionshipIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -1473,7 +1762,9 @@ def test_getWALPerGame_onlyChampionshipIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getWALPerGame(year, onlyChampionship=True) @@ -1485,8 +1776,12 @@ def test_getWALPerGame_onlyChampionshipIsTrue(self): def test_getWALPerGame_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -1499,7 +1794,9 @@ def test_getWALPerGame_weekNumberStartGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getWALPerGame(year, weekNumberStart=2) @@ -1511,8 +1808,12 @@ def test_getWALPerGame_weekNumberStartGiven(self): def test_getWALPerGame_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -1525,7 +1826,9 @@ def test_getWALPerGame_weekNumberEndGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = GameOutcomeYearCalculator.getWALPerGame(year, weekNumberEnd=2) @@ -1537,8 +1840,12 @@ def test_getWALPerGame_weekNumberEndGiven(self): def test_getWALPerGame_weekNumberStartGivenAndWeekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -1559,9 +1866,15 @@ def test_getWALPerGame_weekNumberStartGivenAndWeekNumberEndGiven(self): week3 = Week(weekNumber=3, matchups=[matchup3]) week4 = Week(weekNumber=4, matchups=[matchup4]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3, week4]) + year = Year( + yearNumber=2000, + teams=[teams[0], teams[1]], + weeks=[week1, week2, week3, week4], + ) - response = GameOutcomeYearCalculator.getWALPerGame(year, weekNumberStart=2, weekNumberEnd=3) + response = GameOutcomeYearCalculator.getWALPerGame( + year, weekNumberStart=2, weekNumberEnd=3 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -1571,13 +1884,19 @@ def test_getWALPerGame_weekNumberStartGivenAndWeekNumberEndGiven(self): def test_getLeagueMedianWins_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(4) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2]) yearSettings = YearSettings(leagueMedianGames=True) - year = Year(yearNumber=2000, teams=teams, weeks=[week1], yearSettings=yearSettings) + year = Year( + yearNumber=2000, teams=teams, weeks=[week1], yearSettings=yearSettings + ) response = GameOutcomeYearCalculator.getLeagueMedianWins(year) @@ -1588,16 +1907,24 @@ def test_getLeagueMedianWins_happyPath(self): self.assertEqual(1, response[teams[2].id]) self.assertEqual(1, response[teams[3].id]) - def test_getLeagueMedianWins_yearHasLeagueMedianGamesOff_returnsZeroForEachTeam(self): + def test_getLeagueMedianWins_yearHasLeagueMedianGamesOff_returnsZeroForEachTeam( + self, + ): owners, teams = getNDefaultOwnersAndTeams(4) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2]) yearSettings = YearSettings(leagueMedianGames=False) - year = Year(yearNumber=2000, teams=teams, weeks=[week1], yearSettings=yearSettings) + year = Year( + yearNumber=2000, teams=teams, weeks=[week1], yearSettings=yearSettings + ) response = GameOutcomeYearCalculator.getLeagueMedianWins(year) @@ -1611,13 +1938,19 @@ def test_getLeagueMedianWins_yearHasLeagueMedianGamesOff_returnsZeroForEachTeam( def test_getLeagueMedianWinsTieForLeagueMedian_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(4) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=2, teamBScore=4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=2, teamBScore=4 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2]) yearSettings = YearSettings(leagueMedianGames=True) - year = Year(yearNumber=2000, teams=teams, weeks=[week1], yearSettings=yearSettings) + year = Year( + yearNumber=2000, teams=teams, weeks=[week1], yearSettings=yearSettings + ) response = GameOutcomeYearCalculator.getLeagueMedianWins(year) @@ -1631,14 +1964,23 @@ def test_getLeagueMedianWinsTieForLeagueMedian_happyPath(self): def test_getLeagueMedianWins_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) yearSettings = YearSettings(leagueMedianGames=True) - year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2], yearSettings=yearSettings) + year = Year( + yearNumber=2000, + teams=teams, + weeks=[week1, week2], + yearSettings=yearSettings, + ) response = GameOutcomeYearCalculator.getLeagueMedianWins(year, weekNumberEnd=1) @@ -1651,7 +1993,9 @@ def test_getLeagueMedianWins_noneIfNoGamesPlayed(self): def test_getLeagueMedianWins_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -1673,7 +2017,9 @@ def test_getLeagueMedianWins_onlyPostSeasonIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = GameOutcomeYearCalculator.getLeagueMedianWins(year, onlyPostSeason=True) + response = GameOutcomeYearCalculator.getLeagueMedianWins( + year, onlyPostSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -1683,8 +2029,12 @@ def test_getLeagueMedianWins_onlyPostSeasonIsTrue(self): def test_getLeagueMedianWins_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -1699,10 +2049,15 @@ def test_getLeagueMedianWins_onlyRegularSeasonIsTrue(self): yearSettings = YearSettings(leagueMedianGames=True) year = Year( - yearNumber=2000, teams=teams, weeks=[week1, week2, week3], yearSettings=yearSettings + yearNumber=2000, + teams=teams, + weeks=[week1, week2, week3], + yearSettings=yearSettings, ) - response = GameOutcomeYearCalculator.getLeagueMedianWins(year, onlyRegularSeason=True) + response = GameOutcomeYearCalculator.getLeagueMedianWins( + year, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -1712,7 +2067,9 @@ def test_getLeagueMedianWins_onlyRegularSeasonIsTrue(self): def test_getLeagueMedianWins_onlyChampionshipIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -1734,7 +2091,9 @@ def test_getLeagueMedianWins_onlyChampionshipIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = GameOutcomeYearCalculator.getLeagueMedianWins(year, onlyChampionship=True) + response = GameOutcomeYearCalculator.getLeagueMedianWins( + year, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -1744,9 +2103,15 @@ def test_getLeagueMedianWins_onlyChampionshipIsTrue(self): def test_getLeagueMedianWins_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -1754,10 +2119,15 @@ def test_getLeagueMedianWins_weekNumberStartGiven(self): yearSettings = YearSettings(leagueMedianGames=True) year = Year( - yearNumber=2000, teams=teams, weeks=[week1, week2, week3], yearSettings=yearSettings + yearNumber=2000, + teams=teams, + weeks=[week1, week2, week3], + yearSettings=yearSettings, ) - response = GameOutcomeYearCalculator.getLeagueMedianWins(year, weekNumberStart=2) + response = GameOutcomeYearCalculator.getLeagueMedianWins( + year, weekNumberStart=2 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -1767,9 +2137,15 @@ def test_getLeagueMedianWins_weekNumberStartGiven(self): def test_getLeagueMedianWins_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -1777,7 +2153,10 @@ def test_getLeagueMedianWins_weekNumberEndGiven(self): yearSettings = YearSettings(leagueMedianGames=True) year = Year( - yearNumber=2000, teams=teams, weeks=[week1, week2, week3], yearSettings=yearSettings + yearNumber=2000, + teams=teams, + weeks=[week1, week2, week3], + yearSettings=yearSettings, ) response = GameOutcomeYearCalculator.getLeagueMedianWins(year, weekNumberEnd=2) @@ -1790,10 +2169,18 @@ def test_getLeagueMedianWins_weekNumberEndGiven(self): def test_getLeagueMedianWins_weekNumberStartGivenAndWeekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1) - matchup4 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1 + ) + matchup4 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -1820,13 +2207,19 @@ def test_getLeagueMedianWins_weekNumberStartGivenAndWeekNumberEndGiven(self): def test_getOpponentLeagueMedianWins_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(4) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2]) yearSettings = YearSettings(leagueMedianGames=True) - year = Year(yearNumber=2000, teams=teams, weeks=[week1], yearSettings=yearSettings) + year = Year( + yearNumber=2000, teams=teams, weeks=[week1], yearSettings=yearSettings + ) response = GameOutcomeYearCalculator.getOpponentLeagueMedianWins(year) @@ -1837,16 +2230,24 @@ def test_getOpponentLeagueMedianWins_happyPath(self): self.assertEqual(1, response[teams[2].id]) self.assertEqual(1, response[teams[3].id]) - def test_getOpponentLeagueMedianWins_yearHasLeagueMedianGamesOff_returnsZeroForEachTeam(self): + def test_getOpponentLeagueMedianWins_yearHasLeagueMedianGamesOff_returnsZeroForEachTeam( + self, + ): owners, teams = getNDefaultOwnersAndTeams(4) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2]) yearSettings = YearSettings(leagueMedianGames=False) - year = Year(yearNumber=2000, teams=teams, weeks=[week1], yearSettings=yearSettings) + year = Year( + yearNumber=2000, teams=teams, weeks=[week1], yearSettings=yearSettings + ) response = GameOutcomeYearCalculator.getOpponentLeagueMedianWins(year) @@ -1860,13 +2261,19 @@ def test_getOpponentLeagueMedianWins_yearHasLeagueMedianGamesOff_returnsZeroForE def test_getOpponentLeagueMedianWinsTieForLeagueMedian_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(4) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=2, teamBScore=4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=2, teamBScore=4 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2]) yearSettings = YearSettings(leagueMedianGames=True) - year = Year(yearNumber=2000, teams=teams, weeks=[week1], yearSettings=yearSettings) + year = Year( + yearNumber=2000, teams=teams, weeks=[week1], yearSettings=yearSettings + ) response = GameOutcomeYearCalculator.getOpponentLeagueMedianWins(year) @@ -1880,16 +2287,27 @@ def test_getOpponentLeagueMedianWinsTieForLeagueMedian_happyPath(self): def test_getOpponentLeagueMedianWins_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) yearSettings = YearSettings(leagueMedianGames=True) - year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2], yearSettings=yearSettings) + year = Year( + yearNumber=2000, + teams=teams, + weeks=[week1, week2], + yearSettings=yearSettings, + ) - response = GameOutcomeYearCalculator.getOpponentLeagueMedianWins(year, weekNumberEnd=1) + response = GameOutcomeYearCalculator.getOpponentLeagueMedianWins( + year, weekNumberEnd=1 + ) self.assertIsInstance(response, dict) self.assertEqual(3, len(response.keys())) @@ -1900,7 +2318,9 @@ def test_getOpponentLeagueMedianWins_noneIfNoGamesPlayed(self): def test_getOpponentLeagueMedianWins_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -1922,7 +2342,9 @@ def test_getOpponentLeagueMedianWins_onlyPostSeasonIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = GameOutcomeYearCalculator.getOpponentLeagueMedianWins(year, onlyPostSeason=True) + response = GameOutcomeYearCalculator.getOpponentLeagueMedianWins( + year, onlyPostSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -1932,8 +2354,12 @@ def test_getOpponentLeagueMedianWins_onlyPostSeasonIsTrue(self): def test_getOpponentLeagueMedianWins_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -1948,7 +2374,10 @@ def test_getOpponentLeagueMedianWins_onlyRegularSeasonIsTrue(self): yearSettings = YearSettings(leagueMedianGames=True) year = Year( - yearNumber=2000, teams=teams, weeks=[week1, week2, week3], yearSettings=yearSettings + yearNumber=2000, + teams=teams, + weeks=[week1, week2, week3], + yearSettings=yearSettings, ) response = GameOutcomeYearCalculator.getOpponentLeagueMedianWins( @@ -1963,7 +2392,9 @@ def test_getOpponentLeagueMedianWins_onlyRegularSeasonIsTrue(self): def test_getOpponentLeagueMedianWins_onlyChampionshipIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -1997,9 +2428,15 @@ def test_getOpponentLeagueMedianWins_onlyChampionshipIsTrue(self): def test_getOpponentLeagueMedianWins_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -2007,10 +2444,15 @@ def test_getOpponentLeagueMedianWins_weekNumberStartGiven(self): yearSettings = YearSettings(leagueMedianGames=True) year = Year( - yearNumber=2000, teams=teams, weeks=[week1, week2, week3], yearSettings=yearSettings + yearNumber=2000, + teams=teams, + weeks=[week1, week2, week3], + yearSettings=yearSettings, ) - response = GameOutcomeYearCalculator.getOpponentLeagueMedianWins(year, weekNumberStart=2) + response = GameOutcomeYearCalculator.getOpponentLeagueMedianWins( + year, weekNumberStart=2 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -2020,9 +2462,15 @@ def test_getOpponentLeagueMedianWins_weekNumberStartGiven(self): def test_getOpponentLeagueMedianWins_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -2030,23 +2478,38 @@ def test_getOpponentLeagueMedianWins_weekNumberEndGiven(self): yearSettings = YearSettings(leagueMedianGames=True) year = Year( - yearNumber=2000, teams=teams, weeks=[week1, week2, week3], yearSettings=yearSettings + yearNumber=2000, + teams=teams, + weeks=[week1, week2, week3], + yearSettings=yearSettings, ) - response = GameOutcomeYearCalculator.getOpponentLeagueMedianWins(year, weekNumberEnd=2) + response = GameOutcomeYearCalculator.getOpponentLeagueMedianWins( + year, weekNumberEnd=2 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) self.assertEqual(2, response[teams[0].id]) self.assertEqual(0, response[teams[1].id]) - def test_getOpponentLeagueMedianWins_weekNumberStartGivenAndWeekNumberEndGiven(self): + def test_getOpponentLeagueMedianWins_weekNumberStartGivenAndWeekNumberEndGiven( + self, + ): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1) - matchup4 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1 + ) + matchup4 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) diff --git a/test/test_calculator/test_year_calculator/test_PlusMinusYearCalculator.py b/test/test_calculator/test_year_calculator/test_PlusMinusYearCalculator.py index 3f3c4fe2..41ee6038 100644 --- a/test/test_calculator/test_year_calculator/test_PlusMinusYearCalculator.py +++ b/test/test_calculator/test_year_calculator/test_PlusMinusYearCalculator.py @@ -1,19 +1,23 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams -from leeger.calculator.year_calculator.PlusMinusYearCalculator import PlusMinusYearCalculator +from leeger.calculator.year_calculator.PlusMinusYearCalculator import ( + PlusMinusYearCalculator, +) from leeger.enum.MatchupType import MatchupType from leeger.model.league.Matchup import Matchup from leeger.model.league.Week import Week from leeger.model.league.Year import Year from leeger.util.Deci import Deci +from test.helper.prototypes import getNDefaultOwnersAndTeams class TestPlusMinusYearCalculator(unittest.TestCase): def test_getPlusMinus_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -33,7 +37,9 @@ def test_getPlusMinus_happyPath(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = PlusMinusYearCalculator.getPlusMinus(year) @@ -45,8 +51,12 @@ def test_getPlusMinus_happyPath(self): def test_getPlusMinus_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=2.5 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -63,7 +73,9 @@ def test_getPlusMinus_noneIfNoGamesPlayed(self): def test_getPlusMinus_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -83,7 +95,9 @@ def test_getPlusMinus_onlyPostSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = PlusMinusYearCalculator.getPlusMinus(year, onlyPostSeason=True) @@ -95,8 +109,12 @@ def test_getPlusMinus_onlyPostSeasonIsTrue(self): def test_getPlusMinus_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -109,7 +127,9 @@ def test_getPlusMinus_onlyRegularSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = PlusMinusYearCalculator.getPlusMinus(year, onlyRegularSeason=True) @@ -121,7 +141,9 @@ def test_getPlusMinus_onlyRegularSeasonIsTrue(self): def test_getPlusMinus_onlyChampionshipIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -141,7 +163,9 @@ def test_getPlusMinus_onlyChampionshipIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = PlusMinusYearCalculator.getPlusMinus(year, onlyChampionship=True) @@ -153,8 +177,12 @@ def test_getPlusMinus_onlyChampionshipIsTrue(self): def test_getPlusMinus_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -167,7 +195,9 @@ def test_getPlusMinus_weekNumberStartGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = PlusMinusYearCalculator.getPlusMinus(year, weekNumberStart=2) @@ -179,8 +209,12 @@ def test_getPlusMinus_weekNumberStartGiven(self): def test_getPlusMinus_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -193,7 +227,9 @@ def test_getPlusMinus_weekNumberEndGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = PlusMinusYearCalculator.getPlusMinus(year, weekNumberEnd=2) @@ -205,8 +241,12 @@ def test_getPlusMinus_weekNumberEndGiven(self): def test_getPlusMinus_weekNumberStartGivenAndWeekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -227,9 +267,15 @@ def test_getPlusMinus_weekNumberStartGivenAndWeekNumberEndGiven(self): week3 = Week(weekNumber=3, matchups=[matchup3]) week4 = Week(weekNumber=4, matchups=[matchup4]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3, week4]) + year = Year( + yearNumber=2000, + teams=[teams[0], teams[1]], + weeks=[week1, week2, week3, week4], + ) - response = PlusMinusYearCalculator.getPlusMinus(year, weekNumberStart=2, weekNumberEnd=3) + response = PlusMinusYearCalculator.getPlusMinus( + year, weekNumberStart=2, weekNumberEnd=3 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) diff --git a/test/test_calculator/test_year_calculator/test_PointsScoredYearCalculator.py b/test/test_calculator/test_year_calculator/test_PointsScoredYearCalculator.py index 19522709..02dcb39b 100644 --- a/test/test_calculator/test_year_calculator/test_PointsScoredYearCalculator.py +++ b/test/test_calculator/test_year_calculator/test_PointsScoredYearCalculator.py @@ -1,19 +1,23 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams -from leeger.calculator.year_calculator.PointsScoredYearCalculator import PointsScoredYearCalculator +from leeger.calculator.year_calculator.PointsScoredYearCalculator import ( + PointsScoredYearCalculator, +) from leeger.enum.MatchupType import MatchupType from leeger.model.league.Matchup import Matchup from leeger.model.league.Week import Week from leeger.model.league.Year import Year from leeger.util.Deci import Deci +from test.helper.prototypes import getNDefaultOwnersAndTeams class TestPointsScoredYearCalculator(unittest.TestCase): def test_getPointsScored_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -33,7 +37,9 @@ def test_getPointsScored_happyPath(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = PointsScoredYearCalculator.getPointsScored(year) @@ -45,8 +51,12 @@ def test_getPointsScored_happyPath(self): def test_getPointsScored_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=2.5 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -63,7 +73,9 @@ def test_getPointsScored_noneIfNoGamesPlayed(self): def test_getPointsScored_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -83,7 +95,9 @@ def test_getPointsScored_onlyPostSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = PointsScoredYearCalculator.getPointsScored(year, onlyPostSeason=True) @@ -95,8 +109,12 @@ def test_getPointsScored_onlyPostSeasonIsTrue(self): def test_getPointsScored_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -109,9 +127,13 @@ def test_getPointsScored_onlyRegularSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) - response = PointsScoredYearCalculator.getPointsScored(year, onlyRegularSeason=True) + response = PointsScoredYearCalculator.getPointsScored( + year, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -121,7 +143,9 @@ def test_getPointsScored_onlyRegularSeasonIsTrue(self): def test_getPointsScored_onlyChampionshipIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -143,7 +167,9 @@ def test_getPointsScored_onlyChampionshipIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = PointsScoredYearCalculator.getPointsScored(year, onlyChampionship=True) + response = PointsScoredYearCalculator.getPointsScored( + year, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -153,8 +179,12 @@ def test_getPointsScored_onlyChampionshipIsTrue(self): def test_getPointsScored_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -167,7 +197,9 @@ def test_getPointsScored_weekNumberStartGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = PointsScoredYearCalculator.getPointsScored(year, weekNumberStart=2) @@ -179,8 +211,12 @@ def test_getPointsScored_weekNumberStartGiven(self): def test_getPointsScored_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -193,7 +229,9 @@ def test_getPointsScored_weekNumberEndGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = PointsScoredYearCalculator.getPointsScored(year, weekNumberEnd=2) @@ -205,8 +243,12 @@ def test_getPointsScored_weekNumberEndGiven(self): def test_getPointsScored_weekNumberStartGivenAndWeekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -227,7 +269,11 @@ def test_getPointsScored_weekNumberStartGivenAndWeekNumberEndGiven(self): week3 = Week(weekNumber=3, matchups=[matchup3]) week4 = Week(weekNumber=4, matchups=[matchup4]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3, week4]) + year = Year( + yearNumber=2000, + teams=[teams[0], teams[1]], + weeks=[week1, week2, week3, week4], + ) response = PointsScoredYearCalculator.getPointsScored( year, weekNumberStart=2, weekNumberEnd=3 @@ -241,7 +287,9 @@ def test_getPointsScored_weekNumberStartGivenAndWeekNumberEndGiven(self): def test_getPointsScoredPerGame_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -261,7 +309,9 @@ def test_getPointsScoredPerGame_happyPath(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = PointsScoredYearCalculator.getPointsScoredPerGame(year) @@ -273,14 +323,20 @@ def test_getPointsScoredPerGame_happyPath(self): def test_getPointsScoredPerGame_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=2.5 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2]) - response = PointsScoredYearCalculator.getPointsScoredPerGame(year, weekNumberEnd=1) + response = PointsScoredYearCalculator.getPointsScoredPerGame( + year, weekNumberEnd=1 + ) self.assertIsInstance(response, dict) self.assertEqual(3, len(response.keys())) @@ -291,7 +347,9 @@ def test_getPointsScoredPerGame_noneIfNoGamesPlayed(self): def test_getPointsScoredPerGame_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -311,9 +369,13 @@ def test_getPointsScoredPerGame_onlyPostSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) - response = PointsScoredYearCalculator.getPointsScoredPerGame(year, onlyPostSeason=True) + response = PointsScoredYearCalculator.getPointsScoredPerGame( + year, onlyPostSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -323,8 +385,12 @@ def test_getPointsScoredPerGame_onlyPostSeasonIsTrue(self): def test_getPointsScoredPerGame_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -337,9 +403,13 @@ def test_getPointsScoredPerGame_onlyRegularSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) - response = PointsScoredYearCalculator.getPointsScoredPerGame(year, onlyRegularSeason=True) + response = PointsScoredYearCalculator.getPointsScoredPerGame( + year, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -349,7 +419,9 @@ def test_getPointsScoredPerGame_onlyRegularSeasonIsTrue(self): def test_getPointsScoredPerGame_onlyChampionshipIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(4) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -378,7 +450,9 @@ def test_getPointsScoredPerGame_onlyChampionshipIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = PointsScoredYearCalculator.getPointsScoredPerGame(year, onlyChampionship=True) + response = PointsScoredYearCalculator.getPointsScoredPerGame( + year, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(4, len(response.keys())) @@ -390,8 +464,12 @@ def test_getPointsScoredPerGame_onlyChampionshipIsTrue(self): def test_getPointsScoredPerGame_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -404,9 +482,13 @@ def test_getPointsScoredPerGame_weekNumberStartGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) - response = PointsScoredYearCalculator.getPointsScoredPerGame(year, weekNumberStart=2) + response = PointsScoredYearCalculator.getPointsScoredPerGame( + year, weekNumberStart=2 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -416,8 +498,12 @@ def test_getPointsScoredPerGame_weekNumberStartGiven(self): def test_getPointsScoredPerGame_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -430,9 +516,13 @@ def test_getPointsScoredPerGame_weekNumberEndGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) - response = PointsScoredYearCalculator.getPointsScoredPerGame(year, weekNumberEnd=2) + response = PointsScoredYearCalculator.getPointsScoredPerGame( + year, weekNumberEnd=2 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -442,8 +532,12 @@ def test_getPointsScoredPerGame_weekNumberEndGiven(self): def test_getPointsScoredPerGame_weekNumberStartGivenAndWeekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -464,7 +558,11 @@ def test_getPointsScoredPerGame_weekNumberStartGivenAndWeekNumberEndGiven(self): week3 = Week(weekNumber=3, matchups=[matchup3]) week4 = Week(weekNumber=4, matchups=[matchup4]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3, week4]) + year = Year( + yearNumber=2000, + teams=[teams[0], teams[1]], + weeks=[week1, week2, week3, week4], + ) response = PointsScoredYearCalculator.getPointsScoredPerGame( year, weekNumberStart=2, weekNumberEnd=3 @@ -478,7 +576,9 @@ def test_getPointsScoredPerGame_weekNumberStartGivenAndWeekNumberEndGiven(self): def test_getOpponentPointsScored_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -498,7 +598,9 @@ def test_getOpponentPointsScored_happyPath(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = PointsScoredYearCalculator.getOpponentPointsScored(year) @@ -510,14 +612,20 @@ def test_getOpponentPointsScored_happyPath(self): def test_getOpponentPointsScored_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=2.5 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2]) - response = PointsScoredYearCalculator.getOpponentPointsScored(year, weekNumberEnd=1) + response = PointsScoredYearCalculator.getOpponentPointsScored( + year, weekNumberEnd=1 + ) self.assertIsInstance(response, dict) self.assertEqual(3, len(response.keys())) @@ -528,7 +636,9 @@ def test_getOpponentPointsScored_noneIfNoGamesPlayed(self): def test_getOpponentPointsScored_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -548,9 +658,13 @@ def test_getOpponentPointsScored_onlyPostSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) - response = PointsScoredYearCalculator.getOpponentPointsScored(year, onlyPostSeason=True) + response = PointsScoredYearCalculator.getOpponentPointsScored( + year, onlyPostSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -560,8 +674,12 @@ def test_getOpponentPointsScored_onlyPostSeasonIsTrue(self): def test_getOpponentPointsScored_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -574,9 +692,13 @@ def test_getOpponentPointsScored_onlyRegularSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) - response = PointsScoredYearCalculator.getOpponentPointsScored(year, onlyRegularSeason=True) + response = PointsScoredYearCalculator.getOpponentPointsScored( + year, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -586,7 +708,9 @@ def test_getOpponentPointsScored_onlyRegularSeasonIsTrue(self): def test_getOpponentPointsScored_onlyChampionshipIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -606,9 +730,13 @@ def test_getOpponentPointsScored_onlyChampionshipIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) - response = PointsScoredYearCalculator.getOpponentPointsScored(year, onlyChampionship=True) + response = PointsScoredYearCalculator.getOpponentPointsScored( + year, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -618,8 +746,12 @@ def test_getOpponentPointsScored_onlyChampionshipIsTrue(self): def test_getOpponentPointsScored_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -632,9 +764,13 @@ def test_getOpponentPointsScored_weekNumberStartGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) - response = PointsScoredYearCalculator.getOpponentPointsScored(year, weekNumberStart=2) + response = PointsScoredYearCalculator.getOpponentPointsScored( + year, weekNumberStart=2 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -644,8 +780,12 @@ def test_getOpponentPointsScored_weekNumberStartGiven(self): def test_getOpponentPointsScored_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -658,9 +798,13 @@ def test_getOpponentPointsScored_weekNumberEndGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) - response = PointsScoredYearCalculator.getOpponentPointsScored(year, weekNumberEnd=2) + response = PointsScoredYearCalculator.getOpponentPointsScored( + year, weekNumberEnd=2 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -670,8 +814,12 @@ def test_getOpponentPointsScored_weekNumberEndGiven(self): def test_getOpponentPointsScored_weekNumberStartGivenAndWeekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -692,7 +840,11 @@ def test_getOpponentPointsScored_weekNumberStartGivenAndWeekNumberEndGiven(self) week3 = Week(weekNumber=3, matchups=[matchup3]) week4 = Week(weekNumber=4, matchups=[matchup4]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3, week4]) + year = Year( + yearNumber=2000, + teams=[teams[0], teams[1]], + weeks=[week1, week2, week3, week4], + ) response = PointsScoredYearCalculator.getOpponentPointsScored( year, weekNumberStart=2, weekNumberEnd=3 @@ -706,7 +858,9 @@ def test_getOpponentPointsScored_weekNumberStartGivenAndWeekNumberEndGiven(self) def test_getOpponentPointsScoredPerGame_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -726,7 +880,9 @@ def test_getOpponentPointsScoredPerGame_happyPath(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = PointsScoredYearCalculator.getOpponentPointsScoredPerGame(year) @@ -738,14 +894,20 @@ def test_getOpponentPointsScoredPerGame_happyPath(self): def test_getOpponentPointsScoredPerGame_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=2.5 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2]) - response = PointsScoredYearCalculator.getOpponentPointsScoredPerGame(year, weekNumberEnd=1) + response = PointsScoredYearCalculator.getOpponentPointsScoredPerGame( + year, weekNumberEnd=1 + ) self.assertIsInstance(response, dict) self.assertEqual(3, len(response.keys())) @@ -756,7 +918,9 @@ def test_getOpponentPointsScoredPerGame_noneIfNoGamesPlayed(self): def test_getOpponentPointsScoredPerGame_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -776,7 +940,9 @@ def test_getOpponentPointsScoredPerGame_onlyPostSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = PointsScoredYearCalculator.getOpponentPointsScoredPerGame( year, onlyPostSeason=True @@ -790,8 +956,12 @@ def test_getOpponentPointsScoredPerGame_onlyPostSeasonIsTrue(self): def test_getOpponentPointsScoredPerGame_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -804,7 +974,9 @@ def test_getOpponentPointsScoredPerGame_onlyRegularSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = PointsScoredYearCalculator.getOpponentPointsScoredPerGame( year, onlyRegularSeason=True @@ -818,7 +990,9 @@ def test_getOpponentPointsScoredPerGame_onlyRegularSeasonIsTrue(self): def test_getOpponentPointsScoredPerGame_onlyChampionshipIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(4) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -861,8 +1035,12 @@ def test_getOpponentPointsScoredPerGame_onlyChampionshipIsTrue(self): def test_getOpponentPointsScoredPerGame_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -875,7 +1053,9 @@ def test_getOpponentPointsScoredPerGame_weekNumberStartGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = PointsScoredYearCalculator.getOpponentPointsScoredPerGame( year, weekNumberStart=2 @@ -889,8 +1069,12 @@ def test_getOpponentPointsScoredPerGame_weekNumberStartGiven(self): def test_getOpponentPointsScoredPerGame_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -903,20 +1087,30 @@ def test_getOpponentPointsScoredPerGame_weekNumberEndGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) - response = PointsScoredYearCalculator.getOpponentPointsScoredPerGame(year, weekNumberEnd=2) + response = PointsScoredYearCalculator.getOpponentPointsScoredPerGame( + year, weekNumberEnd=2 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) self.assertEqual(Deci("2.45"), response[teams[0].id]) self.assertEqual(Deci("1.15"), response[teams[1].id]) - def test_getOpponentPointsScoredPerGame_weekNumberStartGivenAndWeekNumberEndGiven(self): + def test_getOpponentPointsScoredPerGame_weekNumberStartGivenAndWeekNumberEndGiven( + self, + ): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -937,7 +1131,11 @@ def test_getOpponentPointsScoredPerGame_weekNumberStartGivenAndWeekNumberEndGive week3 = Week(weekNumber=3, matchups=[matchup3]) week4 = Week(weekNumber=4, matchups=[matchup4]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3, week4]) + year = Year( + yearNumber=2000, + teams=[teams[0], teams[1]], + weeks=[week1, week2, week3, week4], + ) response = PointsScoredYearCalculator.getOpponentPointsScoredPerGame( year, weekNumberStart=2, weekNumberEnd=3 diff --git a/test/test_calculator/test_year_calculator/test_SSLYearCalculator.py b/test/test_calculator/test_year_calculator/test_SSLYearCalculator.py index 615f5727..a318c8f5 100644 --- a/test/test_calculator/test_year_calculator/test_SSLYearCalculator.py +++ b/test/test_calculator/test_year_calculator/test_SSLYearCalculator.py @@ -1,5 +1,4 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams from leeger.calculator.year_calculator.SSLYearCalculator import SSLYearCalculator from leeger.enum.MatchupType import MatchupType @@ -7,13 +6,16 @@ from leeger.model.league.Week import Week from leeger.model.league.Year import Year from leeger.util.Deci import Deci +from test.helper.prototypes import getNDefaultOwnersAndTeams class TestSSLYearCalculator(unittest.TestCase): def test_getTeamScore_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=3) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=3 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -45,8 +47,12 @@ def test_getTeamScore_happyPath(self): def test_getTeamScore_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=3) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=3) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=3 + ) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=3 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -63,7 +69,9 @@ def test_getTeamScore_noneIfNoGamesPlayed(self): def test_getTeamScore_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=5, teamBScore=4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=5, teamBScore=4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -83,7 +91,9 @@ def test_getTeamScore_onlyPostSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = SSLYearCalculator.getTeamScore(year, onlyPostSeason=True) @@ -95,8 +105,12 @@ def test_getTeamScore_onlyPostSeasonIsTrue(self): def test_getTeamScore_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -109,7 +123,9 @@ def test_getTeamScore_onlyRegularSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = SSLYearCalculator.getTeamScore(year, onlyRegularSeason=True) @@ -161,8 +177,12 @@ def test_getTeamScore_onlyChampionshipIsTrue(self): def test_getTeamScore_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=3, teamBScore=6) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=3, teamBScore=6 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -175,7 +195,9 @@ def test_getTeamScore_weekNumberStartGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = SSLYearCalculator.getTeamScore(year, weekNumberStart=2) @@ -187,8 +209,12 @@ def test_getTeamScore_weekNumberStartGiven(self): def test_getTeamScore_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -201,7 +227,9 @@ def test_getTeamScore_weekNumberEndGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = SSLYearCalculator.getTeamScore(year, weekNumberEnd=2) @@ -213,8 +241,12 @@ def test_getTeamScore_weekNumberEndGiven(self): def test_getTeamScore_weekNumberStartGivenAndWeekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -235,9 +267,15 @@ def test_getTeamScore_weekNumberStartGivenAndWeekNumberEndGiven(self): week3 = Week(weekNumber=3, matchups=[matchup3]) week4 = Week(weekNumber=4, matchups=[matchup4]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3, week4]) + year = Year( + yearNumber=2000, + teams=[teams[0], teams[1]], + weeks=[week1, week2, week3, week4], + ) - response = SSLYearCalculator.getTeamScore(year, weekNumberStart=2, weekNumberEnd=3) + response = SSLYearCalculator.getTeamScore( + year, weekNumberStart=2, weekNumberEnd=3 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -247,7 +285,9 @@ def test_getTeamScore_weekNumberStartGivenAndWeekNumberEndGiven(self): def test_getTeamSuccess_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=3) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=3 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -279,8 +319,12 @@ def test_getTeamSuccess_happyPath(self): def test_getTeamSuccess_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=3) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=3) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=3 + ) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=3 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -297,7 +341,9 @@ def test_getTeamSuccess_noneIfNoGamesPlayed(self): def test_getTeamSuccess_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=5, teamBScore=4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=5, teamBScore=4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -317,7 +363,9 @@ def test_getTeamSuccess_onlyPostSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = SSLYearCalculator.getTeamSuccess(year, onlyPostSeason=True) @@ -329,8 +377,12 @@ def test_getTeamSuccess_onlyPostSeasonIsTrue(self): def test_getTeamSuccess_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -343,7 +395,9 @@ def test_getTeamSuccess_onlyRegularSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = SSLYearCalculator.getTeamSuccess(year, onlyRegularSeason=True) @@ -395,8 +449,12 @@ def test_getTeamSuccess_onlyChampionshipIsTrue(self): def test_getTeamSuccess_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=3, teamBScore=6) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=3, teamBScore=6 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -409,7 +467,9 @@ def test_getTeamSuccess_weekNumberStartGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = SSLYearCalculator.getTeamSuccess(year, weekNumberStart=2) @@ -421,8 +481,12 @@ def test_getTeamSuccess_weekNumberStartGiven(self): def test_getTeamSuccess_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -435,7 +499,9 @@ def test_getTeamSuccess_weekNumberEndGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = SSLYearCalculator.getTeamSuccess(year, weekNumberEnd=2) @@ -447,8 +513,12 @@ def test_getTeamSuccess_weekNumberEndGiven(self): def test_getTeamSuccess_weekNumberStartGivenAndWeekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -469,9 +539,15 @@ def test_getTeamSuccess_weekNumberStartGivenAndWeekNumberEndGiven(self): week3 = Week(weekNumber=3, matchups=[matchup3]) week4 = Week(weekNumber=4, matchups=[matchup4]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3, week4]) + year = Year( + yearNumber=2000, + teams=[teams[0], teams[1]], + weeks=[week1, week2, week3, week4], + ) - response = SSLYearCalculator.getTeamSuccess(year, weekNumberStart=2, weekNumberEnd=3) + response = SSLYearCalculator.getTeamSuccess( + year, weekNumberStart=2, weekNumberEnd=3 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -481,7 +557,9 @@ def test_getTeamSuccess_weekNumberStartGivenAndWeekNumberEndGiven(self): def test_getTeamLuck_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=3) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=3 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -513,8 +591,12 @@ def test_getTeamLuck_happyPath(self): def test_getTeamLuck_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=3) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=3) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=3 + ) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=3 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -531,8 +613,12 @@ def test_getTeamLuck_noneIfNoGamesPlayed(self): def test_getTeamLuck_sumOfLeagueEqualsZero(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=3) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=3) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=3 + ) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=3 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -545,7 +631,9 @@ def test_getTeamLuck_sumOfLeagueEqualsZero(self): def test_getTeamLuck_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=5, teamBScore=4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=5, teamBScore=4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -565,7 +653,9 @@ def test_getTeamLuck_onlyPostSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = SSLYearCalculator.getTeamLuck(year, onlyPostSeason=True) @@ -577,8 +667,12 @@ def test_getTeamLuck_onlyPostSeasonIsTrue(self): def test_getTeamLuck_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -591,7 +685,9 @@ def test_getTeamLuck_onlyRegularSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = SSLYearCalculator.getTeamLuck(year, onlyRegularSeason=True) @@ -643,8 +739,12 @@ def test_getTeamLuck_onlyChampionshipIsTrue(self): def test_getTeamLuck_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=3, teamBScore=6) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=3, teamBScore=6 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -657,7 +757,9 @@ def test_getTeamLuck_weekNumberStartGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = SSLYearCalculator.getTeamLuck(year, weekNumberStart=2) @@ -669,8 +771,12 @@ def test_getTeamLuck_weekNumberStartGiven(self): def test_getTeamLuck_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -683,7 +789,9 @@ def test_getTeamLuck_weekNumberEndGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = SSLYearCalculator.getTeamLuck(year, weekNumberEnd=2) @@ -695,8 +803,12 @@ def test_getTeamLuck_weekNumberEndGiven(self): def test_getTeamLuck_weekNumberStartGivenAndWeekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -717,9 +829,15 @@ def test_getTeamLuck_weekNumberStartGivenAndWeekNumberEndGiven(self): week3 = Week(weekNumber=3, matchups=[matchup3]) week4 = Week(weekNumber=4, matchups=[matchup4]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3, week4]) + year = Year( + yearNumber=2000, + teams=[teams[0], teams[1]], + weeks=[week1, week2, week3, week4], + ) - response = SSLYearCalculator.getTeamLuck(year, weekNumberStart=2, weekNumberEnd=3) + response = SSLYearCalculator.getTeamLuck( + year, weekNumberStart=2, weekNumberEnd=3 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) diff --git a/test/test_calculator/test_year_calculator/test_ScoringShareYearCalculator.py b/test/test_calculator/test_year_calculator/test_ScoringShareYearCalculator.py index ef9e1b02..4e5fdcdc 100644 --- a/test/test_calculator/test_year_calculator/test_ScoringShareYearCalculator.py +++ b/test/test_calculator/test_year_calculator/test_ScoringShareYearCalculator.py @@ -1,19 +1,23 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams -from leeger.calculator.year_calculator.ScoringShareYearCalculator import ScoringShareYearCalculator +from leeger.calculator.year_calculator.ScoringShareYearCalculator import ( + ScoringShareYearCalculator, +) from leeger.enum.MatchupType import MatchupType from leeger.model.league.Matchup import Matchup from leeger.model.league.Week import Week from leeger.model.league.Year import Year from leeger.util.Deci import Deci +from test.helper.prototypes import getNDefaultOwnersAndTeams class TestScoringShareYearCalculator(unittest.TestCase): def test_getScoringShare_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -33,7 +37,9 @@ def test_getScoringShare_happyPath(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = ScoringShareYearCalculator.getScoringShare(year) @@ -46,8 +52,12 @@ def test_getScoringShare_happyPath(self): def test_getScoringShare_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=2.5 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -65,15 +75,23 @@ def test_getScoringShare_noneIfNoGamesPlayed(self): def test_getScoringShare_noPointsScoredInYear(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=0, teamBScore=0) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=0, teamBScore=0) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=0, teamBScore=0) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=0, teamBScore=0 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=0, teamBScore=0 + ) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=0, teamBScore=0 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = ScoringShareYearCalculator.getScoringShare(year) @@ -85,7 +103,9 @@ def test_getScoringShare_noPointsScoredInYear(self): def test_getScoringShare_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -105,7 +125,9 @@ def test_getScoringShare_onlyPostSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = ScoringShareYearCalculator.getScoringShare(year, onlyPostSeason=True) @@ -118,8 +140,12 @@ def test_getScoringShare_onlyPostSeasonIsTrue(self): def test_getScoringShare_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -132,9 +158,13 @@ def test_getScoringShare_onlyRegularSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) - response = ScoringShareYearCalculator.getScoringShare(year, onlyRegularSeason=True) + response = ScoringShareYearCalculator.getScoringShare( + year, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -145,7 +175,9 @@ def test_getScoringShare_onlyRegularSeasonIsTrue(self): def test_getScoringShare_onlyChampionshipIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -167,7 +199,9 @@ def test_getScoringShare_onlyChampionshipIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = ScoringShareYearCalculator.getScoringShare(year, onlyChampionship=True) + response = ScoringShareYearCalculator.getScoringShare( + year, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -178,8 +212,12 @@ def test_getScoringShare_onlyChampionshipIsTrue(self): def test_getScoringShare_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -192,7 +230,9 @@ def test_getScoringShare_weekNumberStartGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = ScoringShareYearCalculator.getScoringShare(year, weekNumberStart=2) @@ -205,8 +245,12 @@ def test_getScoringShare_weekNumberStartGiven(self): def test_getScoringShare_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -219,7 +263,9 @@ def test_getScoringShare_weekNumberEndGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = ScoringShareYearCalculator.getScoringShare(year, weekNumberEnd=2) @@ -232,8 +278,12 @@ def test_getScoringShare_weekNumberEndGiven(self): def test_getScoringShare_weekNumberStartGivenAndWeekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -254,7 +304,11 @@ def test_getScoringShare_weekNumberStartGivenAndWeekNumberEndGiven(self): week3 = Week(weekNumber=3, matchups=[matchup3]) week4 = Week(weekNumber=4, matchups=[matchup4]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3, week4]) + year = Year( + yearNumber=2000, + teams=[teams[0], teams[1]], + weeks=[week1, week2, week3, week4], + ) response = ScoringShareYearCalculator.getScoringShare( year, weekNumberStart=2, weekNumberEnd=3 @@ -269,7 +323,9 @@ def test_getScoringShare_weekNumberStartGivenAndWeekNumberEndGiven(self): def test_getOpponentScoringShare_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -289,7 +345,9 @@ def test_getOpponentScoringShare_happyPath(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = ScoringShareYearCalculator.getOpponentScoringShare(year) @@ -302,14 +360,20 @@ def test_getOpponentScoringShare_happyPath(self): def test_getOpponentScoringShare_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=2.5 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2]) - response = ScoringShareYearCalculator.getOpponentScoringShare(year, weekNumberEnd=1) + response = ScoringShareYearCalculator.getOpponentScoringShare( + year, weekNumberEnd=1 + ) self.assertIsInstance(response, dict) self.assertEqual(3, len(response.keys())) @@ -321,15 +385,23 @@ def test_getOpponentScoringShare_noneIfNoGamesPlayed(self): def test_getOpponentScoringShare_noPointsScoredInYear(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=0, teamBScore=0) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=0, teamBScore=0) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=0, teamBScore=0) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=0, teamBScore=0 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=0, teamBScore=0 + ) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=0, teamBScore=0 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = ScoringShareYearCalculator.getOpponentScoringShare(year) @@ -341,7 +413,9 @@ def test_getOpponentScoringShare_noPointsScoredInYear(self): def test_getOpponentScoringShare_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -361,9 +435,13 @@ def test_getOpponentScoringShare_onlyPostSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) - response = ScoringShareYearCalculator.getOpponentScoringShare(year, onlyPostSeason=True) + response = ScoringShareYearCalculator.getOpponentScoringShare( + year, onlyPostSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -374,8 +452,12 @@ def test_getOpponentScoringShare_onlyPostSeasonIsTrue(self): def test_getOpponentScoringShare_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -388,9 +470,13 @@ def test_getOpponentScoringShare_onlyRegularSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) - response = ScoringShareYearCalculator.getOpponentScoringShare(year, onlyRegularSeason=True) + response = ScoringShareYearCalculator.getOpponentScoringShare( + year, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -401,7 +487,9 @@ def test_getOpponentScoringShare_onlyRegularSeasonIsTrue(self): def test_getOpponentScoringShare_onlyChampionshipIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -423,7 +511,9 @@ def test_getOpponentScoringShare_onlyChampionshipIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = ScoringShareYearCalculator.getOpponentScoringShare(year, onlyChampionship=True) + response = ScoringShareYearCalculator.getOpponentScoringShare( + year, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -434,8 +524,12 @@ def test_getOpponentScoringShare_onlyChampionshipIsTrue(self): def test_getOpponentScoringShare_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -448,9 +542,13 @@ def test_getOpponentScoringShare_weekNumberStartGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) - response = ScoringShareYearCalculator.getOpponentScoringShare(year, weekNumberStart=2) + response = ScoringShareYearCalculator.getOpponentScoringShare( + year, weekNumberStart=2 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -461,8 +559,12 @@ def test_getOpponentScoringShare_weekNumberStartGiven(self): def test_getOpponentScoringShare_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -475,9 +577,13 @@ def test_getOpponentScoringShare_weekNumberEndGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) - response = ScoringShareYearCalculator.getOpponentScoringShare(year, weekNumberEnd=2) + response = ScoringShareYearCalculator.getOpponentScoringShare( + year, weekNumberEnd=2 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -488,8 +594,12 @@ def test_getOpponentScoringShare_weekNumberEndGiven(self): def test_getOpponentScoringShare_weekNumberStartGivenAndWeekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -510,7 +620,11 @@ def test_getOpponentScoringShare_weekNumberStartGivenAndWeekNumberEndGiven(self) week3 = Week(weekNumber=3, matchups=[matchup3]) week4 = Week(weekNumber=4, matchups=[matchup4]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3, week4]) + year = Year( + yearNumber=2000, + teams=[teams[0], teams[1]], + weeks=[week1, week2, week3, week4], + ) response = ScoringShareYearCalculator.getOpponentScoringShare( year, weekNumberStart=2, weekNumberEnd=3 @@ -525,7 +639,9 @@ def test_getOpponentScoringShare_weekNumberStartGivenAndWeekNumberEndGiven(self) def test_getMaxScoringShare_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -557,8 +673,12 @@ def test_getMaxScoringShare_happyPath(self): def test_getMaxScoringShare_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=2.5 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -575,9 +695,15 @@ def test_getMaxScoringShare_noneIfNoGamesPlayed(self): def test_getMaxScoringShare_noPointsScoredInYear(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=0, teamBScore=0) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=0, teamBScore=0) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=0, teamBScore=0) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=0, teamBScore=0 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=0, teamBScore=0 + ) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=0, teamBScore=0 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -595,7 +721,9 @@ def test_getMaxScoringShare_noPointsScoredInYear(self): def test_getMaxScoringShare_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -617,7 +745,9 @@ def test_getMaxScoringShare_onlyPostSeasonIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = ScoringShareYearCalculator.getMaxScoringShare(year, onlyPostSeason=True) + response = ScoringShareYearCalculator.getMaxScoringShare( + year, onlyPostSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -627,8 +757,12 @@ def test_getMaxScoringShare_onlyPostSeasonIsTrue(self): def test_getMaxScoringShare_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -643,7 +777,9 @@ def test_getMaxScoringShare_onlyRegularSeasonIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = ScoringShareYearCalculator.getMaxScoringShare(year, onlyRegularSeason=True) + response = ScoringShareYearCalculator.getMaxScoringShare( + year, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -653,7 +789,9 @@ def test_getMaxScoringShare_onlyRegularSeasonIsTrue(self): def test_getMaxScoringShare_onlyChampionshipIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -675,7 +813,9 @@ def test_getMaxScoringShare_onlyChampionshipIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = ScoringShareYearCalculator.getMaxScoringShare(year, onlyChampionship=True) + response = ScoringShareYearCalculator.getMaxScoringShare( + year, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -685,8 +825,12 @@ def test_getMaxScoringShare_onlyChampionshipIsTrue(self): def test_getMaxScoringShare_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -701,7 +845,9 @@ def test_getMaxScoringShare_weekNumberStartGiven(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = ScoringShareYearCalculator.getMaxScoringShare(year, weekNumberStart=2) + response = ScoringShareYearCalculator.getMaxScoringShare( + year, weekNumberStart=2 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -711,8 +857,12 @@ def test_getMaxScoringShare_weekNumberStartGiven(self): def test_getMaxScoringShare_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -737,8 +887,12 @@ def test_getMaxScoringShare_weekNumberEndGiven(self): def test_getMaxScoringShare_weekNumberStartGivenAndWeekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -773,7 +927,9 @@ def test_getMaxScoringShare_weekNumberStartGivenAndWeekNumberEndGiven(self): def test_getMinScoringShare_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -805,8 +961,12 @@ def test_getMinScoringShare_happyPath(self): def test_getMinScoringShare_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=2.5 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -823,9 +983,15 @@ def test_getMinScoringShare_noneIfNoGamesPlayed(self): def test_getMinScoringShare_noPointsScoredInYear(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=0, teamBScore=0) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=0, teamBScore=0) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=0, teamBScore=0) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=0, teamBScore=0 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=0, teamBScore=0 + ) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=0, teamBScore=0 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -843,7 +1009,9 @@ def test_getMinScoringShare_noPointsScoredInYear(self): def test_getMinScoringShare_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -865,7 +1033,9 @@ def test_getMinScoringShare_onlyPostSeasonIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = ScoringShareYearCalculator.getMinScoringShare(year, onlyPostSeason=True) + response = ScoringShareYearCalculator.getMinScoringShare( + year, onlyPostSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -875,8 +1045,12 @@ def test_getMinScoringShare_onlyPostSeasonIsTrue(self): def test_getMinScoringShare_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -891,7 +1065,9 @@ def test_getMinScoringShare_onlyRegularSeasonIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = ScoringShareYearCalculator.getMinScoringShare(year, onlyRegularSeason=True) + response = ScoringShareYearCalculator.getMinScoringShare( + year, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -901,7 +1077,9 @@ def test_getMinScoringShare_onlyRegularSeasonIsTrue(self): def test_getMinScoringShare_onlyChampionshipIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -923,7 +1101,9 @@ def test_getMinScoringShare_onlyChampionshipIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = ScoringShareYearCalculator.getMinScoringShare(year, onlyChampionship=True) + response = ScoringShareYearCalculator.getMinScoringShare( + year, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -933,8 +1113,12 @@ def test_getMinScoringShare_onlyChampionshipIsTrue(self): def test_getMinScoringShare_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -949,7 +1133,9 @@ def test_getMinScoringShare_weekNumberStartGiven(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = ScoringShareYearCalculator.getMinScoringShare(year, weekNumberStart=2) + response = ScoringShareYearCalculator.getMinScoringShare( + year, weekNumberStart=2 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -959,8 +1145,12 @@ def test_getMinScoringShare_weekNumberStartGiven(self): def test_getMinScoringShare_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -985,8 +1175,12 @@ def test_getMinScoringShare_weekNumberEndGiven(self): def test_getMinScoringShare_weekNumberStartGivenAndWeekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, diff --git a/test/test_calculator/test_year_calculator/test_ScoringStandardDeviationYearCalculator.py b/test/test_calculator/test_year_calculator/test_ScoringStandardDeviationYearCalculator.py index d817bf05..d33cb423 100644 --- a/test/test_calculator/test_year_calculator/test_ScoringStandardDeviationYearCalculator.py +++ b/test/test_calculator/test_year_calculator/test_ScoringStandardDeviationYearCalculator.py @@ -1,5 +1,4 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams from leeger.calculator.year_calculator import ScoringStandardDeviationYearCalculator from leeger.enum.MatchupType import MatchupType @@ -7,13 +6,16 @@ from leeger.model.league.Week import Week from leeger.model.league.Year import Year from leeger.util.Deci import Deci +from test.helper.prototypes import getNDefaultOwnersAndTeams class TestScoringStandardDeviationYearCalculator(unittest.TestCase): def test_getScoringStandardDeviation_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -33,9 +35,13 @@ def test_getScoringStandardDeviation_happyPath(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) - response = ScoringStandardDeviationYearCalculator.getScoringStandardDeviation(year) + response = ScoringStandardDeviationYearCalculator.getScoringStandardDeviation( + year + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -71,9 +77,13 @@ def test_getScoringStandardDeviation_multiWeekMatchups(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) - response = ScoringStandardDeviationYearCalculator.getScoringStandardDeviation(year) + response = ScoringStandardDeviationYearCalculator.getScoringStandardDeviation( + year + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -83,8 +93,12 @@ def test_getScoringStandardDeviation_multiWeekMatchups(self): def test_getScoringStandardDeviation_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=2.5 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -103,7 +117,9 @@ def test_getScoringStandardDeviation_noneIfNoGamesPlayed(self): def test_getScoringStandardDeviation_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -123,7 +139,9 @@ def test_getScoringStandardDeviation_onlyPostSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = ScoringStandardDeviationYearCalculator.getScoringStandardDeviation( year, onlyPostSeason=True @@ -137,8 +155,12 @@ def test_getScoringStandardDeviation_onlyPostSeasonIsTrue(self): def test_getScoringStandardDeviation_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=5, teamBScore=3) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=5, teamBScore=3 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -151,7 +173,9 @@ def test_getScoringStandardDeviation_onlyRegularSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = ScoringStandardDeviationYearCalculator.getScoringStandardDeviation( year, onlyRegularSeason=True @@ -165,9 +189,15 @@ def test_getScoringStandardDeviation_onlyRegularSeasonIsTrue(self): def test_getScoringStandardDeviation_onlyChampionshipIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.3, teamBScore=2.3) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.3, teamBScore=4.3) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.3, teamBScore=5.3) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.3, teamBScore=2.3 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.3, teamBScore=4.3 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.3, teamBScore=5.3 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) matchup4 = Matchup( @@ -211,8 +241,12 @@ def test_getScoringStandardDeviation_onlyChampionshipIsTrue(self): def test_getScoringStandardDeviation_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -225,7 +259,9 @@ def test_getScoringStandardDeviation_weekNumberStartGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = ScoringStandardDeviationYearCalculator.getScoringStandardDeviation( year, weekNumberStart=2 @@ -239,8 +275,12 @@ def test_getScoringStandardDeviation_weekNumberStartGiven(self): def test_getScoringStandardDeviation_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.9, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.9, teamBScore=5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -253,7 +293,9 @@ def test_getScoringStandardDeviation_weekNumberEndGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = ScoringStandardDeviationYearCalculator.getScoringStandardDeviation( year, weekNumberEnd=2 @@ -264,11 +306,17 @@ def test_getScoringStandardDeviation_weekNumberEndGiven(self): self.assertEqual(Deci("0.4"), response[teams[0].id]) self.assertEqual(Deci("1.3"), response[teams[1].id]) - def test_getScoringStandardDeviation_weekNumberStartGivenAndWeekNumberEndGiven(self): + def test_getScoringStandardDeviation_weekNumberStartGivenAndWeekNumberEndGiven( + self, + ): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.4 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.5 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -289,7 +337,11 @@ def test_getScoringStandardDeviation_weekNumberStartGivenAndWeekNumberEndGiven(s week3 = Week(weekNumber=3, matchups=[matchup3]) week4 = Week(weekNumber=4, matchups=[matchup4]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3, week4]) + year = Year( + yearNumber=2000, + teams=[teams[0], teams[1]], + weeks=[week1, week2, week3, week4], + ) response = ScoringStandardDeviationYearCalculator.getScoringStandardDeviation( year, weekNumberStart=2, weekNumberEnd=3 diff --git a/test/test_calculator/test_year_calculator/test_SingleScoreYearCalculator.py b/test/test_calculator/test_year_calculator/test_SingleScoreYearCalculator.py index 931532e3..daafb3e4 100644 --- a/test/test_calculator/test_year_calculator/test_SingleScoreYearCalculator.py +++ b/test/test_calculator/test_year_calculator/test_SingleScoreYearCalculator.py @@ -1,11 +1,11 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams from leeger.calculator.year_calculator import SingleScoreYearCalculator from leeger.enum.MatchupType import MatchupType from leeger.model.league.Matchup import Matchup from leeger.model.league.Week import Week from leeger.model.league.Year import Year +from test.helper.prototypes import getNDefaultOwnersAndTeams class TestSingleScoreYearCalculator(unittest.TestCase): @@ -19,13 +19,23 @@ def test_getMaxScore_happyPath(self): teamBScore=2.1, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.1, teamBScore=4.1) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.1, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.1, teamBScore=4.1 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.1, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup4 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.2) - matchup5 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.2, teamBScore=4.2) - matchup6 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.2, teamBScore=6) + matchup4 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.2 + ) + matchup5 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.2, teamBScore=4.2 + ) + matchup6 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.2, teamBScore=6 + ) week2 = Week(weekNumber=2, matchups=[matchup4, matchup5, matchup6]) matchup7 = Matchup( @@ -67,9 +77,13 @@ def test_getMaxScore_happyPath(self): def test_getMaxScore_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.1 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=2.2) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=2.2 + ) week2 = Week(weekNumber=2, matchups=[matchup2]) year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2]) @@ -92,8 +106,12 @@ def test_getMaxScore_onlyPostSeasonIsTrue(self): teamBScore=2.1, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.1, teamBScore=4.1) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.1, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.1, teamBScore=4.1 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.1, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) matchup4 = Matchup( @@ -102,7 +120,9 @@ def test_getMaxScore_onlyPostSeasonIsTrue(self): matchup5 = Matchup( teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=30.2, teamBScore=40.2 ) - matchup6 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=40.2, teamBScore=60) + matchup6 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=40.2, teamBScore=60 + ) week2 = Week(weekNumber=2, matchups=[matchup4, matchup5, matchup6]) matchup7 = Matchup( @@ -151,13 +171,23 @@ def test_getMaxScore_onlyRegularSeasonIsTrue(self): teamBScore=2.1, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.1, teamBScore=4.1) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.1, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.1, teamBScore=4.1 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.1, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup4 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.2) - matchup5 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.2, teamBScore=4.2) - matchup6 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.2, teamBScore=6) + matchup4 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.2 + ) + matchup5 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.2, teamBScore=4.2 + ) + matchup6 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.2, teamBScore=6 + ) week2 = Week(weekNumber=2, matchups=[matchup4, matchup5, matchup6]) matchup7 = Matchup( @@ -206,13 +236,23 @@ def test_getMaxScore_onlyChampionshipIsTrue(self): teamBScore=2.1, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.1, teamBScore=4.1) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.1, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.1, teamBScore=4.1 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.1, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup4 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.2) - matchup5 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.2, teamBScore=4.2) - matchup6 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.2, teamBScore=6) + matchup4 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.2 + ) + matchup5 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.2, teamBScore=4.2 + ) + matchup6 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.2, teamBScore=6 + ) week2 = Week(weekNumber=2, matchups=[matchup4, matchup5, matchup6]) matchup7 = Matchup( @@ -264,12 +304,20 @@ def test_getMaxScore_weekNumberStartGiven(self): matchup2 = Matchup( teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=30.1, teamBScore=40.1 ) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=40.1, teamBScore=50) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=40.1, teamBScore=50 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup4 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.2) - matchup5 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.2, teamBScore=4.2) - matchup6 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.2, teamBScore=6) + matchup4 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.2 + ) + matchup5 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.2, teamBScore=4.2 + ) + matchup6 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.2, teamBScore=6 + ) week2 = Week(weekNumber=2, matchups=[matchup4, matchup5, matchup6]) matchup7 = Matchup( @@ -318,13 +366,23 @@ def test_getMaxScore_weekNumberEndGiven(self): teamBScore=2.1, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.1, teamBScore=4.1) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.1, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.1, teamBScore=4.1 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.1, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup4 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.2) - matchup5 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.2, teamBScore=4.2) - matchup6 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.2, teamBScore=6) + matchup4 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.2 + ) + matchup5 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.2, teamBScore=4.2 + ) + matchup6 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.2, teamBScore=6 + ) week2 = Week(weekNumber=2, matchups=[matchup4, matchup5, matchup6]) matchup7 = Matchup( @@ -373,18 +431,34 @@ def test_getMaxScore_weekNumberStartGivenAndWeekNumberEndGiven(self): teamBScore=2.1, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.1, teamBScore=4.1) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.1, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.1, teamBScore=4.1 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.1, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup4 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.2) - matchup5 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.2, teamBScore=4.2) - matchup6 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.2, teamBScore=6) + matchup4 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.2 + ) + matchup5 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.2, teamBScore=4.2 + ) + matchup6 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.2, teamBScore=6 + ) week2 = Week(weekNumber=2, matchups=[matchup4, matchup5, matchup6]) - matchup7 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.3, teamBScore=2.3) - matchup8 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.3, teamBScore=4.3) - matchup9 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.3, teamBScore=7) + matchup7 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.3, teamBScore=2.3 + ) + matchup8 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.3, teamBScore=4.3 + ) + matchup9 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.3, teamBScore=7 + ) week3 = Week(weekNumber=3, matchups=[matchup7, matchup8, matchup9]) matchup10 = Matchup( @@ -412,7 +486,9 @@ def test_getMaxScore_weekNumberStartGivenAndWeekNumberEndGiven(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = SingleScoreYearCalculator.getMaxScore(year, weekNumberStart=2, weekNumberEnd=3) + response = SingleScoreYearCalculator.getMaxScore( + year, weekNumberStart=2, weekNumberEnd=3 + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -433,13 +509,23 @@ def test_getMinScore_happyPath(self): teamBScore=2.1, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.1, teamBScore=4.1) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.1, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.1, teamBScore=4.1 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.1, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup4 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.2) - matchup5 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.2, teamBScore=4.2) - matchup6 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.2, teamBScore=6) + matchup4 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.2 + ) + matchup5 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.2, teamBScore=4.2 + ) + matchup6 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.2, teamBScore=6 + ) week2 = Week(weekNumber=2, matchups=[matchup4, matchup5, matchup6]) matchup7 = Matchup( @@ -481,9 +567,13 @@ def test_getMinScore_happyPath(self): def test_getMinScore_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=2.1 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=2.2) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1.2, teamBScore=2.2 + ) week2 = Week(weekNumber=2, matchups=[matchup2]) year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2]) @@ -506,8 +596,12 @@ def test_getMinScore_onlyPostSeasonIsTrue(self): teamBScore=2.1, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.1, teamBScore=4.1) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.1, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.1, teamBScore=4.1 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.1, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) matchup4 = Matchup( @@ -516,7 +610,9 @@ def test_getMinScore_onlyPostSeasonIsTrue(self): matchup5 = Matchup( teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=30.2, teamBScore=40.2 ) - matchup6 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=40.2, teamBScore=60) + matchup6 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=40.2, teamBScore=60 + ) week2 = Week(weekNumber=2, matchups=[matchup4, matchup5, matchup6]) matchup7 = Matchup( @@ -565,13 +661,23 @@ def test_getMinScore_onlyRegularSeasonIsTrue(self): teamBScore=2.1, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.1, teamBScore=4.1) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.1, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.1, teamBScore=4.1 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.1, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup4 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.2) - matchup5 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.2, teamBScore=4.2) - matchup6 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.2, teamBScore=6) + matchup4 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.2 + ) + matchup5 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.2, teamBScore=4.2 + ) + matchup6 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.2, teamBScore=6 + ) week2 = Week(weekNumber=2, matchups=[matchup4, matchup5, matchup6]) matchup7 = Matchup( @@ -620,13 +726,23 @@ def test_getMinScore_onlyChampionshipIsTrue(self): teamBScore=2.1, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.1, teamBScore=4.1) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.1, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.1, teamBScore=4.1 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.1, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup4 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.2) - matchup5 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.2, teamBScore=4.2) - matchup6 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.2, teamBScore=6) + matchup4 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.2 + ) + matchup5 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.2, teamBScore=4.2 + ) + matchup6 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.2, teamBScore=6 + ) week2 = Week(weekNumber=2, matchups=[matchup4, matchup5, matchup6]) matchup7 = Matchup( @@ -678,12 +794,20 @@ def test_getMinScore_weekNumberStartGiven(self): matchup2 = Matchup( teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=30.1, teamBScore=40.1 ) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=40.1, teamBScore=50) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=40.1, teamBScore=50 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup4 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.2) - matchup5 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.2, teamBScore=4.2) - matchup6 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.2, teamBScore=6) + matchup4 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.2 + ) + matchup5 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.2, teamBScore=4.2 + ) + matchup6 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.2, teamBScore=6 + ) week2 = Week(weekNumber=2, matchups=[matchup4, matchup5, matchup6]) matchup7 = Matchup( @@ -732,13 +856,23 @@ def test_getMinScore_weekNumberEndGiven(self): teamBScore=2.1, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.1, teamBScore=4.1) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.1, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.1, teamBScore=4.1 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.1, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup4 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.2) - matchup5 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.2, teamBScore=4.2) - matchup6 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.2, teamBScore=6) + matchup4 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.2 + ) + matchup5 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.2, teamBScore=4.2 + ) + matchup6 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.2, teamBScore=6 + ) week2 = Week(weekNumber=2, matchups=[matchup4, matchup5, matchup6]) matchup7 = Matchup( @@ -787,18 +921,34 @@ def test_getMinScore_weekNumberStartGivenAndWeekNumberEndGiven(self): teamBScore=2.1, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.1, teamBScore=4.1) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.1, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.1, teamBScore=4.1 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.1, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup4 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.2) - matchup5 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.2, teamBScore=4.2) - matchup6 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.2, teamBScore=6) + matchup4 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=2.2 + ) + matchup5 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.2, teamBScore=4.2 + ) + matchup6 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.2, teamBScore=6 + ) week2 = Week(weekNumber=2, matchups=[matchup4, matchup5, matchup6]) - matchup7 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.3, teamBScore=2.3) - matchup8 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.3, teamBScore=4.3) - matchup9 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.3, teamBScore=7) + matchup7 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.3, teamBScore=2.3 + ) + matchup8 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3.3, teamBScore=4.3 + ) + matchup9 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4.3, teamBScore=7 + ) week3 = Week(weekNumber=3, matchups=[matchup7, matchup8, matchup9]) matchup10 = Matchup( @@ -826,7 +976,9 @@ def test_getMinScore_weekNumberStartGivenAndWeekNumberEndGiven(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = SingleScoreYearCalculator.getMinScore(year, weekNumberStart=2, weekNumberEnd=3) + response = SingleScoreYearCalculator.getMinScore( + year, weekNumberStart=2, weekNumberEnd=3 + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) diff --git a/test/test_calculator/test_year_calculator/test_SmartWinsYearCalculator.py b/test/test_calculator/test_year_calculator/test_SmartWinsYearCalculator.py index 873e9dc3..90b57cab 100644 --- a/test/test_calculator/test_year_calculator/test_SmartWinsYearCalculator.py +++ b/test/test_calculator/test_year_calculator/test_SmartWinsYearCalculator.py @@ -1,12 +1,14 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams -from leeger.calculator.year_calculator.SmartWinsYearCalculator import SmartWinsYearCalculator +from leeger.calculator.year_calculator.SmartWinsYearCalculator import ( + SmartWinsYearCalculator, +) from leeger.enum.MatchupType import MatchupType from leeger.model.league.Matchup import Matchup from leeger.model.league.Week import Week from leeger.model.league.Year import Year from leeger.util.Deci import Deci +from test.helper.prototypes import getNDefaultOwnersAndTeams class TestSmartWinsYearCalculator(unittest.TestCase): @@ -20,14 +22,24 @@ def test_getSmartWins_happyPath(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) @@ -78,8 +90,12 @@ def test_getSmartWins_multiWeekMatchups(self): teamBScore=2, multiWeekMatchupId="1", ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -90,8 +106,12 @@ def test_getSmartWins_multiWeekMatchups(self): teamBScore=2, multiWeekMatchupId="1", ) - matchup5 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup6 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup5 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup6 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup4, matchup5, matchup6]) @@ -111,10 +131,14 @@ def test_getSmartWins_multiWeekMatchups(self): def test_getSmartWins_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=3, teamBScore=4) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=3, teamBScore=4 + ) week2 = Week(weekNumber=2, matchups=[matchup2]) year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2]) @@ -137,14 +161,24 @@ def test_getSmartWins_onlyPostSeasonIsTrue(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) @@ -195,14 +229,24 @@ def test_getSmartWins_onlyRegularSeasonIsTrue(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) @@ -253,14 +297,24 @@ def test_getSmartWins_onlyChampionshipIsTrue(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) @@ -311,14 +365,24 @@ def test_getSmartWins_weekNumberStartGiven(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) @@ -369,14 +433,24 @@ def test_getSmartWins_weekNumberEndGiven(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) @@ -427,20 +501,36 @@ def test_getSmartWins_weekNumberStartGivenWeekNumberEndGiven(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week3 = Week(weekNumber=3, matchups=[matchup1, matchup2, matchup3]) @@ -470,7 +560,9 @@ def test_getSmartWins_weekNumberStartGivenWeekNumberEndGiven(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = SmartWinsYearCalculator.getSmartWins(year, weekNumberStart=2, weekNumberEnd=3) + response = SmartWinsYearCalculator.getSmartWins( + year, weekNumberStart=2, weekNumberEnd=3 + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -491,14 +583,24 @@ def test_getSmartWinsPerGame_happyPath(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) @@ -549,8 +651,12 @@ def test_getSmartWinsPerGame_multiWeekMatchups(self): teamBScore=2, multiWeekMatchupId="1", ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -561,8 +667,12 @@ def test_getSmartWinsPerGame_multiWeekMatchups(self): teamBScore=2, multiWeekMatchupId="1", ) - matchup5 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup6 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup5 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup6 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup4, matchup5, matchup6]) @@ -582,10 +692,14 @@ def test_getSmartWinsPerGame_multiWeekMatchups(self): def test_getSmartWinsPerGame_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=3, teamBScore=4) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=3, teamBScore=4 + ) week2 = Week(weekNumber=2, matchups=[matchup2]) year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2]) @@ -608,14 +722,24 @@ def test_getSmartWinsPerGame_onlyPostSeasonIsTrue(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) @@ -645,7 +769,9 @@ def test_getSmartWinsPerGame_onlyPostSeasonIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = SmartWinsYearCalculator.getSmartWinsPerGame(year, onlyPostSeason=True) + response = SmartWinsYearCalculator.getSmartWinsPerGame( + year, onlyPostSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -666,14 +792,24 @@ def test_getSmartWinsPerGame_onlyRegularSeasonIsTrue(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) @@ -703,7 +839,9 @@ def test_getSmartWinsPerGame_onlyRegularSeasonIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = SmartWinsYearCalculator.getSmartWinsPerGame(year, onlyRegularSeason=True) + response = SmartWinsYearCalculator.getSmartWinsPerGame( + year, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -724,14 +862,24 @@ def test_getSmartWinsPerGame_onlyChampionshipIsTrue(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) @@ -761,7 +909,9 @@ def test_getSmartWinsPerGame_onlyChampionshipIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = SmartWinsYearCalculator.getSmartWinsPerGame(year, onlyChampionship=True) + response = SmartWinsYearCalculator.getSmartWinsPerGame( + year, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -782,14 +932,24 @@ def test_getSmartWinsPerGame_weekNumberStartGiven(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) @@ -840,14 +1000,24 @@ def test_getSmartWinsPerGame_weekNumberEndGiven(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) @@ -898,20 +1068,36 @@ def test_getSmartWinsPerGame_weekNumberStartGivenWeekNumberEndGiven(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week3 = Week(weekNumber=3, matchups=[matchup1, matchup2, matchup3]) @@ -964,14 +1150,24 @@ def test_getOpponentSmartWins_happyPath(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) @@ -1022,8 +1218,12 @@ def test_getOpponentSmartWins_multiWeekMatchups(self): teamBScore=2, multiWeekMatchupId="1", ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -1034,8 +1234,12 @@ def test_getOpponentSmartWins_multiWeekMatchups(self): teamBScore=2, multiWeekMatchupId="1", ) - matchup5 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup6 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup5 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup6 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup4, matchup5, matchup6]) @@ -1055,10 +1259,14 @@ def test_getOpponentSmartWins_multiWeekMatchups(self): def test_getOpponentSmartWins_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=3, teamBScore=4) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=3, teamBScore=4 + ) week2 = Week(weekNumber=2, matchups=[matchup2]) year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2]) @@ -1081,14 +1289,24 @@ def test_getOpponentSmartWins_onlyPostSeasonIsTrue(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) @@ -1118,7 +1336,9 @@ def test_getOpponentSmartWins_onlyPostSeasonIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = SmartWinsYearCalculator.getOpponentSmartWins(year, onlyPostSeason=True) + response = SmartWinsYearCalculator.getOpponentSmartWins( + year, onlyPostSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -1139,14 +1359,24 @@ def test_getOpponentSmartWins_onlyRegularSeasonIsTrue(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) @@ -1176,7 +1406,9 @@ def test_getOpponentSmartWins_onlyRegularSeasonIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = SmartWinsYearCalculator.getOpponentSmartWins(year, onlyRegularSeason=True) + response = SmartWinsYearCalculator.getOpponentSmartWins( + year, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -1197,14 +1429,24 @@ def test_getOpponentSmartWins_onlyChampionshipIsTrue(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) @@ -1234,7 +1476,9 @@ def test_getOpponentSmartWins_onlyChampionshipIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = SmartWinsYearCalculator.getOpponentSmartWins(year, onlyChampionship=True) + response = SmartWinsYearCalculator.getOpponentSmartWins( + year, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -1255,14 +1499,24 @@ def test_getOpponentSmartWins_weekNumberStartGiven(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) @@ -1313,14 +1567,24 @@ def test_getOpponentSmartWins_weekNumberEndGiven(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) @@ -1371,20 +1635,36 @@ def test_getOpponentSmartWins_weekNumberStartGivenWeekNumberEndGiven(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week3 = Week(weekNumber=3, matchups=[matchup1, matchup2, matchup3]) @@ -1437,14 +1717,24 @@ def test_getOpponentSmartWinsPerGame_happyPath(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) @@ -1495,8 +1785,12 @@ def test_getOpponentSmartWinsPerGame_multiWeekMatchups(self): teamBScore=2, multiWeekMatchupId="1", ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) @@ -1507,8 +1801,12 @@ def test_getOpponentSmartWinsPerGame_multiWeekMatchups(self): teamBScore=2, multiWeekMatchupId="1", ) - matchup5 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup6 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup5 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup6 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup4, matchup5, matchup6]) @@ -1528,15 +1826,21 @@ def test_getOpponentSmartWinsPerGame_multiWeekMatchups(self): def test_getOpponentSmartWinsPerGame_noneIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=3, teamBScore=4) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=3, teamBScore=4 + ) week2 = Week(weekNumber=2, matchups=[matchup2]) year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2]) - response = SmartWinsYearCalculator.getOpponentSmartWinsPerGame(year, weekNumberEnd=1) + response = SmartWinsYearCalculator.getOpponentSmartWinsPerGame( + year, weekNumberEnd=1 + ) self.assertIsInstance(response, dict) self.assertEqual(3, len(response.keys())) @@ -1554,14 +1858,24 @@ def test_getOpponentSmartWinsPerGame_onlyPostSeasonIsTrue(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) @@ -1591,7 +1905,9 @@ def test_getOpponentSmartWinsPerGame_onlyPostSeasonIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = SmartWinsYearCalculator.getOpponentSmartWinsPerGame(year, onlyPostSeason=True) + response = SmartWinsYearCalculator.getOpponentSmartWinsPerGame( + year, onlyPostSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -1612,14 +1928,24 @@ def test_getOpponentSmartWinsPerGame_onlyRegularSeasonIsTrue(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) @@ -1649,7 +1975,9 @@ def test_getOpponentSmartWinsPerGame_onlyRegularSeasonIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = SmartWinsYearCalculator.getOpponentSmartWinsPerGame(year, onlyRegularSeason=True) + response = SmartWinsYearCalculator.getOpponentSmartWinsPerGame( + year, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -1670,14 +1998,24 @@ def test_getOpponentSmartWinsPerGame_onlyChampionshipIsTrue(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) @@ -1707,7 +2045,9 @@ def test_getOpponentSmartWinsPerGame_onlyChampionshipIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = SmartWinsYearCalculator.getOpponentSmartWinsPerGame(year, onlyChampionship=True) + response = SmartWinsYearCalculator.getOpponentSmartWinsPerGame( + year, onlyChampionship=True + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -1728,14 +2068,24 @@ def test_getOpponentSmartWinsPerGame_weekNumberStartGiven(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) @@ -1765,7 +2115,9 @@ def test_getOpponentSmartWinsPerGame_weekNumberStartGiven(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = SmartWinsYearCalculator.getOpponentSmartWinsPerGame(year, weekNumberStart=2) + response = SmartWinsYearCalculator.getOpponentSmartWinsPerGame( + year, weekNumberStart=2 + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -1786,14 +2138,24 @@ def test_getOpponentSmartWinsPerGame_weekNumberEndGiven(self): teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) @@ -1823,7 +2185,9 @@ def test_getOpponentSmartWinsPerGame_weekNumberEndGiven(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = SmartWinsYearCalculator.getOpponentSmartWinsPerGame(year, weekNumberEnd=2) + response = SmartWinsYearCalculator.getOpponentSmartWinsPerGame( + year, weekNumberEnd=2 + ) self.assertIsInstance(response, dict) self.assertEqual(6, len(response.keys())) @@ -1844,20 +2208,36 @@ def test_getOpponentSmartWinsPerGame_weekNumberStartGivenWeekNumberEndGiven(self teamBScore=2, matchupType=MatchupType.IGNORE, ) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week1 = Week(weekNumber=1, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week2 = Week(weekNumber=2, matchups=[matchup1, matchup2, matchup3]) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[4].id, teamBId=teams[5].id, teamAScore=4, teamBScore=5 + ) week3 = Week(weekNumber=3, matchups=[matchup1, matchup2, matchup3]) diff --git a/test/test_calculator/test_year_calculator/test_TeamSummaryYearCalculator.py b/test/test_calculator/test_year_calculator/test_TeamSummaryYearCalculator.py index 5fa6faf3..5188d837 100644 --- a/test/test_calculator/test_year_calculator/test_TeamSummaryYearCalculator.py +++ b/test/test_calculator/test_year_calculator/test_TeamSummaryYearCalculator.py @@ -1,19 +1,23 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams -from leeger.calculator.year_calculator.TeamSummaryYearCalculator import TeamSummaryYearCalculator +from leeger.calculator.year_calculator.TeamSummaryYearCalculator import ( + TeamSummaryYearCalculator, +) from leeger.enum.MatchupType import MatchupType from leeger.model.league import YearSettings from leeger.model.league.Matchup import Matchup from leeger.model.league.Week import Week from leeger.model.league.Year import Year +from test.helper.prototypes import getNDefaultOwnersAndTeams class TestTeamSummaryYearCalculator(unittest.TestCase): def test_getGamesPlayed_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=3) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=3 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -63,7 +67,9 @@ def test_getGamesPlayed_multiWeekMatchups(self): ) week2 = Week(weekNumber=2, matchups=[matchup2]) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week3 = Week(weekNumber=3, matchups=[matchup3]) year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) @@ -78,8 +84,12 @@ def test_getGamesPlayed_multiWeekMatchups(self): def test_getGamesPlayed_zeroIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -97,7 +107,9 @@ def test_getGamesPlayed_zeroIfNoGamesPlayed(self): def test_getGamesPlayed_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -117,7 +129,9 @@ def test_getGamesPlayed_onlyPostSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = TeamSummaryYearCalculator.getGamesPlayed(year, onlyPostSeason=True) @@ -129,8 +143,12 @@ def test_getGamesPlayed_onlyPostSeasonIsTrue(self): def test_getGamesPlayed_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -143,9 +161,13 @@ def test_getGamesPlayed_onlyRegularSeasonIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) - response = TeamSummaryYearCalculator.getGamesPlayed(year, onlyRegularSeason=True) + response = TeamSummaryYearCalculator.getGamesPlayed( + year, onlyRegularSeason=True + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) @@ -155,7 +177,9 @@ def test_getGamesPlayed_onlyRegularSeasonIsTrue(self): def test_getGamesPlayed_onlyChampionshipIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -175,7 +199,9 @@ def test_getGamesPlayed_onlyChampionshipIsTrue(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = TeamSummaryYearCalculator.getGamesPlayed(year, onlyChampionship=True) @@ -187,8 +213,12 @@ def test_getGamesPlayed_onlyChampionshipIsTrue(self): def test_getGamesPlayed_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -201,7 +231,9 @@ def test_getGamesPlayed_weekNumberStartGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = TeamSummaryYearCalculator.getGamesPlayed(year, weekNumberStart=2) @@ -213,8 +245,12 @@ def test_getGamesPlayed_weekNumberStartGiven(self): def test_getGamesPlayed_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -227,7 +263,9 @@ def test_getGamesPlayed_weekNumberEndGiven(self): week2 = Week(weekNumber=2, matchups=[matchup2]) week3 = Week(weekNumber=3, matchups=[matchup3]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3]) + year = Year( + yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3] + ) response = TeamSummaryYearCalculator.getGamesPlayed(year, weekNumberEnd=2) @@ -239,8 +277,12 @@ def test_getGamesPlayed_weekNumberEndGiven(self): def test_getGamesPlayed_weekNumberStartGivenAndWeekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -261,7 +303,11 @@ def test_getGamesPlayed_weekNumberStartGivenAndWeekNumberEndGiven(self): week3 = Week(weekNumber=3, matchups=[matchup3]) week4 = Week(weekNumber=4, matchups=[matchup4]) - year = Year(yearNumber=2000, teams=[teams[0], teams[1]], weeks=[week1, week2, week3, week4]) + year = Year( + yearNumber=2000, + teams=[teams[0], teams[1]], + weeks=[week1, week2, week3, week4], + ) response = TeamSummaryYearCalculator.getGamesPlayed( year, weekNumberStart=2, weekNumberEnd=3 @@ -275,9 +321,15 @@ def test_getGamesPlayed_weekNumberStartGivenAndWeekNumberEndGiven(self): def test_getTotalGames_default_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=3) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=3) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.3, teamBScore=2.9) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=3 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=3 + ) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.3, teamBScore=2.9 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -295,9 +347,15 @@ def test_getTotalGames_default_happyPath(self): def test_getTotalGames_leagueMedianGamesIsOn_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=3) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=3) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.3, teamBScore=2.9) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.1, teamBScore=3 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.2, teamBScore=3 + ) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1.3, teamBScore=2.9 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -305,7 +363,10 @@ def test_getTotalGames_leagueMedianGamesIsOn_happyPath(self): yearSettings = YearSettings(leagueMedianGames=True) year = Year( - yearNumber=2000, teams=teams, weeks=[week1, week2, week3], yearSettings=yearSettings + yearNumber=2000, + teams=teams, + weeks=[week1, week2, week3], + yearSettings=yearSettings, ) response = TeamSummaryYearCalculator.getTotalGames(year) @@ -336,7 +397,9 @@ def test_getTotalGames_multiWeekMatchups(self): ) week2 = Week(weekNumber=2, matchups=[matchup2]) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week3 = Week(weekNumber=3, matchups=[matchup3]) year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) @@ -351,8 +414,12 @@ def test_getTotalGames_multiWeekMatchups(self): def test_getTotalGames_zeroIfNoGamesPlayed(self): owners, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[1].id, teamBId=teams[2].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -370,7 +437,9 @@ def test_getTotalGames_zeroIfNoGamesPlayed(self): def test_getTotalGames_onlyPostSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -402,8 +471,12 @@ def test_getTotalGames_onlyPostSeasonIsTrue(self): def test_getTotalGames_onlyRegularSeasonIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -418,7 +491,10 @@ def test_getTotalGames_onlyRegularSeasonIsTrue(self): yearSettings = YearSettings(leagueMedianGames=True) year = Year( - yearNumber=2000, teams=teams, weeks=[week1, week2, week3], yearSettings=yearSettings + yearNumber=2000, + teams=teams, + weeks=[week1, week2, week3], + yearSettings=yearSettings, ) response = TeamSummaryYearCalculator.getTotalGames(year, onlyRegularSeason=True) @@ -431,7 +507,9 @@ def test_getTotalGames_onlyRegularSeasonIsTrue(self): def test_getTotalGames_onlyChampionshipIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -463,9 +541,15 @@ def test_getTotalGames_onlyChampionshipIsTrue(self): def test_getTotalGames_weekNumberStartGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -473,7 +557,10 @@ def test_getTotalGames_weekNumberStartGiven(self): yearSettings = YearSettings(leagueMedianGames=True) year = Year( - yearNumber=2000, teams=teams, weeks=[week1, week2, week3], yearSettings=yearSettings + yearNumber=2000, + teams=teams, + weeks=[week1, week2, week3], + yearSettings=yearSettings, ) response = TeamSummaryYearCalculator.getTotalGames(year, weekNumberStart=2) @@ -486,8 +573,12 @@ def test_getTotalGames_weekNumberStartGiven(self): def test_getTotalGames_weekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -502,7 +593,10 @@ def test_getTotalGames_weekNumberEndGiven(self): yearSettings = YearSettings(leagueMedianGames=True) year = Year( - yearNumber=2000, teams=teams, weeks=[week1, week2, week3], yearSettings=yearSettings + yearNumber=2000, + teams=teams, + weeks=[week1, week2, week3], + yearSettings=yearSettings, ) response = TeamSummaryYearCalculator.getTotalGames(year, weekNumberEnd=2) @@ -515,10 +609,18 @@ def test_getTotalGames_weekNumberEndGiven(self): def test_getTotalGames_weekNumberStartGivenAndWeekNumberEndGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1) - matchup4 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1 + ) + matchup4 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -533,7 +635,9 @@ def test_getTotalGames_weekNumberStartGivenAndWeekNumberEndGiven(self): yearSettings=yearSettings, ) - response = TeamSummaryYearCalculator.getTotalGames(year, weekNumberStart=2, weekNumberEnd=3) + response = TeamSummaryYearCalculator.getTotalGames( + year, weekNumberStart=2, weekNumberEnd=3 + ) self.assertIsInstance(response, dict) self.assertEqual(2, len(response.keys())) diff --git a/test/test_decorator/test_validators.py b/test/test_decorator/test_validators.py index 70c5e300..a040a5de 100644 --- a/test/test_decorator/test_validators.py +++ b/test/test_decorator/test_validators.py @@ -1,12 +1,17 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams -from leeger.decorator.validators import validateLeague, validateMatchup, validateWeek, validateYear +from leeger.decorator.validators import ( + validateLeague, + validateMatchup, + validateWeek, + validateYear, +) from leeger.enum import MatchupType from leeger.model.league import Matchup from leeger.model.league.League import League from leeger.model.league.Week import Week from leeger.model.league.Year import Year +from test.helper.prototypes import getNDefaultOwnersAndTeams class TestValidators(unittest.TestCase): @@ -43,7 +48,9 @@ def dummyMatchupFunction(self, week: Week, **kwargs): def test_validateLeague_noLeagueParameterGiven_raisesException(self): with self.assertRaises(ValueError) as context: self.dummyLeagueFunction(None) - self.assertEqual("No valid League argument given to validate.", str(context.exception)) + self.assertEqual( + "No valid League argument given to validate.", str(context.exception) + ) def test_validateLeague_validateLeagueKwargIsFalse_doesntRunValidation(self): self.dummyLeagueFunction(None, validate=False) @@ -67,7 +74,9 @@ def test_validateLeague_happyPath(self): def test_validateYear_noYearParameterGiven_raisesException(self): with self.assertRaises(ValueError) as context: self.dummyYearFunction(None) - self.assertEqual("No valid Year argument given to validate.", str(context.exception)) + self.assertEqual( + "No valid Year argument given to validate.", str(context.exception) + ) def test_validateYear_validateYearKwargIsFalse_doesntRunValidation(self): self.dummyYearFunction(None, validate=False) @@ -90,7 +99,9 @@ def test_validateYear_happyPath(self): def test_validateWeek_noWeekParameterGiven_raisesException(self): with self.assertRaises(ValueError) as context: self.dummyWeekFunction(None) - self.assertEqual("No valid Week argument given to validate.", str(context.exception)) + self.assertEqual( + "No valid Week argument given to validate.", str(context.exception) + ) def test_validateWeek_validateWeekKwargIsFalse_doesntRunValidation(self): self.dummyWeekFunction(None, validate=False) @@ -112,7 +123,9 @@ def test_validateWeek_happyPath(self): def test_validateMatchup_noMatchupParameterGiven_raisesException(self): with self.assertRaises(ValueError) as context: self.dummyMatchupFunction(None) - self.assertEqual("No valid Matchup argument given to validate.", str(context.exception)) + self.assertEqual( + "No valid Matchup argument given to validate.", str(context.exception) + ) def test_validateMatchup_validateMatchupKwargIsFalse_doesntRunValidation(self): self.dummyMatchupFunction(None, validate=False) diff --git a/test/test_league_loader/test_ESPNLeagueLoader.py b/test/test_league_loader/test_ESPNLeagueLoader.py index 44bbd841..5a87b91f 100644 --- a/test/test_league_loader/test_ESPNLeagueLoader.py +++ b/test/test_league_loader/test_ESPNLeagueLoader.py @@ -19,7 +19,9 @@ def __getMockOwnersList(self, firstName: str, lastName: str) -> list[dict]: def test_loadLeague_nonIntPassingStringForLeagueId(self): with self.assertRaises(ValueError) as context: ESPNLeagueLoader("a", [2000]) - self.assertEqual("League ID 'a' could not be turned into an int.", str(context.exception)) + self.assertEqual( + "League ID 'a' could not be turned into an int.", str(context.exception) + ) @patch("espn_api.football.League") def test_load_league_happyPath(self, mockLeague): @@ -107,14 +109,54 @@ def test_load_league_happyPath(self, mockLeague): # Team1: 1 # Team7: 2 # Team3: 3 - mockTeam1_2022.schedule = [mockTeam2_2022, mockTeam3_2022, mockTeam4_2022, mockTeam7_2022] - mockTeam2_2022.schedule = [mockTeam1_2022, mockTeam4_2022, mockTeam5_2022, mockTeam3_2022] - mockTeam3_2022.schedule = [mockTeam4_2022, mockTeam1_2022, mockTeam7_2022, mockTeam2_2022] - mockTeam4_2022.schedule = [mockTeam3_2022, mockTeam2_2022, mockTeam1_2022, mockTeam5_2022] - mockTeam5_2022.schedule = [mockTeam6_2022, mockTeam7_2022, mockTeam2_2022, mockTeam4_2022] - mockTeam6_2022.schedule = [mockTeam5_2022, mockTeam8_2022, mockTeam8_2022, mockTeam8_2022] - mockTeam7_2022.schedule = [mockTeam8_2022, mockTeam5_2022, mockTeam3_2022, mockTeam1_2022] - mockTeam8_2022.schedule = [mockTeam7_2022, mockTeam6_2022, mockTeam6_2022, mockTeam6_2022] + mockTeam1_2022.schedule = [ + mockTeam2_2022, + mockTeam3_2022, + mockTeam4_2022, + mockTeam7_2022, + ] + mockTeam2_2022.schedule = [ + mockTeam1_2022, + mockTeam4_2022, + mockTeam5_2022, + mockTeam3_2022, + ] + mockTeam3_2022.schedule = [ + mockTeam4_2022, + mockTeam1_2022, + mockTeam7_2022, + mockTeam2_2022, + ] + mockTeam4_2022.schedule = [ + mockTeam3_2022, + mockTeam2_2022, + mockTeam1_2022, + mockTeam5_2022, + ] + mockTeam5_2022.schedule = [ + mockTeam6_2022, + mockTeam7_2022, + mockTeam2_2022, + mockTeam4_2022, + ] + mockTeam6_2022.schedule = [ + mockTeam5_2022, + mockTeam8_2022, + mockTeam8_2022, + mockTeam8_2022, + ] + mockTeam7_2022.schedule = [ + mockTeam8_2022, + mockTeam5_2022, + mockTeam3_2022, + mockTeam1_2022, + ] + mockTeam8_2022.schedule = [ + mockTeam7_2022, + mockTeam6_2022, + mockTeam6_2022, + mockTeam6_2022, + ] mockEspnLeague2022.teams = [ mockTeam1_2022, mockTeam2_2022, @@ -238,23 +280,55 @@ def test_load_league_happyPath(self, mockLeague): division1_2023 = Division(name="d1_2023") division2_2023 = Division(name="d2_2023") - team1_2022 = Team(ownerId=owner1.id, name="Team 1", divisionId=division1_2022.id) - team2_2022 = Team(ownerId=owner2.id, name="Team 2", divisionId=division1_2022.id) - team3_2022 = Team(ownerId=owner3.id, name="Team 3", divisionId=division1_2022.id) - team4_2022 = Team(ownerId=owner4.id, name="Team 4", divisionId=division1_2022.id) - team5_2022 = Team(ownerId=owner5.id, name="Team 5", divisionId=division2_2022.id) - team6_2022 = Team(ownerId=owner6.id, name="Team 6", divisionId=division2_2022.id) - team7_2022 = Team(ownerId=owner7.id, name="Team 7", divisionId=division2_2022.id) - team8_2022 = Team(ownerId=owner8.id, name="Team 8", divisionId=division2_2022.id) + team1_2022 = Team( + ownerId=owner1.id, name="Team 1", divisionId=division1_2022.id + ) + team2_2022 = Team( + ownerId=owner2.id, name="Team 2", divisionId=division1_2022.id + ) + team3_2022 = Team( + ownerId=owner3.id, name="Team 3", divisionId=division1_2022.id + ) + team4_2022 = Team( + ownerId=owner4.id, name="Team 4", divisionId=division1_2022.id + ) + team5_2022 = Team( + ownerId=owner5.id, name="Team 5", divisionId=division2_2022.id + ) + team6_2022 = Team( + ownerId=owner6.id, name="Team 6", divisionId=division2_2022.id + ) + team7_2022 = Team( + ownerId=owner7.id, name="Team 7", divisionId=division2_2022.id + ) + team8_2022 = Team( + ownerId=owner8.id, name="Team 8", divisionId=division2_2022.id + ) - team1_2023 = Team(ownerId=owner1.id, name="Team 1", divisionId=division1_2023.id) - team2_2023 = Team(ownerId=owner2.id, name="Team 2", divisionId=division1_2023.id) - team3_2023 = Team(ownerId=owner3.id, name="Team 3", divisionId=division1_2023.id) - team4_2023 = Team(ownerId=owner4.id, name="Team 4", divisionId=division1_2023.id) - team5_2023 = Team(ownerId=owner5.id, name="Team 5", divisionId=division2_2023.id) - team6_2023 = Team(ownerId=owner6.id, name="Team 6", divisionId=division2_2023.id) - team7_2023 = Team(ownerId=owner7.id, name="Team 7", divisionId=division2_2023.id) - team8_2023 = Team(ownerId=owner8.id, name="Team 8", divisionId=division2_2023.id) + team1_2023 = Team( + ownerId=owner1.id, name="Team 1", divisionId=division1_2023.id + ) + team2_2023 = Team( + ownerId=owner2.id, name="Team 2", divisionId=division1_2023.id + ) + team3_2023 = Team( + ownerId=owner3.id, name="Team 3", divisionId=division1_2023.id + ) + team4_2023 = Team( + ownerId=owner4.id, name="Team 4", divisionId=division1_2023.id + ) + team5_2023 = Team( + ownerId=owner5.id, name="Team 5", divisionId=division2_2023.id + ) + team6_2023 = Team( + ownerId=owner6.id, name="Team 6", divisionId=division2_2023.id + ) + team7_2023 = Team( + ownerId=owner7.id, name="Team 7", divisionId=division2_2023.id + ) + team8_2023 = Team( + ownerId=owner8.id, name="Team 8", divisionId=division2_2023.id + ) expectedLeague = League( name="Test League 2023", @@ -492,7 +566,9 @@ def test_load_league_happyPath(self, mockLeague): ), ], ) - self.assertTrue(league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True)) + self.assertTrue( + league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True) + ) # check multiWeekMatchupIds for year in league.years: for week in year.weeks: @@ -585,14 +661,54 @@ def test_load_league_happyPath_withOwnerNamesAndAliases(self, mockLeague): # Team1: 1 # Team7: 2 # Team3: 3 - mockTeam1_2022.schedule = [mockTeam2_2022, mockTeam3_2022, mockTeam4_2022, mockTeam7_2022] - mockTeam2_2022.schedule = [mockTeam1_2022, mockTeam4_2022, mockTeam5_2022, mockTeam3_2022] - mockTeam3_2022.schedule = [mockTeam4_2022, mockTeam1_2022, mockTeam7_2022, mockTeam2_2022] - mockTeam4_2022.schedule = [mockTeam3_2022, mockTeam2_2022, mockTeam1_2022, mockTeam5_2022] - mockTeam5_2022.schedule = [mockTeam6_2022, mockTeam7_2022, mockTeam2_2022, mockTeam4_2022] - mockTeam6_2022.schedule = [mockTeam5_2022, mockTeam8_2022, mockTeam8_2022, mockTeam8_2022] - mockTeam7_2022.schedule = [mockTeam8_2022, mockTeam5_2022, mockTeam3_2022, mockTeam1_2022] - mockTeam8_2022.schedule = [mockTeam7_2022, mockTeam6_2022, mockTeam6_2022, mockTeam6_2022] + mockTeam1_2022.schedule = [ + mockTeam2_2022, + mockTeam3_2022, + mockTeam4_2022, + mockTeam7_2022, + ] + mockTeam2_2022.schedule = [ + mockTeam1_2022, + mockTeam4_2022, + mockTeam5_2022, + mockTeam3_2022, + ] + mockTeam3_2022.schedule = [ + mockTeam4_2022, + mockTeam1_2022, + mockTeam7_2022, + mockTeam2_2022, + ] + mockTeam4_2022.schedule = [ + mockTeam3_2022, + mockTeam2_2022, + mockTeam1_2022, + mockTeam5_2022, + ] + mockTeam5_2022.schedule = [ + mockTeam6_2022, + mockTeam7_2022, + mockTeam2_2022, + mockTeam4_2022, + ] + mockTeam6_2022.schedule = [ + mockTeam5_2022, + mockTeam8_2022, + mockTeam8_2022, + mockTeam8_2022, + ] + mockTeam7_2022.schedule = [ + mockTeam8_2022, + mockTeam5_2022, + mockTeam3_2022, + mockTeam1_2022, + ] + mockTeam8_2022.schedule = [ + mockTeam7_2022, + mockTeam6_2022, + mockTeam6_2022, + mockTeam6_2022, + ] mockEspnLeague2022.teams = [ mockTeam1_2022, mockTeam2_2022, @@ -729,23 +845,55 @@ def test_load_league_happyPath_withOwnerNamesAndAliases(self, mockLeague): division1_2023 = Division(name="d1_2023") division2_2023 = Division(name="d2_2023") - team1_2022 = Team(ownerId=owner1.id, name="Team 1", divisionId=division1_2022.id) - team2_2022 = Team(ownerId=owner2.id, name="Team 2", divisionId=division1_2022.id) - team3_2022 = Team(ownerId=owner3.id, name="Team 3", divisionId=division1_2022.id) - team4_2022 = Team(ownerId=owner4.id, name="Team 4", divisionId=division1_2022.id) - team5_2022 = Team(ownerId=owner5.id, name="Team 5", divisionId=division2_2022.id) - team6_2022 = Team(ownerId=owner6.id, name="Team 6", divisionId=division2_2022.id) - team7_2022 = Team(ownerId=owner7.id, name="Team 7", divisionId=division2_2022.id) - team8_2022 = Team(ownerId=owner8.id, name="Team 8", divisionId=division2_2022.id) + team1_2022 = Team( + ownerId=owner1.id, name="Team 1", divisionId=division1_2022.id + ) + team2_2022 = Team( + ownerId=owner2.id, name="Team 2", divisionId=division1_2022.id + ) + team3_2022 = Team( + ownerId=owner3.id, name="Team 3", divisionId=division1_2022.id + ) + team4_2022 = Team( + ownerId=owner4.id, name="Team 4", divisionId=division1_2022.id + ) + team5_2022 = Team( + ownerId=owner5.id, name="Team 5", divisionId=division2_2022.id + ) + team6_2022 = Team( + ownerId=owner6.id, name="Team 6", divisionId=division2_2022.id + ) + team7_2022 = Team( + ownerId=owner7.id, name="Team 7", divisionId=division2_2022.id + ) + team8_2022 = Team( + ownerId=owner8.id, name="Team 8", divisionId=division2_2022.id + ) - team1_2023 = Team(ownerId=owner1.id, name="Team 1", divisionId=division1_2023.id) - team2_2023 = Team(ownerId=owner2.id, name="Team 2", divisionId=division1_2023.id) - team3_2023 = Team(ownerId=owner3.id, name="Team 3", divisionId=division1_2023.id) - team4_2023 = Team(ownerId=owner4.id, name="Team 4", divisionId=division1_2023.id) - team5_2023 = Team(ownerId=owner5.id, name="Team 5", divisionId=division2_2023.id) - team6_2023 = Team(ownerId=owner6.id, name="Team 6", divisionId=division2_2023.id) - team7_2023 = Team(ownerId=owner7.id, name="Team 7", divisionId=division2_2023.id) - team8_2023 = Team(ownerId=owner8.id, name="Team 8", divisionId=division2_2023.id) + team1_2023 = Team( + ownerId=owner1.id, name="Team 1", divisionId=division1_2023.id + ) + team2_2023 = Team( + ownerId=owner2.id, name="Team 2", divisionId=division1_2023.id + ) + team3_2023 = Team( + ownerId=owner3.id, name="Team 3", divisionId=division1_2023.id + ) + team4_2023 = Team( + ownerId=owner4.id, name="Team 4", divisionId=division1_2023.id + ) + team5_2023 = Team( + ownerId=owner5.id, name="Team 5", divisionId=division2_2023.id + ) + team6_2023 = Team( + ownerId=owner6.id, name="Team 6", divisionId=division2_2023.id + ) + team7_2023 = Team( + ownerId=owner7.id, name="Team 7", divisionId=division2_2023.id + ) + team8_2023 = Team( + ownerId=owner8.id, name="Team 8", divisionId=division2_2023.id + ) expectedLeague = League( name="Test League 2023", @@ -983,7 +1131,9 @@ def test_load_league_happyPath_withOwnerNamesAndAliases(self, mockLeague): ), ], ) - self.assertTrue(league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True)) + self.assertTrue( + league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True) + ) # check multiWeekMatchupIds for year in league.years: for week in year.weeks: @@ -1076,14 +1226,54 @@ def test_load_league_withLeagueName(self, mockLeague): # Team1: 1 # Team7: 2 # Team3: 3 - mockTeam1_2022.schedule = [mockTeam2_2022, mockTeam3_2022, mockTeam4_2022, mockTeam7_2022] - mockTeam2_2022.schedule = [mockTeam1_2022, mockTeam4_2022, mockTeam5_2022, mockTeam3_2022] - mockTeam3_2022.schedule = [mockTeam4_2022, mockTeam1_2022, mockTeam7_2022, mockTeam2_2022] - mockTeam4_2022.schedule = [mockTeam3_2022, mockTeam2_2022, mockTeam1_2022, mockTeam5_2022] - mockTeam5_2022.schedule = [mockTeam6_2022, mockTeam7_2022, mockTeam2_2022, mockTeam4_2022] - mockTeam6_2022.schedule = [mockTeam5_2022, mockTeam8_2022, mockTeam8_2022, mockTeam8_2022] - mockTeam7_2022.schedule = [mockTeam8_2022, mockTeam5_2022, mockTeam3_2022, mockTeam1_2022] - mockTeam8_2022.schedule = [mockTeam7_2022, mockTeam6_2022, mockTeam6_2022, mockTeam6_2022] + mockTeam1_2022.schedule = [ + mockTeam2_2022, + mockTeam3_2022, + mockTeam4_2022, + mockTeam7_2022, + ] + mockTeam2_2022.schedule = [ + mockTeam1_2022, + mockTeam4_2022, + mockTeam5_2022, + mockTeam3_2022, + ] + mockTeam3_2022.schedule = [ + mockTeam4_2022, + mockTeam1_2022, + mockTeam7_2022, + mockTeam2_2022, + ] + mockTeam4_2022.schedule = [ + mockTeam3_2022, + mockTeam2_2022, + mockTeam1_2022, + mockTeam5_2022, + ] + mockTeam5_2022.schedule = [ + mockTeam6_2022, + mockTeam7_2022, + mockTeam2_2022, + mockTeam4_2022, + ] + mockTeam6_2022.schedule = [ + mockTeam5_2022, + mockTeam8_2022, + mockTeam8_2022, + mockTeam8_2022, + ] + mockTeam7_2022.schedule = [ + mockTeam8_2022, + mockTeam5_2022, + mockTeam3_2022, + mockTeam1_2022, + ] + mockTeam8_2022.schedule = [ + mockTeam7_2022, + mockTeam6_2022, + mockTeam6_2022, + mockTeam6_2022, + ] mockEspnLeague2022.teams = [ mockTeam1_2022, mockTeam2_2022, diff --git a/test/test_league_loader/test_FleaflickerLeagueLoader.py b/test/test_league_loader/test_FleaflickerLeagueLoader.py index f7bcd1e8..054d9ce1 100644 --- a/test/test_league_loader/test_FleaflickerLeagueLoader.py +++ b/test/test_league_loader/test_FleaflickerLeagueLoader.py @@ -16,40 +16,122 @@ class TestFleaflickerLeagueLoader(unittest.TestCase): def test_init_leagueIdNotIntConvertable_raisesException(self): with self.assertRaises(ValueError) as context: FleaflickerLeagueLoader("foo", []) - self.assertEqual("League ID 'foo' could not be turned into an int.", str(context.exception)) + self.assertEqual( + "League ID 'foo' could not be turned into an int.", str(context.exception) + ) - @mock.patch("fleaflicker.api.LeagueInfoAPIClient.LeagueInfoAPIClient.get_league_standings") - @mock.patch("fleaflicker.api.ScoringAPIClient.ScoringAPIClient.get_league_scoreboard") - def test_loadLeague_happyPath(self, mockGetLeagueScoreboard, mockGetLeaguestandings): - mockTeam1_2022 = {"owners": [{"displayName": "Owner 1"}], "id": 1, "name": "Team 1"} - mockTeam2_2022 = {"owners": [{"displayName": "Owner 2"}], "id": 2, "name": "Team 2"} - mockTeam3_2022 = {"owners": [{"displayName": "Owner 3"}], "id": 3, "name": "Team 3"} - mockTeam4_2022 = {"owners": [{"displayName": "Owner 4"}], "id": 4, "name": "Team 4"} - mockTeam5_2022 = {"owners": [{"displayName": "Owner 5"}], "id": 5, "name": "Team 5"} - mockTeam6_2022 = {"owners": [{"displayName": "Owner 6"}], "id": 6, "name": "Team 6"} - mockTeam7_2022 = {"owners": [{"displayName": "Owner 7"}], "id": 7, "name": "Team 7"} - mockTeam8_2022 = {"owners": [{"displayName": "Owner 8"}], "id": 8, "name": "Team 8"} + @mock.patch( + "fleaflicker.api.LeagueInfoAPIClient.LeagueInfoAPIClient.get_league_standings" + ) + @mock.patch( + "fleaflicker.api.ScoringAPIClient.ScoringAPIClient.get_league_scoreboard" + ) + def test_loadLeague_happyPath( + self, mockGetLeagueScoreboard, mockGetLeaguestandings + ): + mockTeam1_2022 = { + "owners": [{"displayName": "Owner 1"}], + "id": 1, + "name": "Team 1", + } + mockTeam2_2022 = { + "owners": [{"displayName": "Owner 2"}], + "id": 2, + "name": "Team 2", + } + mockTeam3_2022 = { + "owners": [{"displayName": "Owner 3"}], + "id": 3, + "name": "Team 3", + } + mockTeam4_2022 = { + "owners": [{"displayName": "Owner 4"}], + "id": 4, + "name": "Team 4", + } + mockTeam5_2022 = { + "owners": [{"displayName": "Owner 5"}], + "id": 5, + "name": "Team 5", + } + mockTeam6_2022 = { + "owners": [{"displayName": "Owner 6"}], + "id": 6, + "name": "Team 6", + } + mockTeam7_2022 = { + "owners": [{"displayName": "Owner 7"}], + "id": 7, + "name": "Team 7", + } + mockTeam8_2022 = { + "owners": [{"displayName": "Owner 8"}], + "id": 8, + "name": "Team 8", + } - mockTeam1_2023 = {"owners": [{"displayName": "Owner 1"}], "id": 1, "name": "Team 1"} - mockTeam2_2023 = {"owners": [{"displayName": "Owner 2"}], "id": 2, "name": "Team 2"} - mockTeam3_2023 = {"owners": [{"displayName": "Owner 3"}], "id": 3, "name": "Team 3"} - mockTeam4_2023 = {"owners": [{"displayName": "Owner 4"}], "id": 4, "name": "Team 4"} - mockTeam5_2023 = {"owners": [{"displayName": "Owner 5"}], "id": 5, "name": "Team 5"} - mockTeam6_2023 = {"owners": [{"displayName": "Owner 6"}], "id": 6, "name": "Team 6"} - mockTeam7_2023 = {"owners": [{"displayName": "Owner 7"}], "id": 7, "name": "Team 7"} - mockTeam8_2023 = {"owners": [{"displayName": "Owner 8"}], "id": 8, "name": "Team 8"} + mockTeam1_2023 = { + "owners": [{"displayName": "Owner 1"}], + "id": 1, + "name": "Team 1", + } + mockTeam2_2023 = { + "owners": [{"displayName": "Owner 2"}], + "id": 2, + "name": "Team 2", + } + mockTeam3_2023 = { + "owners": [{"displayName": "Owner 3"}], + "id": 3, + "name": "Team 3", + } + mockTeam4_2023 = { + "owners": [{"displayName": "Owner 4"}], + "id": 4, + "name": "Team 4", + } + mockTeam5_2023 = { + "owners": [{"displayName": "Owner 5"}], + "id": 5, + "name": "Team 5", + } + mockTeam6_2023 = { + "owners": [{"displayName": "Owner 6"}], + "id": 6, + "name": "Team 6", + } + mockTeam7_2023 = { + "owners": [{"displayName": "Owner 7"}], + "id": 7, + "name": "Team 7", + } + mockTeam8_2023 = { + "owners": [{"displayName": "Owner 8"}], + "id": 8, + "name": "Team 8", + } mockLeagueStandings2022 = { "divisions": [ { "id": 1, "name": "d1_2022", - "teams": [mockTeam1_2022, mockTeam2_2022, mockTeam3_2022, mockTeam4_2022], + "teams": [ + mockTeam1_2022, + mockTeam2_2022, + mockTeam3_2022, + mockTeam4_2022, + ], }, { "id": 2, "name": "d2_2022", - "teams": [mockTeam5_2022, mockTeam6_2022, mockTeam7_2022, mockTeam8_2022], + "teams": [ + mockTeam5_2022, + mockTeam6_2022, + mockTeam7_2022, + mockTeam8_2022, + ], }, ], "league": {"name": "Test League 2022", "id": 123}, @@ -227,7 +309,10 @@ def test_loadLeague_happyPath(self, mockGetLeagueScoreboard, mockGetLeaguestandi "eligibleSchedulePeriods": [mockWeek1_2023, mockWeek2_2023, mockWeek3_2023] } - mockGetLeaguestandings.side_effect = [mockLeagueStandings2022, mockLeagueStandings2023] + mockGetLeaguestandings.side_effect = [ + mockLeagueStandings2022, + mockLeagueStandings2023, + ] mockGetLeagueScoreboard.side_effect = [ mockScoreboard2022, mockWeek1_2022, @@ -257,23 +342,55 @@ def test_loadLeague_happyPath(self, mockGetLeagueScoreboard, mockGetLeaguestandi owner7 = Owner(name="Owner 7") owner8 = Owner(name="Owner 8") - team1_2022 = Team(ownerId=owner1.id, name="Team 1", divisionId=division1_2022.id) - team2_2022 = Team(ownerId=owner2.id, name="Team 2", divisionId=division1_2022.id) - team3_2022 = Team(ownerId=owner3.id, name="Team 3", divisionId=division1_2022.id) - team4_2022 = Team(ownerId=owner4.id, name="Team 4", divisionId=division1_2022.id) - team5_2022 = Team(ownerId=owner5.id, name="Team 5", divisionId=division2_2022.id) - team6_2022 = Team(ownerId=owner6.id, name="Team 6", divisionId=division2_2022.id) - team7_2022 = Team(ownerId=owner7.id, name="Team 7", divisionId=division2_2022.id) - team8_2022 = Team(ownerId=owner8.id, name="Team 8", divisionId=division2_2022.id) + team1_2022 = Team( + ownerId=owner1.id, name="Team 1", divisionId=division1_2022.id + ) + team2_2022 = Team( + ownerId=owner2.id, name="Team 2", divisionId=division1_2022.id + ) + team3_2022 = Team( + ownerId=owner3.id, name="Team 3", divisionId=division1_2022.id + ) + team4_2022 = Team( + ownerId=owner4.id, name="Team 4", divisionId=division1_2022.id + ) + team5_2022 = Team( + ownerId=owner5.id, name="Team 5", divisionId=division2_2022.id + ) + team6_2022 = Team( + ownerId=owner6.id, name="Team 6", divisionId=division2_2022.id + ) + team7_2022 = Team( + ownerId=owner7.id, name="Team 7", divisionId=division2_2022.id + ) + team8_2022 = Team( + ownerId=owner8.id, name="Team 8", divisionId=division2_2022.id + ) - team1_2023 = Team(ownerId=owner1.id, name="Team 1", divisionId=division1_2023.id) - team2_2023 = Team(ownerId=owner2.id, name="Team 2", divisionId=division1_2023.id) - team3_2023 = Team(ownerId=owner3.id, name="Team 3", divisionId=division1_2023.id) - team4_2023 = Team(ownerId=owner4.id, name="Team 4", divisionId=division1_2023.id) - team5_2023 = Team(ownerId=owner5.id, name="Team 5", divisionId=division1_2023.id) - team6_2023 = Team(ownerId=owner6.id, name="Team 6", divisionId=division1_2023.id) - team7_2023 = Team(ownerId=owner7.id, name="Team 7", divisionId=division1_2023.id) - team8_2023 = Team(ownerId=owner8.id, name="Team 8", divisionId=division1_2023.id) + team1_2023 = Team( + ownerId=owner1.id, name="Team 1", divisionId=division1_2023.id + ) + team2_2023 = Team( + ownerId=owner2.id, name="Team 2", divisionId=division1_2023.id + ) + team3_2023 = Team( + ownerId=owner3.id, name="Team 3", divisionId=division1_2023.id + ) + team4_2023 = Team( + ownerId=owner4.id, name="Team 4", divisionId=division1_2023.id + ) + team5_2023 = Team( + ownerId=owner5.id, name="Team 5", divisionId=division1_2023.id + ) + team6_2023 = Team( + ownerId=owner6.id, name="Team 6", divisionId=division1_2023.id + ) + team7_2023 = Team( + ownerId=owner7.id, name="Team 7", divisionId=division1_2023.id + ) + team8_2023 = Team( + ownerId=owner8.id, name="Team 8", divisionId=division1_2023.id + ) expectedLeague = League( name="Test League 2023", @@ -454,47 +571,127 @@ def test_loadLeague_happyPath(self, mockGetLeagueScoreboard, mockGetLeaguestandi ], ) - self.assertTrue(league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True)) + self.assertTrue( + league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True) + ) # check multiWeekMatchupIds for year in league.years: for week in year.weeks: for matchup in week.matchups: self.assertIsNone(matchup.multiWeekMatchupId) - @mock.patch("fleaflicker.api.LeagueInfoAPIClient.LeagueInfoAPIClient.get_league_standings") - @mock.patch("fleaflicker.api.ScoringAPIClient.ScoringAPIClient.get_league_scoreboard") + @mock.patch( + "fleaflicker.api.LeagueInfoAPIClient.LeagueInfoAPIClient.get_league_standings" + ) + @mock.patch( + "fleaflicker.api.ScoringAPIClient.ScoringAPIClient.get_league_scoreboard" + ) def test_loadLeague_happyPath_withOwnerNamesAndAliases( self, mockGetLeagueScoreboard, mockGetLeaguestandings ): - mockTeam1_2022 = {"owners": [{"displayName": "Owner 1"}], "id": 1, "name": "Team 1"} - mockTeam2_2022 = {"owners": [{"displayName": "Owner 2"}], "id": 2, "name": "Team 2"} - mockTeam3_2022 = {"owners": [{"displayName": "Owner 3"}], "id": 3, "name": "Team 3"} - mockTeam4_2022 = {"owners": [{"displayName": "Owner 4"}], "id": 4, "name": "Team 4"} - mockTeam5_2022 = {"owners": [{"displayName": "Owner 5"}], "id": 5, "name": "Team 5"} - mockTeam6_2022 = {"owners": [{"displayName": "Owner 6"}], "id": 6, "name": "Team 6"} - mockTeam7_2022 = {"owners": [{"displayName": "Owner 7"}], "id": 7, "name": "Team 7"} - mockTeam8_2022 = {"owners": [{"displayName": "Owner 8"}], "id": 8, "name": "Team 8"} + mockTeam1_2022 = { + "owners": [{"displayName": "Owner 1"}], + "id": 1, + "name": "Team 1", + } + mockTeam2_2022 = { + "owners": [{"displayName": "Owner 2"}], + "id": 2, + "name": "Team 2", + } + mockTeam3_2022 = { + "owners": [{"displayName": "Owner 3"}], + "id": 3, + "name": "Team 3", + } + mockTeam4_2022 = { + "owners": [{"displayName": "Owner 4"}], + "id": 4, + "name": "Team 4", + } + mockTeam5_2022 = { + "owners": [{"displayName": "Owner 5"}], + "id": 5, + "name": "Team 5", + } + mockTeam6_2022 = { + "owners": [{"displayName": "Owner 6"}], + "id": 6, + "name": "Team 6", + } + mockTeam7_2022 = { + "owners": [{"displayName": "Owner 7"}], + "id": 7, + "name": "Team 7", + } + mockTeam8_2022 = { + "owners": [{"displayName": "Owner 8"}], + "id": 8, + "name": "Team 8", + } - mockTeam1_2023 = {"owners": [{"displayName": "Owner 1"}], "id": 1, "name": "Team 1"} - mockTeam2_2023 = {"owners": [{"displayName": "Owner 2"}], "id": 2, "name": "Team 2"} - mockTeam3_2023 = {"owners": [{"displayName": "Owner 3"}], "id": 3, "name": "Team 3"} - mockTeam4_2023 = {"owners": [{"displayName": "Owner 4"}], "id": 4, "name": "Team 4"} - mockTeam5_2023 = {"owners": [{"displayName": "Owner 5"}], "id": 5, "name": "Team 5"} - mockTeam6_2023 = {"owners": [{"displayName": "Owner 6"}], "id": 6, "name": "Team 6"} - mockTeam7_2023 = {"owners": [{"displayName": "Owner 7"}], "id": 7, "name": "Team 7"} - mockTeam8_2023 = {"owners": [{"displayName": "Owner 8"}], "id": 8, "name": "Team 8"} + mockTeam1_2023 = { + "owners": [{"displayName": "Owner 1"}], + "id": 1, + "name": "Team 1", + } + mockTeam2_2023 = { + "owners": [{"displayName": "Owner 2"}], + "id": 2, + "name": "Team 2", + } + mockTeam3_2023 = { + "owners": [{"displayName": "Owner 3"}], + "id": 3, + "name": "Team 3", + } + mockTeam4_2023 = { + "owners": [{"displayName": "Owner 4"}], + "id": 4, + "name": "Team 4", + } + mockTeam5_2023 = { + "owners": [{"displayName": "Owner 5"}], + "id": 5, + "name": "Team 5", + } + mockTeam6_2023 = { + "owners": [{"displayName": "Owner 6"}], + "id": 6, + "name": "Team 6", + } + mockTeam7_2023 = { + "owners": [{"displayName": "Owner 7"}], + "id": 7, + "name": "Team 7", + } + mockTeam8_2023 = { + "owners": [{"displayName": "Owner 8"}], + "id": 8, + "name": "Team 8", + } mockLeagueStandings2022 = { "divisions": [ { "id": 1, "name": "d1_2022", - "teams": [mockTeam1_2022, mockTeam2_2022, mockTeam3_2022, mockTeam4_2022], + "teams": [ + mockTeam1_2022, + mockTeam2_2022, + mockTeam3_2022, + mockTeam4_2022, + ], }, { "id": 2, "name": "d2_2022", - "teams": [mockTeam5_2022, mockTeam6_2022, mockTeam7_2022, mockTeam8_2022], + "teams": [ + mockTeam5_2022, + mockTeam6_2022, + mockTeam7_2022, + mockTeam8_2022, + ], }, ], "league": {"name": "Test League 2022", "id": 123}, @@ -672,7 +869,10 @@ def test_loadLeague_happyPath_withOwnerNamesAndAliases( "eligibleSchedulePeriods": [mockWeek1_2023, mockWeek2_2023, mockWeek3_2023] } - mockGetLeaguestandings.side_effect = [mockLeagueStandings2022, mockLeagueStandings2023] + mockGetLeaguestandings.side_effect = [ + mockLeagueStandings2022, + mockLeagueStandings2023, + ] mockGetLeagueScoreboard.side_effect = [ mockScoreboard2022, mockWeek1_2022, @@ -715,23 +915,55 @@ def test_loadLeague_happyPath_withOwnerNamesAndAliases( owner7 = Owner(name="o7") owner8 = Owner(name="o8") - team1_2022 = Team(ownerId=owner1.id, name="Team 1", divisionId=division1_2022.id) - team2_2022 = Team(ownerId=owner2.id, name="Team 2", divisionId=division1_2022.id) - team3_2022 = Team(ownerId=owner3.id, name="Team 3", divisionId=division1_2022.id) - team4_2022 = Team(ownerId=owner4.id, name="Team 4", divisionId=division1_2022.id) - team5_2022 = Team(ownerId=owner5.id, name="Team 5", divisionId=division2_2022.id) - team6_2022 = Team(ownerId=owner6.id, name="Team 6", divisionId=division2_2022.id) - team7_2022 = Team(ownerId=owner7.id, name="Team 7", divisionId=division2_2022.id) - team8_2022 = Team(ownerId=owner8.id, name="Team 8", divisionId=division2_2022.id) + team1_2022 = Team( + ownerId=owner1.id, name="Team 1", divisionId=division1_2022.id + ) + team2_2022 = Team( + ownerId=owner2.id, name="Team 2", divisionId=division1_2022.id + ) + team3_2022 = Team( + ownerId=owner3.id, name="Team 3", divisionId=division1_2022.id + ) + team4_2022 = Team( + ownerId=owner4.id, name="Team 4", divisionId=division1_2022.id + ) + team5_2022 = Team( + ownerId=owner5.id, name="Team 5", divisionId=division2_2022.id + ) + team6_2022 = Team( + ownerId=owner6.id, name="Team 6", divisionId=division2_2022.id + ) + team7_2022 = Team( + ownerId=owner7.id, name="Team 7", divisionId=division2_2022.id + ) + team8_2022 = Team( + ownerId=owner8.id, name="Team 8", divisionId=division2_2022.id + ) - team1_2023 = Team(ownerId=owner1.id, name="Team 1", divisionId=division1_2023.id) - team2_2023 = Team(ownerId=owner2.id, name="Team 2", divisionId=division1_2023.id) - team3_2023 = Team(ownerId=owner3.id, name="Team 3", divisionId=division1_2023.id) - team4_2023 = Team(ownerId=owner4.id, name="Team 4", divisionId=division1_2023.id) - team5_2023 = Team(ownerId=owner5.id, name="Team 5", divisionId=division1_2023.id) - team6_2023 = Team(ownerId=owner6.id, name="Team 6", divisionId=division1_2023.id) - team7_2023 = Team(ownerId=owner7.id, name="Team 7", divisionId=division1_2023.id) - team8_2023 = Team(ownerId=owner8.id, name="Team 8", divisionId=division1_2023.id) + team1_2023 = Team( + ownerId=owner1.id, name="Team 1", divisionId=division1_2023.id + ) + team2_2023 = Team( + ownerId=owner2.id, name="Team 2", divisionId=division1_2023.id + ) + team3_2023 = Team( + ownerId=owner3.id, name="Team 3", divisionId=division1_2023.id + ) + team4_2023 = Team( + ownerId=owner4.id, name="Team 4", divisionId=division1_2023.id + ) + team5_2023 = Team( + ownerId=owner5.id, name="Team 5", divisionId=division1_2023.id + ) + team6_2023 = Team( + ownerId=owner6.id, name="Team 6", divisionId=division1_2023.id + ) + team7_2023 = Team( + ownerId=owner7.id, name="Team 7", divisionId=division1_2023.id + ) + team8_2023 = Team( + ownerId=owner8.id, name="Team 8", divisionId=division1_2023.id + ) expectedLeague = League( name="Test League 2023", @@ -912,45 +1144,127 @@ def test_loadLeague_happyPath_withOwnerNamesAndAliases( ], ) - self.assertTrue(league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True)) + self.assertTrue( + league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True) + ) # check multiWeekMatchupIds for year in league.years: for week in year.weeks: for matchup in week.matchups: self.assertIsNone(matchup.multiWeekMatchupId) - @mock.patch("fleaflicker.api.LeagueInfoAPIClient.LeagueInfoAPIClient.get_league_standings") - @mock.patch("fleaflicker.api.ScoringAPIClient.ScoringAPIClient.get_league_scoreboard") - def test_loadLeague_withLeagueName(self, mockGetLeagueScoreboard, mockGetLeaguestandings): - mockTeam1_2022 = {"owners": [{"displayName": "Owner 1"}], "id": 1, "name": "Team 1"} - mockTeam2_2022 = {"owners": [{"displayName": "Owner 2"}], "id": 2, "name": "Team 2"} - mockTeam3_2022 = {"owners": [{"displayName": "Owner 3"}], "id": 3, "name": "Team 3"} - mockTeam4_2022 = {"owners": [{"displayName": "Owner 4"}], "id": 4, "name": "Team 4"} - mockTeam5_2022 = {"owners": [{"displayName": "Owner 5"}], "id": 5, "name": "Team 5"} - mockTeam6_2022 = {"owners": [{"displayName": "Owner 6"}], "id": 6, "name": "Team 6"} - mockTeam7_2022 = {"owners": [{"displayName": "Owner 7"}], "id": 7, "name": "Team 7"} - mockTeam8_2022 = {"owners": [{"displayName": "Owner 8"}], "id": 8, "name": "Team 8"} + @mock.patch( + "fleaflicker.api.LeagueInfoAPIClient.LeagueInfoAPIClient.get_league_standings" + ) + @mock.patch( + "fleaflicker.api.ScoringAPIClient.ScoringAPIClient.get_league_scoreboard" + ) + def test_loadLeague_withLeagueName( + self, mockGetLeagueScoreboard, mockGetLeaguestandings + ): + mockTeam1_2022 = { + "owners": [{"displayName": "Owner 1"}], + "id": 1, + "name": "Team 1", + } + mockTeam2_2022 = { + "owners": [{"displayName": "Owner 2"}], + "id": 2, + "name": "Team 2", + } + mockTeam3_2022 = { + "owners": [{"displayName": "Owner 3"}], + "id": 3, + "name": "Team 3", + } + mockTeam4_2022 = { + "owners": [{"displayName": "Owner 4"}], + "id": 4, + "name": "Team 4", + } + mockTeam5_2022 = { + "owners": [{"displayName": "Owner 5"}], + "id": 5, + "name": "Team 5", + } + mockTeam6_2022 = { + "owners": [{"displayName": "Owner 6"}], + "id": 6, + "name": "Team 6", + } + mockTeam7_2022 = { + "owners": [{"displayName": "Owner 7"}], + "id": 7, + "name": "Team 7", + } + mockTeam8_2022 = { + "owners": [{"displayName": "Owner 8"}], + "id": 8, + "name": "Team 8", + } - mockTeam1_2023 = {"owners": [{"displayName": "Owner 1"}], "id": 1, "name": "Team 1"} - mockTeam2_2023 = {"owners": [{"displayName": "Owner 2"}], "id": 2, "name": "Team 2"} - mockTeam3_2023 = {"owners": [{"displayName": "Owner 3"}], "id": 3, "name": "Team 3"} - mockTeam4_2023 = {"owners": [{"displayName": "Owner 4"}], "id": 4, "name": "Team 4"} - mockTeam5_2023 = {"owners": [{"displayName": "Owner 5"}], "id": 5, "name": "Team 5"} - mockTeam6_2023 = {"owners": [{"displayName": "Owner 6"}], "id": 6, "name": "Team 6"} - mockTeam7_2023 = {"owners": [{"displayName": "Owner 7"}], "id": 7, "name": "Team 7"} - mockTeam8_2023 = {"owners": [{"displayName": "Owner 8"}], "id": 8, "name": "Team 8"} + mockTeam1_2023 = { + "owners": [{"displayName": "Owner 1"}], + "id": 1, + "name": "Team 1", + } + mockTeam2_2023 = { + "owners": [{"displayName": "Owner 2"}], + "id": 2, + "name": "Team 2", + } + mockTeam3_2023 = { + "owners": [{"displayName": "Owner 3"}], + "id": 3, + "name": "Team 3", + } + mockTeam4_2023 = { + "owners": [{"displayName": "Owner 4"}], + "id": 4, + "name": "Team 4", + } + mockTeam5_2023 = { + "owners": [{"displayName": "Owner 5"}], + "id": 5, + "name": "Team 5", + } + mockTeam6_2023 = { + "owners": [{"displayName": "Owner 6"}], + "id": 6, + "name": "Team 6", + } + mockTeam7_2023 = { + "owners": [{"displayName": "Owner 7"}], + "id": 7, + "name": "Team 7", + } + mockTeam8_2023 = { + "owners": [{"displayName": "Owner 8"}], + "id": 8, + "name": "Team 8", + } mockLeagueStandings2022 = { "divisions": [ { "id": 1, "name": "d1_2022", - "teams": [mockTeam1_2022, mockTeam2_2022, mockTeam3_2022, mockTeam4_2022], + "teams": [ + mockTeam1_2022, + mockTeam2_2022, + mockTeam3_2022, + mockTeam4_2022, + ], }, { "id": 2, "name": "d2_2022", - "teams": [mockTeam5_2022, mockTeam6_2022, mockTeam7_2022, mockTeam8_2022], + "teams": [ + mockTeam5_2022, + mockTeam6_2022, + mockTeam7_2022, + mockTeam8_2022, + ], }, ], "league": {"name": "Test League 2022", "id": 123}, @@ -1128,7 +1442,10 @@ def test_loadLeague_withLeagueName(self, mockGetLeagueScoreboard, mockGetLeagues "eligibleSchedulePeriods": [mockWeek1_2023, mockWeek2_2023, mockWeek3_2023] } - mockGetLeaguestandings.side_effect = [mockLeagueStandings2022, mockLeagueStandings2023] + mockGetLeaguestandings.side_effect = [ + mockLeagueStandings2022, + mockLeagueStandings2023, + ] mockGetLeagueScoreboard.side_effect = [ mockScoreboard2022, mockWeek1_2022, @@ -1140,7 +1457,9 @@ def test_loadLeague_withLeagueName(self, mockGetLeagueScoreboard, mockGetLeagues mockWeek3_2023, ] - leagueLoader = FleaflickerLeagueLoader("123", [2022, 2023], leagueName="custom name") + leagueLoader = FleaflickerLeagueLoader( + "123", [2022, 2023], leagueName="custom name" + ) league = leagueLoader.loadLeague() self.assertEqual("custom name", league.name) diff --git a/test/test_league_loader/test_LeagueLoader.py b/test/test_league_loader/test_LeagueLoader.py index 768e55ad..3fa8baf7 100644 --- a/test/test_league_loader/test_LeagueLoader.py +++ b/test/test_league_loader/test_LeagueLoader.py @@ -13,7 +13,9 @@ class TestLeagueLoader(unittest.TestCase): def test_noYearsGiven(self): with self.assertRaises(ValueError) as context: LeagueLoader("0", []) - self.assertEqual("No years given to load league with ID '0'.", str(context.exception)) + self.assertEqual( + "No years given to load league with ID '0'.", str(context.exception) + ) def test_yearsGivenThatArentInts(self): with self.assertRaises(ValueError) as context: @@ -47,22 +49,32 @@ def test__getGeneralOwnerNameFromGivenOwnerName(self): ) # alias that belongs to a single owner - self.assertEqual("John Smith", leagueLoader._getGeneralOwnerNameFromGivenOwnerName("John")) + self.assertEqual( + "John Smith", leagueLoader._getGeneralOwnerNameFromGivenOwnerName("John") + ) # alias that belongs to multiple owners - self.assertEqual("John Smith", leagueLoader._getGeneralOwnerNameFromGivenOwnerName("Smith")) + self.assertEqual( + "John Smith", leagueLoader._getGeneralOwnerNameFromGivenOwnerName("Smith") + ) # alias that does not belong to any owner self.assertIsNone(leagueLoader._getGeneralOwnerNameFromGivenOwnerName("Foo")) # owner name that is also an owner name but NOT an alias - self.assertIsNone(leagueLoader._getGeneralOwnerNameFromGivenOwnerName("John Smith")) + self.assertIsNone( + leagueLoader._getGeneralOwnerNameFromGivenOwnerName("John Smith") + ) # owner name that is not in the aliases list self.assertIsNone(leagueLoader._getGeneralOwnerNameFromGivenOwnerName("Foo")) def test__getOwnerByName(self): - owners = [Owner(name="John Smith"), Owner(name="Jane Doe"), Owner(name="Tom Hanks")] + owners = [ + Owner(name="John Smith"), + Owner(name="Jane Doe"), + Owner(name="Tom Hanks"), + ] leagueLoader = LeagueLoader( "leagueId", [2021], @@ -174,7 +186,12 @@ def test__warnForUnusedOwnerNames(self): leagueLoader = LeagueLoader( "leagueId", [2020], - ownerNamesAndAliases={"o1": list(), "o2": list(), "o3": list(), "o4": list()}, + ownerNamesAndAliases={ + "o1": list(), + "o2": list(), + "o3": list(), + "o4": list(), + }, ) with self.assertLogs() as captured: diff --git a/test/test_league_loader/test_MyFantasyLeagueLeagueLoader.py b/test/test_league_loader/test_MyFantasyLeagueLeagueLoader.py index 8205b378..fb562719 100644 --- a/test/test_league_loader/test_MyFantasyLeagueLeagueLoader.py +++ b/test/test_league_loader/test_MyFantasyLeagueLeagueLoader.py @@ -36,32 +36,152 @@ def test_loadLeague_happyPath( - having 1 playoff matchup in a playoff week (dict) - having multiple playoff matchups in a playoff week (list) """ - mockFranchise1_2022 = {"owner_name": "Owner 1", "name": "Team 1", "id": 1, "division": "1"} - mockFranchise2_2022 = {"owner_name": "Owner 2", "name": "Team 2", "id": 2, "division": "1"} - mockFranchise3_2022 = {"owner_name": "Owner 3", "name": "Team 3", "id": 3, "division": "1"} - mockFranchise4_2022 = {"owner_name": "Owner 4", "name": "Team 4", "id": 4, "division": "1"} - mockFranchise5_2022 = {"owner_name": "Owner 5", "name": "Team 5", "id": 5, "division": "2"} - mockFranchise6_2022 = {"owner_name": "Owner 6", "name": "Team 6", "id": 6, "division": "2"} - mockFranchise7_2022 = {"owner_name": "Owner 7", "name": "Team 7", "id": 7, "division": "2"} - mockFranchise8_2022 = {"owner_name": "Owner 8", "name": "Team 8", "id": 8, "division": "2"} - - mockFranchise1_2023 = {"owner_name": "Owner 1", "name": "Team 1", "id": 1, "division": "1"} - mockFranchise2_2023 = {"owner_name": "Owner 2", "name": "Team 2", "id": 2, "division": "1"} - mockFranchise3_2023 = {"owner_name": "Owner 3", "name": "Team 3", "id": 3, "division": "1"} - mockFranchise4_2023 = {"owner_name": "Owner 4", "name": "Team 4", "id": 4, "division": "1"} - mockFranchise5_2023 = {"owner_name": "Owner 5", "name": "Team 5", "id": 5, "division": "2"} - mockFranchise6_2023 = {"owner_name": "Owner 6", "name": "Team 6", "id": 6, "division": "2"} - mockFranchise7_2023 = {"owner_name": "Owner 7", "name": "Team 7", "id": 7, "division": "2"} - mockFranchise8_2023 = {"owner_name": "Owner 8", "name": "Team 8", "id": 8, "division": "2"} - - mockFranchise1_2024 = {"owner_name": "Owner 1", "name": "Team 1", "id": 1, "division": "1"} - mockFranchise2_2024 = {"owner_name": "Owner 2", "name": "Team 2", "id": 2, "division": "1"} - mockFranchise3_2024 = {"owner_name": "Owner 3", "name": "Team 3", "id": 3, "division": "1"} - mockFranchise4_2024 = {"owner_name": "Owner 4", "name": "Team 4", "id": 4, "division": "1"} - mockFranchise5_2024 = {"owner_name": "Owner 5", "name": "Team 5", "id": 5, "division": "2"} - mockFranchise6_2024 = {"owner_name": "Owner 6", "name": "Team 6", "id": 6, "division": "2"} - mockFranchise7_2024 = {"owner_name": "Owner 7", "name": "Team 7", "id": 7, "division": "2"} - mockFranchise8_2024 = {"owner_name": "Owner 8", "name": "Team 8", "id": 8, "division": "2"} + mockFranchise1_2022 = { + "owner_name": "Owner 1", + "name": "Team 1", + "id": 1, + "division": "1", + } + mockFranchise2_2022 = { + "owner_name": "Owner 2", + "name": "Team 2", + "id": 2, + "division": "1", + } + mockFranchise3_2022 = { + "owner_name": "Owner 3", + "name": "Team 3", + "id": 3, + "division": "1", + } + mockFranchise4_2022 = { + "owner_name": "Owner 4", + "name": "Team 4", + "id": 4, + "division": "1", + } + mockFranchise5_2022 = { + "owner_name": "Owner 5", + "name": "Team 5", + "id": 5, + "division": "2", + } + mockFranchise6_2022 = { + "owner_name": "Owner 6", + "name": "Team 6", + "id": 6, + "division": "2", + } + mockFranchise7_2022 = { + "owner_name": "Owner 7", + "name": "Team 7", + "id": 7, + "division": "2", + } + mockFranchise8_2022 = { + "owner_name": "Owner 8", + "name": "Team 8", + "id": 8, + "division": "2", + } + + mockFranchise1_2023 = { + "owner_name": "Owner 1", + "name": "Team 1", + "id": 1, + "division": "1", + } + mockFranchise2_2023 = { + "owner_name": "Owner 2", + "name": "Team 2", + "id": 2, + "division": "1", + } + mockFranchise3_2023 = { + "owner_name": "Owner 3", + "name": "Team 3", + "id": 3, + "division": "1", + } + mockFranchise4_2023 = { + "owner_name": "Owner 4", + "name": "Team 4", + "id": 4, + "division": "1", + } + mockFranchise5_2023 = { + "owner_name": "Owner 5", + "name": "Team 5", + "id": 5, + "division": "2", + } + mockFranchise6_2023 = { + "owner_name": "Owner 6", + "name": "Team 6", + "id": 6, + "division": "2", + } + mockFranchise7_2023 = { + "owner_name": "Owner 7", + "name": "Team 7", + "id": 7, + "division": "2", + } + mockFranchise8_2023 = { + "owner_name": "Owner 8", + "name": "Team 8", + "id": 8, + "division": "2", + } + + mockFranchise1_2024 = { + "owner_name": "Owner 1", + "name": "Team 1", + "id": 1, + "division": "1", + } + mockFranchise2_2024 = { + "owner_name": "Owner 2", + "name": "Team 2", + "id": 2, + "division": "1", + } + mockFranchise3_2024 = { + "owner_name": "Owner 3", + "name": "Team 3", + "id": 3, + "division": "1", + } + mockFranchise4_2024 = { + "owner_name": "Owner 4", + "name": "Team 4", + "id": 4, + "division": "1", + } + mockFranchise5_2024 = { + "owner_name": "Owner 5", + "name": "Team 5", + "id": 5, + "division": "2", + } + mockFranchise6_2024 = { + "owner_name": "Owner 6", + "name": "Team 6", + "id": 6, + "division": "2", + } + mockFranchise7_2024 = { + "owner_name": "Owner 7", + "name": "Team 7", + "id": 7, + "division": "2", + } + mockFranchise8_2024 = { + "owner_name": "Owner 8", + "name": "Team 8", + "id": 8, + "division": "2", + } mockLeague2022 = { "league": { @@ -81,7 +201,10 @@ def test_loadLeague_happyPath( ] }, "divisions": { - "division": [{"id": "1", "name": "d1_2022"}, {"id": "2", "name": "d2_2022"}] + "division": [ + {"id": "1", "name": "d1_2022"}, + {"id": "2", "name": "d2_2022"}, + ] }, } } @@ -104,7 +227,10 @@ def test_loadLeague_happyPath( ] }, "divisions": { - "division": [{"id": "1", "name": "d1_2023"}, {"id": "2", "name": "d2_2023"}] + "division": [ + {"id": "1", "name": "d1_2023"}, + {"id": "2", "name": "d2_2023"}, + ] }, } } @@ -127,7 +253,10 @@ def test_loadLeague_happyPath( ] }, "divisions": { - "division": [{"id": "1", "name": "d1_2024"}, {"id": "2", "name": "d2_2024"}] + "division": [ + {"id": "1", "name": "d1_2024"}, + {"id": "2", "name": "d2_2024"}, + ] }, } } @@ -141,40 +270,56 @@ def test_loadLeague_happyPath( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise1_2022, score=100, result="W" + mockFranchise=mockFranchise1_2022, + score=100, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2022, score=100, result="L" + mockFranchise=mockFranchise2_2022, + score=100, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise3_2022, score=100.1, result="W" + mockFranchise=mockFranchise3_2022, + score=100.1, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise4_2022, score=90.1, result="L" + mockFranchise=mockFranchise4_2022, + score=90.1, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise5_2022, score=101, result="W" + mockFranchise=mockFranchise5_2022, + score=101, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise6_2022, score=91, result="L" + mockFranchise=mockFranchise6_2022, + score=91, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise7_2022, score=102, result="W" + mockFranchise=mockFranchise7_2022, + score=102, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise8_2022, score=92, result="L" + mockFranchise=mockFranchise8_2022, + score=92, + result="L", ), ] }, @@ -186,10 +331,14 @@ def test_loadLeague_happyPath( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2022, score=103, result="W" + mockFranchise=mockFranchise2_2022, + score=103, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise3_2022, score=93, result="L" + mockFranchise=mockFranchise3_2022, + score=93, + result="L", ), ] } @@ -201,10 +350,14 @@ def test_loadLeague_happyPath( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise1_2022, score=104, result="W" + mockFranchise=mockFranchise1_2022, + score=104, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2022, score=94, result="L" + mockFranchise=mockFranchise2_2022, + score=94, + result="L", ), ] } @@ -223,40 +376,56 @@ def test_loadLeague_happyPath( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise1_2023, score=100, result="W" + mockFranchise=mockFranchise1_2023, + score=100, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2023, score=100, result="L" + mockFranchise=mockFranchise2_2023, + score=100, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise3_2023, score=100.1, result="W" + mockFranchise=mockFranchise3_2023, + score=100.1, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise4_2023, score=90.1, result="L" + mockFranchise=mockFranchise4_2023, + score=90.1, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise5_2023, score=101, result="W" + mockFranchise=mockFranchise5_2023, + score=101, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise6_2023, score=91, result="L" + mockFranchise=mockFranchise6_2023, + score=91, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise7_2023, score=102, result="W" + mockFranchise=mockFranchise7_2023, + score=102, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise8_2023, score=92, result="L" + mockFranchise=mockFranchise8_2023, + score=92, + result="L", ), ] }, @@ -268,20 +437,28 @@ def test_loadLeague_happyPath( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2023, score=103, result="W" + mockFranchise=mockFranchise2_2023, + score=103, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise3_2023, score=93, result="L" + mockFranchise=mockFranchise3_2023, + score=93, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise4_2023, score=103, result="W" + mockFranchise=mockFranchise4_2023, + score=103, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise5_2023, score=93, result="L" + mockFranchise=mockFranchise5_2023, + score=93, + result="L", ), ] }, @@ -293,10 +470,14 @@ def test_loadLeague_happyPath( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2023, score=104, result="W" + mockFranchise=mockFranchise2_2023, + score=104, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise3_2023, score=94, result="L" + mockFranchise=mockFranchise3_2023, + score=94, + result="L", ), ] } @@ -308,10 +489,14 @@ def test_loadLeague_happyPath( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise1_2023, score=104, result="W" + mockFranchise=mockFranchise1_2023, + score=104, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2023, score=94, result="L" + mockFranchise=mockFranchise2_2023, + score=94, + result="L", ), ] } @@ -330,40 +515,56 @@ def test_loadLeague_happyPath( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise1_2022, score=100, result="W" + mockFranchise=mockFranchise1_2022, + score=100, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2022, score=100, result="L" + mockFranchise=mockFranchise2_2022, + score=100, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise3_2022, score=100.1, result="W" + mockFranchise=mockFranchise3_2022, + score=100.1, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise4_2022, score=90.1, result="L" + mockFranchise=mockFranchise4_2022, + score=90.1, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise5_2022, score=101, result="W" + mockFranchise=mockFranchise5_2022, + score=101, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise6_2022, score=91, result="L" + mockFranchise=mockFranchise6_2022, + score=91, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise7_2022, score=102, result="W" + mockFranchise=mockFranchise7_2022, + score=102, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise8_2022, score=92, result="L" + mockFranchise=mockFranchise8_2022, + score=92, + result="L", ), ] }, @@ -375,10 +576,14 @@ def test_loadLeague_happyPath( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise1_2022, score=103, result="W" + mockFranchise=mockFranchise1_2022, + score=103, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2022, score=93, result="L" + mockFranchise=mockFranchise2_2022, + score=93, + result="L", ), ] } @@ -393,11 +598,17 @@ def test_loadLeague_happyPath( "playoffRound": [ { "week": 2, - "playoffGame": {"away": {"franchise_id": 2}, "home": {"franchise_id": 3}}, + "playoffGame": { + "away": {"franchise_id": 2}, + "home": {"franchise_id": 3}, + }, }, { "week": 3, - "playoffGame": {"away": {"franchise_id": 1}, "home": {"franchise_id": 2}}, + "playoffGame": { + "away": {"franchise_id": 1}, + "home": {"franchise_id": 2}, + }, }, ] } @@ -415,11 +626,17 @@ def test_loadLeague_happyPath( }, { "week": 3, - "playoffGame": {"away": {"franchise_id": 2}, "home": {"franchise_id": 4}}, + "playoffGame": { + "away": {"franchise_id": 2}, + "home": {"franchise_id": 4}, + }, }, { "week": 4, - "playoffGame": {"away": {"franchise_id": 1}, "home": {"franchise_id": 2}}, + "playoffGame": { + "away": {"franchise_id": 1}, + "home": {"franchise_id": 2}, + }, }, ] } @@ -429,13 +646,20 @@ def test_loadLeague_happyPath( "playoffBracket": { "playoffRound": { "week": 2, - "playoffGame": {"away": {"franchise_id": 1}, "home": {"franchise_id": 2}}, + "playoffGame": { + "away": {"franchise_id": 1}, + "home": {"franchise_id": 2}, + }, } } } mockGetLeague.side_effect = [mockLeague2022, mockLeague2023, mockLeague2024] - mockGetSchedule.side_effect = [mockSchedule2022, mockSchedule2023, mockSchedule2024] + mockGetSchedule.side_effect = [ + mockSchedule2022, + mockSchedule2023, + mockSchedule2024, + ] mockGetPlayoffBracket.side_effect = [ mockPlayoffSchedule_2022, mockPlayoffSchedule_2023, @@ -471,32 +695,80 @@ def test_loadLeague_happyPath( owner7 = Owner(name="Owner 7") owner8 = Owner(name="Owner 8") - team1_2022 = Team(ownerId=owner1.id, name="Team 1", divisionId=division1_2022.id) - team2_2022 = Team(ownerId=owner2.id, name="Team 2", divisionId=division1_2022.id) - team3_2022 = Team(ownerId=owner3.id, name="Team 3", divisionId=division1_2022.id) - team4_2022 = Team(ownerId=owner4.id, name="Team 4", divisionId=division1_2022.id) - team5_2022 = Team(ownerId=owner5.id, name="Team 5", divisionId=division2_2022.id) - team6_2022 = Team(ownerId=owner6.id, name="Team 6", divisionId=division2_2022.id) - team7_2022 = Team(ownerId=owner7.id, name="Team 7", divisionId=division2_2022.id) - team8_2022 = Team(ownerId=owner8.id, name="Team 8", divisionId=division2_2022.id) - - team1_2023 = Team(ownerId=owner1.id, name="Team 1", divisionId=division1_2023.id) - team2_2023 = Team(ownerId=owner2.id, name="Team 2", divisionId=division1_2023.id) - team3_2023 = Team(ownerId=owner3.id, name="Team 3", divisionId=division1_2023.id) - team4_2023 = Team(ownerId=owner4.id, name="Team 4", divisionId=division1_2023.id) - team5_2023 = Team(ownerId=owner5.id, name="Team 5", divisionId=division2_2023.id) - team6_2023 = Team(ownerId=owner6.id, name="Team 6", divisionId=division2_2023.id) - team7_2023 = Team(ownerId=owner7.id, name="Team 7", divisionId=division2_2023.id) - team8_2023 = Team(ownerId=owner8.id, name="Team 8", divisionId=division2_2023.id) - - team1_2024 = Team(ownerId=owner1.id, name="Team 1", divisionId=division1_2024.id) - team2_2024 = Team(ownerId=owner2.id, name="Team 2", divisionId=division1_2024.id) - team3_2024 = Team(ownerId=owner3.id, name="Team 3", divisionId=division1_2024.id) - team4_2024 = Team(ownerId=owner4.id, name="Team 4", divisionId=division1_2024.id) - team5_2024 = Team(ownerId=owner5.id, name="Team 5", divisionId=division2_2024.id) - team6_2024 = Team(ownerId=owner6.id, name="Team 6", divisionId=division2_2024.id) - team7_2024 = Team(ownerId=owner7.id, name="Team 7", divisionId=division2_2024.id) - team8_2024 = Team(ownerId=owner8.id, name="Team 8", divisionId=division2_2024.id) + team1_2022 = Team( + ownerId=owner1.id, name="Team 1", divisionId=division1_2022.id + ) + team2_2022 = Team( + ownerId=owner2.id, name="Team 2", divisionId=division1_2022.id + ) + team3_2022 = Team( + ownerId=owner3.id, name="Team 3", divisionId=division1_2022.id + ) + team4_2022 = Team( + ownerId=owner4.id, name="Team 4", divisionId=division1_2022.id + ) + team5_2022 = Team( + ownerId=owner5.id, name="Team 5", divisionId=division2_2022.id + ) + team6_2022 = Team( + ownerId=owner6.id, name="Team 6", divisionId=division2_2022.id + ) + team7_2022 = Team( + ownerId=owner7.id, name="Team 7", divisionId=division2_2022.id + ) + team8_2022 = Team( + ownerId=owner8.id, name="Team 8", divisionId=division2_2022.id + ) + + team1_2023 = Team( + ownerId=owner1.id, name="Team 1", divisionId=division1_2023.id + ) + team2_2023 = Team( + ownerId=owner2.id, name="Team 2", divisionId=division1_2023.id + ) + team3_2023 = Team( + ownerId=owner3.id, name="Team 3", divisionId=division1_2023.id + ) + team4_2023 = Team( + ownerId=owner4.id, name="Team 4", divisionId=division1_2023.id + ) + team5_2023 = Team( + ownerId=owner5.id, name="Team 5", divisionId=division2_2023.id + ) + team6_2023 = Team( + ownerId=owner6.id, name="Team 6", divisionId=division2_2023.id + ) + team7_2023 = Team( + ownerId=owner7.id, name="Team 7", divisionId=division2_2023.id + ) + team8_2023 = Team( + ownerId=owner8.id, name="Team 8", divisionId=division2_2023.id + ) + + team1_2024 = Team( + ownerId=owner1.id, name="Team 1", divisionId=division1_2024.id + ) + team2_2024 = Team( + ownerId=owner2.id, name="Team 2", divisionId=division1_2024.id + ) + team3_2024 = Team( + ownerId=owner3.id, name="Team 3", divisionId=division1_2024.id + ) + team4_2024 = Team( + ownerId=owner4.id, name="Team 4", divisionId=division1_2024.id + ) + team5_2024 = Team( + ownerId=owner5.id, name="Team 5", divisionId=division2_2024.id + ) + team6_2024 = Team( + ownerId=owner6.id, name="Team 6", divisionId=division2_2024.id + ) + team7_2024 = Team( + ownerId=owner7.id, name="Team 7", divisionId=division2_2024.id + ) + team8_2024 = Team( + ownerId=owner8.id, name="Team 8", divisionId=division2_2024.id + ) expectedLeague = League( name="Test League 2024", @@ -772,7 +1044,9 @@ def test_loadLeague_happyPath( ], ) - self.assertTrue(league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True)) + self.assertTrue( + league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True) + ) # check multiWeekMatchupIds for year in league.years: for week in year.weeks: @@ -793,32 +1067,152 @@ def test_loadLeague_happyPath_withOwnerNamesAndAliases( - having 1 playoff matchup in a playoff week (dict) - having multiple playoff matchups in a playoff week (list) """ - mockFranchise1_2022 = {"owner_name": "Owner 1", "name": "Team 1", "id": 1, "division": "1"} - mockFranchise2_2022 = {"owner_name": "Owner 2", "name": "Team 2", "id": 2, "division": "1"} - mockFranchise3_2022 = {"owner_name": "Owner 3", "name": "Team 3", "id": 3, "division": "1"} - mockFranchise4_2022 = {"owner_name": "Owner 4", "name": "Team 4", "id": 4, "division": "1"} - mockFranchise5_2022 = {"owner_name": "Owner 5", "name": "Team 5", "id": 5, "division": "2"} - mockFranchise6_2022 = {"owner_name": "Owner 6", "name": "Team 6", "id": 6, "division": "2"} - mockFranchise7_2022 = {"owner_name": "Owner 7", "name": "Team 7", "id": 7, "division": "2"} - mockFranchise8_2022 = {"owner_name": "Owner 8", "name": "Team 8", "id": 8, "division": "2"} - - mockFranchise1_2023 = {"owner_name": "Owner 1", "name": "Team 1", "id": 1, "division": "1"} - mockFranchise2_2023 = {"owner_name": "Owner 2", "name": "Team 2", "id": 2, "division": "1"} - mockFranchise3_2023 = {"owner_name": "Owner 3", "name": "Team 3", "id": 3, "division": "1"} - mockFranchise4_2023 = {"owner_name": "Owner 4", "name": "Team 4", "id": 4, "division": "1"} - mockFranchise5_2023 = {"owner_name": "Owner 5", "name": "Team 5", "id": 5, "division": "2"} - mockFranchise6_2023 = {"owner_name": "Owner 6", "name": "Team 6", "id": 6, "division": "2"} - mockFranchise7_2023 = {"owner_name": "Owner 7", "name": "Team 7", "id": 7, "division": "2"} - mockFranchise8_2023 = {"owner_name": "Owner 8", "name": "Team 8", "id": 8, "division": "2"} - - mockFranchise1_2024 = {"owner_name": "Owner 1", "name": "Team 1", "id": 1, "division": "1"} - mockFranchise2_2024 = {"owner_name": "Owner 2", "name": "Team 2", "id": 2, "division": "1"} - mockFranchise3_2024 = {"owner_name": "Owner 3", "name": "Team 3", "id": 3, "division": "1"} - mockFranchise4_2024 = {"owner_name": "Owner 4", "name": "Team 4", "id": 4, "division": "1"} - mockFranchise5_2024 = {"owner_name": "Owner 5", "name": "Team 5", "id": 5, "division": "2"} - mockFranchise6_2024 = {"owner_name": "Owner 6", "name": "Team 6", "id": 6, "division": "2"} - mockFranchise7_2024 = {"owner_name": "Owner 7", "name": "Team 7", "id": 7, "division": "2"} - mockFranchise8_2024 = {"owner_name": "Owner 8", "name": "Team 8", "id": 8, "division": "2"} + mockFranchise1_2022 = { + "owner_name": "Owner 1", + "name": "Team 1", + "id": 1, + "division": "1", + } + mockFranchise2_2022 = { + "owner_name": "Owner 2", + "name": "Team 2", + "id": 2, + "division": "1", + } + mockFranchise3_2022 = { + "owner_name": "Owner 3", + "name": "Team 3", + "id": 3, + "division": "1", + } + mockFranchise4_2022 = { + "owner_name": "Owner 4", + "name": "Team 4", + "id": 4, + "division": "1", + } + mockFranchise5_2022 = { + "owner_name": "Owner 5", + "name": "Team 5", + "id": 5, + "division": "2", + } + mockFranchise6_2022 = { + "owner_name": "Owner 6", + "name": "Team 6", + "id": 6, + "division": "2", + } + mockFranchise7_2022 = { + "owner_name": "Owner 7", + "name": "Team 7", + "id": 7, + "division": "2", + } + mockFranchise8_2022 = { + "owner_name": "Owner 8", + "name": "Team 8", + "id": 8, + "division": "2", + } + + mockFranchise1_2023 = { + "owner_name": "Owner 1", + "name": "Team 1", + "id": 1, + "division": "1", + } + mockFranchise2_2023 = { + "owner_name": "Owner 2", + "name": "Team 2", + "id": 2, + "division": "1", + } + mockFranchise3_2023 = { + "owner_name": "Owner 3", + "name": "Team 3", + "id": 3, + "division": "1", + } + mockFranchise4_2023 = { + "owner_name": "Owner 4", + "name": "Team 4", + "id": 4, + "division": "1", + } + mockFranchise5_2023 = { + "owner_name": "Owner 5", + "name": "Team 5", + "id": 5, + "division": "2", + } + mockFranchise6_2023 = { + "owner_name": "Owner 6", + "name": "Team 6", + "id": 6, + "division": "2", + } + mockFranchise7_2023 = { + "owner_name": "Owner 7", + "name": "Team 7", + "id": 7, + "division": "2", + } + mockFranchise8_2023 = { + "owner_name": "Owner 8", + "name": "Team 8", + "id": 8, + "division": "2", + } + + mockFranchise1_2024 = { + "owner_name": "Owner 1", + "name": "Team 1", + "id": 1, + "division": "1", + } + mockFranchise2_2024 = { + "owner_name": "Owner 2", + "name": "Team 2", + "id": 2, + "division": "1", + } + mockFranchise3_2024 = { + "owner_name": "Owner 3", + "name": "Team 3", + "id": 3, + "division": "1", + } + mockFranchise4_2024 = { + "owner_name": "Owner 4", + "name": "Team 4", + "id": 4, + "division": "1", + } + mockFranchise5_2024 = { + "owner_name": "Owner 5", + "name": "Team 5", + "id": 5, + "division": "2", + } + mockFranchise6_2024 = { + "owner_name": "Owner 6", + "name": "Team 6", + "id": 6, + "division": "2", + } + mockFranchise7_2024 = { + "owner_name": "Owner 7", + "name": "Team 7", + "id": 7, + "division": "2", + } + mockFranchise8_2024 = { + "owner_name": "Owner 8", + "name": "Team 8", + "id": 8, + "division": "2", + } mockLeague2022 = { "league": { @@ -838,7 +1232,10 @@ def test_loadLeague_happyPath_withOwnerNamesAndAliases( ] }, "divisions": { - "division": [{"id": "1", "name": "d1_2022"}, {"id": "2", "name": "d2_2022"}] + "division": [ + {"id": "1", "name": "d1_2022"}, + {"id": "2", "name": "d2_2022"}, + ] }, } } @@ -861,7 +1258,10 @@ def test_loadLeague_happyPath_withOwnerNamesAndAliases( ] }, "divisions": { - "division": [{"id": "1", "name": "d1_2023"}, {"id": "2", "name": "d2_2023"}] + "division": [ + {"id": "1", "name": "d1_2023"}, + {"id": "2", "name": "d2_2023"}, + ] }, } } @@ -884,7 +1284,10 @@ def test_loadLeague_happyPath_withOwnerNamesAndAliases( ] }, "divisions": { - "division": [{"id": "1", "name": "d1_2024"}, {"id": "2", "name": "d2_2024"}] + "division": [ + {"id": "1", "name": "d1_2024"}, + {"id": "2", "name": "d2_2024"}, + ] }, } } @@ -898,40 +1301,56 @@ def test_loadLeague_happyPath_withOwnerNamesAndAliases( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise1_2022, score=100, result="W" + mockFranchise=mockFranchise1_2022, + score=100, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2022, score=100, result="L" + mockFranchise=mockFranchise2_2022, + score=100, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise3_2022, score=100.1, result="W" + mockFranchise=mockFranchise3_2022, + score=100.1, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise4_2022, score=90.1, result="L" + mockFranchise=mockFranchise4_2022, + score=90.1, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise5_2022, score=101, result="W" + mockFranchise=mockFranchise5_2022, + score=101, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise6_2022, score=91, result="L" + mockFranchise=mockFranchise6_2022, + score=91, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise7_2022, score=102, result="W" + mockFranchise=mockFranchise7_2022, + score=102, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise8_2022, score=92, result="L" + mockFranchise=mockFranchise8_2022, + score=92, + result="L", ), ] }, @@ -943,10 +1362,14 @@ def test_loadLeague_happyPath_withOwnerNamesAndAliases( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2022, score=103, result="W" + mockFranchise=mockFranchise2_2022, + score=103, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise3_2022, score=93, result="L" + mockFranchise=mockFranchise3_2022, + score=93, + result="L", ), ] } @@ -958,10 +1381,14 @@ def test_loadLeague_happyPath_withOwnerNamesAndAliases( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise1_2022, score=104, result="W" + mockFranchise=mockFranchise1_2022, + score=104, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2022, score=94, result="L" + mockFranchise=mockFranchise2_2022, + score=94, + result="L", ), ] } @@ -980,40 +1407,56 @@ def test_loadLeague_happyPath_withOwnerNamesAndAliases( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise1_2023, score=100, result="W" + mockFranchise=mockFranchise1_2023, + score=100, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2023, score=100, result="L" + mockFranchise=mockFranchise2_2023, + score=100, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise3_2023, score=100.1, result="W" + mockFranchise=mockFranchise3_2023, + score=100.1, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise4_2023, score=90.1, result="L" + mockFranchise=mockFranchise4_2023, + score=90.1, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise5_2023, score=101, result="W" + mockFranchise=mockFranchise5_2023, + score=101, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise6_2023, score=91, result="L" + mockFranchise=mockFranchise6_2023, + score=91, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise7_2023, score=102, result="W" + mockFranchise=mockFranchise7_2023, + score=102, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise8_2023, score=92, result="L" + mockFranchise=mockFranchise8_2023, + score=92, + result="L", ), ] }, @@ -1025,20 +1468,28 @@ def test_loadLeague_happyPath_withOwnerNamesAndAliases( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2023, score=103, result="W" + mockFranchise=mockFranchise2_2023, + score=103, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise3_2023, score=93, result="L" + mockFranchise=mockFranchise3_2023, + score=93, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise4_2023, score=103, result="W" + mockFranchise=mockFranchise4_2023, + score=103, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise5_2023, score=93, result="L" + mockFranchise=mockFranchise5_2023, + score=93, + result="L", ), ] }, @@ -1050,10 +1501,14 @@ def test_loadLeague_happyPath_withOwnerNamesAndAliases( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2023, score=104, result="W" + mockFranchise=mockFranchise2_2023, + score=104, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise3_2023, score=94, result="L" + mockFranchise=mockFranchise3_2023, + score=94, + result="L", ), ] } @@ -1065,10 +1520,14 @@ def test_loadLeague_happyPath_withOwnerNamesAndAliases( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise1_2023, score=104, result="W" + mockFranchise=mockFranchise1_2023, + score=104, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2023, score=94, result="L" + mockFranchise=mockFranchise2_2023, + score=94, + result="L", ), ] } @@ -1087,40 +1546,56 @@ def test_loadLeague_happyPath_withOwnerNamesAndAliases( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise1_2022, score=100, result="W" + mockFranchise=mockFranchise1_2022, + score=100, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2022, score=100, result="L" + mockFranchise=mockFranchise2_2022, + score=100, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise3_2022, score=100.1, result="W" + mockFranchise=mockFranchise3_2022, + score=100.1, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise4_2022, score=90.1, result="L" + mockFranchise=mockFranchise4_2022, + score=90.1, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise5_2022, score=101, result="W" + mockFranchise=mockFranchise5_2022, + score=101, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise6_2022, score=91, result="L" + mockFranchise=mockFranchise6_2022, + score=91, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise7_2022, score=102, result="W" + mockFranchise=mockFranchise7_2022, + score=102, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise8_2022, score=92, result="L" + mockFranchise=mockFranchise8_2022, + score=92, + result="L", ), ] }, @@ -1132,10 +1607,14 @@ def test_loadLeague_happyPath_withOwnerNamesAndAliases( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise1_2022, score=103, result="W" + mockFranchise=mockFranchise1_2022, + score=103, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2022, score=93, result="L" + mockFranchise=mockFranchise2_2022, + score=93, + result="L", ), ] } @@ -1150,11 +1629,17 @@ def test_loadLeague_happyPath_withOwnerNamesAndAliases( "playoffRound": [ { "week": 2, - "playoffGame": {"away": {"franchise_id": 2}, "home": {"franchise_id": 3}}, + "playoffGame": { + "away": {"franchise_id": 2}, + "home": {"franchise_id": 3}, + }, }, { "week": 3, - "playoffGame": {"away": {"franchise_id": 1}, "home": {"franchise_id": 2}}, + "playoffGame": { + "away": {"franchise_id": 1}, + "home": {"franchise_id": 2}, + }, }, ] } @@ -1172,11 +1657,17 @@ def test_loadLeague_happyPath_withOwnerNamesAndAliases( }, { "week": 3, - "playoffGame": {"away": {"franchise_id": 2}, "home": {"franchise_id": 4}}, + "playoffGame": { + "away": {"franchise_id": 2}, + "home": {"franchise_id": 4}, + }, }, { "week": 4, - "playoffGame": {"away": {"franchise_id": 1}, "home": {"franchise_id": 2}}, + "playoffGame": { + "away": {"franchise_id": 1}, + "home": {"franchise_id": 2}, + }, }, ] } @@ -1186,13 +1677,20 @@ def test_loadLeague_happyPath_withOwnerNamesAndAliases( "playoffBracket": { "playoffRound": { "week": 2, - "playoffGame": {"away": {"franchise_id": 1}, "home": {"franchise_id": 2}}, + "playoffGame": { + "away": {"franchise_id": 1}, + "home": {"franchise_id": 2}, + }, } } } mockGetLeague.side_effect = [mockLeague2022, mockLeague2023, mockLeague2024] - mockGetSchedule.side_effect = [mockSchedule2022, mockSchedule2023, mockSchedule2024] + mockGetSchedule.side_effect = [ + mockSchedule2022, + mockSchedule2023, + mockSchedule2024, + ] mockGetPlayoffBracket.side_effect = [ mockPlayoffSchedule_2022, mockPlayoffSchedule_2023, @@ -1238,32 +1736,80 @@ def test_loadLeague_happyPath_withOwnerNamesAndAliases( owner7 = Owner(name="o7") owner8 = Owner(name="o8") - team1_2022 = Team(ownerId=owner1.id, name="Team 1", divisionId=division1_2022.id) - team2_2022 = Team(ownerId=owner2.id, name="Team 2", divisionId=division1_2022.id) - team3_2022 = Team(ownerId=owner3.id, name="Team 3", divisionId=division1_2022.id) - team4_2022 = Team(ownerId=owner4.id, name="Team 4", divisionId=division1_2022.id) - team5_2022 = Team(ownerId=owner5.id, name="Team 5", divisionId=division2_2022.id) - team6_2022 = Team(ownerId=owner6.id, name="Team 6", divisionId=division2_2022.id) - team7_2022 = Team(ownerId=owner7.id, name="Team 7", divisionId=division2_2022.id) - team8_2022 = Team(ownerId=owner8.id, name="Team 8", divisionId=division2_2022.id) - - team1_2023 = Team(ownerId=owner1.id, name="Team 1", divisionId=division1_2023.id) - team2_2023 = Team(ownerId=owner2.id, name="Team 2", divisionId=division1_2023.id) - team3_2023 = Team(ownerId=owner3.id, name="Team 3", divisionId=division1_2023.id) - team4_2023 = Team(ownerId=owner4.id, name="Team 4", divisionId=division1_2023.id) - team5_2023 = Team(ownerId=owner5.id, name="Team 5", divisionId=division2_2023.id) - team6_2023 = Team(ownerId=owner6.id, name="Team 6", divisionId=division2_2023.id) - team7_2023 = Team(ownerId=owner7.id, name="Team 7", divisionId=division2_2023.id) - team8_2023 = Team(ownerId=owner8.id, name="Team 8", divisionId=division2_2023.id) - - team1_2024 = Team(ownerId=owner1.id, name="Team 1", divisionId=division1_2024.id) - team2_2024 = Team(ownerId=owner2.id, name="Team 2", divisionId=division1_2024.id) - team3_2024 = Team(ownerId=owner3.id, name="Team 3", divisionId=division1_2024.id) - team4_2024 = Team(ownerId=owner4.id, name="Team 4", divisionId=division1_2024.id) - team5_2024 = Team(ownerId=owner5.id, name="Team 5", divisionId=division2_2024.id) - team6_2024 = Team(ownerId=owner6.id, name="Team 6", divisionId=division2_2024.id) - team7_2024 = Team(ownerId=owner7.id, name="Team 7", divisionId=division2_2024.id) - team8_2024 = Team(ownerId=owner8.id, name="Team 8", divisionId=division2_2024.id) + team1_2022 = Team( + ownerId=owner1.id, name="Team 1", divisionId=division1_2022.id + ) + team2_2022 = Team( + ownerId=owner2.id, name="Team 2", divisionId=division1_2022.id + ) + team3_2022 = Team( + ownerId=owner3.id, name="Team 3", divisionId=division1_2022.id + ) + team4_2022 = Team( + ownerId=owner4.id, name="Team 4", divisionId=division1_2022.id + ) + team5_2022 = Team( + ownerId=owner5.id, name="Team 5", divisionId=division2_2022.id + ) + team6_2022 = Team( + ownerId=owner6.id, name="Team 6", divisionId=division2_2022.id + ) + team7_2022 = Team( + ownerId=owner7.id, name="Team 7", divisionId=division2_2022.id + ) + team8_2022 = Team( + ownerId=owner8.id, name="Team 8", divisionId=division2_2022.id + ) + + team1_2023 = Team( + ownerId=owner1.id, name="Team 1", divisionId=division1_2023.id + ) + team2_2023 = Team( + ownerId=owner2.id, name="Team 2", divisionId=division1_2023.id + ) + team3_2023 = Team( + ownerId=owner3.id, name="Team 3", divisionId=division1_2023.id + ) + team4_2023 = Team( + ownerId=owner4.id, name="Team 4", divisionId=division1_2023.id + ) + team5_2023 = Team( + ownerId=owner5.id, name="Team 5", divisionId=division2_2023.id + ) + team6_2023 = Team( + ownerId=owner6.id, name="Team 6", divisionId=division2_2023.id + ) + team7_2023 = Team( + ownerId=owner7.id, name="Team 7", divisionId=division2_2023.id + ) + team8_2023 = Team( + ownerId=owner8.id, name="Team 8", divisionId=division2_2023.id + ) + + team1_2024 = Team( + ownerId=owner1.id, name="Team 1", divisionId=division1_2024.id + ) + team2_2024 = Team( + ownerId=owner2.id, name="Team 2", divisionId=division1_2024.id + ) + team3_2024 = Team( + ownerId=owner3.id, name="Team 3", divisionId=division1_2024.id + ) + team4_2024 = Team( + ownerId=owner4.id, name="Team 4", divisionId=division1_2024.id + ) + team5_2024 = Team( + ownerId=owner5.id, name="Team 5", divisionId=division2_2024.id + ) + team6_2024 = Team( + ownerId=owner6.id, name="Team 6", divisionId=division2_2024.id + ) + team7_2024 = Team( + ownerId=owner7.id, name="Team 7", divisionId=division2_2024.id + ) + team8_2024 = Team( + ownerId=owner8.id, name="Team 8", divisionId=division2_2024.id + ) expectedLeague = League( name="Test League 2024", @@ -1539,7 +2085,9 @@ def test_loadLeague_happyPath_withOwnerNamesAndAliases( ], ) - self.assertTrue(league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True)) + self.assertTrue( + league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True) + ) # check multiWeekMatchupIds for year in league.years: for week in year.weeks: @@ -1553,32 +2101,152 @@ def test_loadLeague_happyPath_withOwnerNamesAndAliases( def test_loadLeague_withLeagueName( self, mockGetPlayoffBracket, mockGetSchedule, mockGetLeague, mockAddConfig ): - mockFranchise1_2022 = {"owner_name": "Owner 1", "name": "Team 1", "id": 1, "division": "1"} - mockFranchise2_2022 = {"owner_name": "Owner 2", "name": "Team 2", "id": 2, "division": "1"} - mockFranchise3_2022 = {"owner_name": "Owner 3", "name": "Team 3", "id": 3, "division": "1"} - mockFranchise4_2022 = {"owner_name": "Owner 4", "name": "Team 4", "id": 4, "division": "1"} - mockFranchise5_2022 = {"owner_name": "Owner 5", "name": "Team 5", "id": 5, "division": "2"} - mockFranchise6_2022 = {"owner_name": "Owner 6", "name": "Team 6", "id": 6, "division": "2"} - mockFranchise7_2022 = {"owner_name": "Owner 7", "name": "Team 7", "id": 7, "division": "2"} - mockFranchise8_2022 = {"owner_name": "Owner 8", "name": "Team 8", "id": 8, "division": "2"} - - mockFranchise1_2023 = {"owner_name": "Owner 1", "name": "Team 1", "id": 1, "division": "1"} - mockFranchise2_2023 = {"owner_name": "Owner 2", "name": "Team 2", "id": 2, "division": "1"} - mockFranchise3_2023 = {"owner_name": "Owner 3", "name": "Team 3", "id": 3, "division": "1"} - mockFranchise4_2023 = {"owner_name": "Owner 4", "name": "Team 4", "id": 4, "division": "1"} - mockFranchise5_2023 = {"owner_name": "Owner 5", "name": "Team 5", "id": 5, "division": "2"} - mockFranchise6_2023 = {"owner_name": "Owner 6", "name": "Team 6", "id": 6, "division": "2"} - mockFranchise7_2023 = {"owner_name": "Owner 7", "name": "Team 7", "id": 7, "division": "2"} - mockFranchise8_2023 = {"owner_name": "Owner 8", "name": "Team 8", "id": 8, "division": "2"} - - mockFranchise1_2024 = {"owner_name": "Owner 1", "name": "Team 1", "id": 1, "division": "1"} - mockFranchise2_2024 = {"owner_name": "Owner 2", "name": "Team 2", "id": 2, "division": "1"} - mockFranchise3_2024 = {"owner_name": "Owner 3", "name": "Team 3", "id": 3, "division": "1"} - mockFranchise4_2024 = {"owner_name": "Owner 4", "name": "Team 4", "id": 4, "division": "1"} - mockFranchise5_2024 = {"owner_name": "Owner 5", "name": "Team 5", "id": 5, "division": "2"} - mockFranchise6_2024 = {"owner_name": "Owner 6", "name": "Team 6", "id": 6, "division": "2"} - mockFranchise7_2024 = {"owner_name": "Owner 7", "name": "Team 7", "id": 7, "division": "2"} - mockFranchise8_2024 = {"owner_name": "Owner 8", "name": "Team 8", "id": 8, "division": "2"} + mockFranchise1_2022 = { + "owner_name": "Owner 1", + "name": "Team 1", + "id": 1, + "division": "1", + } + mockFranchise2_2022 = { + "owner_name": "Owner 2", + "name": "Team 2", + "id": 2, + "division": "1", + } + mockFranchise3_2022 = { + "owner_name": "Owner 3", + "name": "Team 3", + "id": 3, + "division": "1", + } + mockFranchise4_2022 = { + "owner_name": "Owner 4", + "name": "Team 4", + "id": 4, + "division": "1", + } + mockFranchise5_2022 = { + "owner_name": "Owner 5", + "name": "Team 5", + "id": 5, + "division": "2", + } + mockFranchise6_2022 = { + "owner_name": "Owner 6", + "name": "Team 6", + "id": 6, + "division": "2", + } + mockFranchise7_2022 = { + "owner_name": "Owner 7", + "name": "Team 7", + "id": 7, + "division": "2", + } + mockFranchise8_2022 = { + "owner_name": "Owner 8", + "name": "Team 8", + "id": 8, + "division": "2", + } + + mockFranchise1_2023 = { + "owner_name": "Owner 1", + "name": "Team 1", + "id": 1, + "division": "1", + } + mockFranchise2_2023 = { + "owner_name": "Owner 2", + "name": "Team 2", + "id": 2, + "division": "1", + } + mockFranchise3_2023 = { + "owner_name": "Owner 3", + "name": "Team 3", + "id": 3, + "division": "1", + } + mockFranchise4_2023 = { + "owner_name": "Owner 4", + "name": "Team 4", + "id": 4, + "division": "1", + } + mockFranchise5_2023 = { + "owner_name": "Owner 5", + "name": "Team 5", + "id": 5, + "division": "2", + } + mockFranchise6_2023 = { + "owner_name": "Owner 6", + "name": "Team 6", + "id": 6, + "division": "2", + } + mockFranchise7_2023 = { + "owner_name": "Owner 7", + "name": "Team 7", + "id": 7, + "division": "2", + } + mockFranchise8_2023 = { + "owner_name": "Owner 8", + "name": "Team 8", + "id": 8, + "division": "2", + } + + mockFranchise1_2024 = { + "owner_name": "Owner 1", + "name": "Team 1", + "id": 1, + "division": "1", + } + mockFranchise2_2024 = { + "owner_name": "Owner 2", + "name": "Team 2", + "id": 2, + "division": "1", + } + mockFranchise3_2024 = { + "owner_name": "Owner 3", + "name": "Team 3", + "id": 3, + "division": "1", + } + mockFranchise4_2024 = { + "owner_name": "Owner 4", + "name": "Team 4", + "id": 4, + "division": "1", + } + mockFranchise5_2024 = { + "owner_name": "Owner 5", + "name": "Team 5", + "id": 5, + "division": "2", + } + mockFranchise6_2024 = { + "owner_name": "Owner 6", + "name": "Team 6", + "id": 6, + "division": "2", + } + mockFranchise7_2024 = { + "owner_name": "Owner 7", + "name": "Team 7", + "id": 7, + "division": "2", + } + mockFranchise8_2024 = { + "owner_name": "Owner 8", + "name": "Team 8", + "id": 8, + "division": "2", + } mockLeague2022 = { "league": { @@ -1598,7 +2266,10 @@ def test_loadLeague_withLeagueName( ] }, "divisions": { - "division": [{"id": "1", "name": "d1_2022"}, {"id": "2", "name": "d2_2022"}] + "division": [ + {"id": "1", "name": "d1_2022"}, + {"id": "2", "name": "d2_2022"}, + ] }, } } @@ -1621,7 +2292,10 @@ def test_loadLeague_withLeagueName( ] }, "divisions": { - "division": [{"id": "1", "name": "d1_2023"}, {"id": "2", "name": "d2_2023"}] + "division": [ + {"id": "1", "name": "d1_2023"}, + {"id": "2", "name": "d2_2023"}, + ] }, } } @@ -1644,7 +2318,10 @@ def test_loadLeague_withLeagueName( ] }, "divisions": { - "division": [{"id": "1", "name": "d1_2024"}, {"id": "2", "name": "d2_2024"}] + "division": [ + {"id": "1", "name": "d1_2024"}, + {"id": "2", "name": "d2_2024"}, + ] }, } } @@ -1658,40 +2335,56 @@ def test_loadLeague_withLeagueName( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise1_2022, score=100, result="W" + mockFranchise=mockFranchise1_2022, + score=100, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2022, score=100, result="L" + mockFranchise=mockFranchise2_2022, + score=100, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise3_2022, score=100.1, result="W" + mockFranchise=mockFranchise3_2022, + score=100.1, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise4_2022, score=90.1, result="L" + mockFranchise=mockFranchise4_2022, + score=90.1, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise5_2022, score=101, result="W" + mockFranchise=mockFranchise5_2022, + score=101, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise6_2022, score=91, result="L" + mockFranchise=mockFranchise6_2022, + score=91, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise7_2022, score=102, result="W" + mockFranchise=mockFranchise7_2022, + score=102, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise8_2022, score=92, result="L" + mockFranchise=mockFranchise8_2022, + score=92, + result="L", ), ] }, @@ -1703,10 +2396,14 @@ def test_loadLeague_withLeagueName( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2022, score=103, result="W" + mockFranchise=mockFranchise2_2022, + score=103, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise3_2022, score=93, result="L" + mockFranchise=mockFranchise3_2022, + score=93, + result="L", ), ] } @@ -1718,10 +2415,14 @@ def test_loadLeague_withLeagueName( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise1_2022, score=104, result="W" + mockFranchise=mockFranchise1_2022, + score=104, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2022, score=94, result="L" + mockFranchise=mockFranchise2_2022, + score=94, + result="L", ), ] } @@ -1740,40 +2441,56 @@ def test_loadLeague_withLeagueName( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise1_2023, score=100, result="W" + mockFranchise=mockFranchise1_2023, + score=100, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2023, score=100, result="L" + mockFranchise=mockFranchise2_2023, + score=100, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise3_2023, score=100.1, result="W" + mockFranchise=mockFranchise3_2023, + score=100.1, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise4_2023, score=90.1, result="L" + mockFranchise=mockFranchise4_2023, + score=90.1, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise5_2023, score=101, result="W" + mockFranchise=mockFranchise5_2023, + score=101, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise6_2023, score=91, result="L" + mockFranchise=mockFranchise6_2023, + score=91, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise7_2023, score=102, result="W" + mockFranchise=mockFranchise7_2023, + score=102, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise8_2023, score=92, result="L" + mockFranchise=mockFranchise8_2023, + score=92, + result="L", ), ] }, @@ -1785,20 +2502,28 @@ def test_loadLeague_withLeagueName( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2023, score=103, result="W" + mockFranchise=mockFranchise2_2023, + score=103, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise3_2023, score=93, result="L" + mockFranchise=mockFranchise3_2023, + score=93, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise4_2023, score=103, result="W" + mockFranchise=mockFranchise4_2023, + score=103, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise5_2023, score=93, result="L" + mockFranchise=mockFranchise5_2023, + score=93, + result="L", ), ] }, @@ -1810,10 +2535,14 @@ def test_loadLeague_withLeagueName( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2023, score=104, result="W" + mockFranchise=mockFranchise2_2023, + score=104, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise3_2023, score=94, result="L" + mockFranchise=mockFranchise3_2023, + score=94, + result="L", ), ] } @@ -1825,10 +2554,14 @@ def test_loadLeague_withLeagueName( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise1_2023, score=104, result="W" + mockFranchise=mockFranchise1_2023, + score=104, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2023, score=94, result="L" + mockFranchise=mockFranchise2_2023, + score=94, + result="L", ), ] } @@ -1847,40 +2580,56 @@ def test_loadLeague_withLeagueName( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise1_2022, score=100, result="W" + mockFranchise=mockFranchise1_2022, + score=100, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2022, score=100, result="L" + mockFranchise=mockFranchise2_2022, + score=100, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise3_2022, score=100.1, result="W" + mockFranchise=mockFranchise3_2022, + score=100.1, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise4_2022, score=90.1, result="L" + mockFranchise=mockFranchise4_2022, + score=90.1, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise5_2022, score=101, result="W" + mockFranchise=mockFranchise5_2022, + score=101, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise6_2022, score=91, result="L" + mockFranchise=mockFranchise6_2022, + score=91, + result="L", ), ] }, { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise7_2022, score=102, result="W" + mockFranchise=mockFranchise7_2022, + score=102, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise8_2022, score=92, result="L" + mockFranchise=mockFranchise8_2022, + score=92, + result="L", ), ] }, @@ -1892,10 +2641,14 @@ def test_loadLeague_withLeagueName( { "franchise": [ self.__addScoreToMockFranchise( - mockFranchise=mockFranchise1_2022, score=103, result="W" + mockFranchise=mockFranchise1_2022, + score=103, + result="W", ), self.__addScoreToMockFranchise( - mockFranchise=mockFranchise2_2022, score=93, result="L" + mockFranchise=mockFranchise2_2022, + score=93, + result="L", ), ] } @@ -1910,11 +2663,17 @@ def test_loadLeague_withLeagueName( "playoffRound": [ { "week": 2, - "playoffGame": {"away": {"franchise_id": 2}, "home": {"franchise_id": 3}}, + "playoffGame": { + "away": {"franchise_id": 2}, + "home": {"franchise_id": 3}, + }, }, { "week": 3, - "playoffGame": {"away": {"franchise_id": 1}, "home": {"franchise_id": 2}}, + "playoffGame": { + "away": {"franchise_id": 1}, + "home": {"franchise_id": 2}, + }, }, ] } @@ -1932,11 +2691,17 @@ def test_loadLeague_withLeagueName( }, { "week": 3, - "playoffGame": {"away": {"franchise_id": 2}, "home": {"franchise_id": 4}}, + "playoffGame": { + "away": {"franchise_id": 2}, + "home": {"franchise_id": 4}, + }, }, { "week": 4, - "playoffGame": {"away": {"franchise_id": 1}, "home": {"franchise_id": 2}}, + "playoffGame": { + "away": {"franchise_id": 1}, + "home": {"franchise_id": 2}, + }, }, ] } @@ -1946,13 +2711,20 @@ def test_loadLeague_withLeagueName( "playoffBracket": { "playoffRound": { "week": 2, - "playoffGame": {"away": {"franchise_id": 1}, "home": {"franchise_id": 2}}, + "playoffGame": { + "away": {"franchise_id": 1}, + "home": {"franchise_id": 2}, + }, } } } mockGetLeague.side_effect = [mockLeague2022, mockLeague2023, mockLeague2024] - mockGetSchedule.side_effect = [mockSchedule2022, mockSchedule2023, mockSchedule2024] + mockGetSchedule.side_effect = [ + mockSchedule2022, + mockSchedule2023, + mockSchedule2024, + ] mockGetPlayoffBracket.side_effect = [ mockPlayoffSchedule_2022, mockPlayoffSchedule_2023, diff --git a/test/test_league_loader/test_SleeperLeagueLoader.py b/test/test_league_loader/test_SleeperLeagueLoader.py index bab5b7ef..85a67e25 100644 --- a/test/test_league_loader/test_SleeperLeagueLoader.py +++ b/test/test_league_loader/test_SleeperLeagueLoader.py @@ -101,7 +101,9 @@ def __generateMockSleeperMatchup( starters_points=None, ) - def __generateMockSleeperSportState(self, *, season: str, leg: int) -> SleeperSportState: + def __generateMockSleeperSportState( + self, *, season: str, leg: int + ) -> SleeperSportState: return SleeperSportState( display_week=None, league_create_season=None, @@ -282,76 +284,160 @@ def test_load_league_happyPath( # create mock SleeperMatchup objects # matchup id will be YYYY (year) WW (week number) MM (matchup number) mockSleeperMatchups2022_1 = [ - self.__generateMockSleeperMatchup(matchupId=20220101, rosterId=202201, points=100), - self.__generateMockSleeperMatchup(matchupId=20220101, rosterId=202202, points=100), - self.__generateMockSleeperMatchup(matchupId=20220102, rosterId=202203, points=90.5), - self.__generateMockSleeperMatchup(matchupId=20220102, rosterId=202204, points=70.5), - self.__generateMockSleeperMatchup(matchupId=20220103, rosterId=202205, points=110), - self.__generateMockSleeperMatchup(matchupId=20220103, rosterId=202206, points=60), - self.__generateMockSleeperMatchup(matchupId=20220104, rosterId=202207, points=120), - self.__generateMockSleeperMatchup(matchupId=20220104, rosterId=202208, points=50), + self.__generateMockSleeperMatchup( + matchupId=20220101, rosterId=202201, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220101, rosterId=202202, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220102, rosterId=202203, points=90.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20220102, rosterId=202204, points=70.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20220103, rosterId=202205, points=110 + ), + self.__generateMockSleeperMatchup( + matchupId=20220103, rosterId=202206, points=60 + ), + self.__generateMockSleeperMatchup( + matchupId=20220104, rosterId=202207, points=120 + ), + self.__generateMockSleeperMatchup( + matchupId=20220104, rosterId=202208, points=50 + ), ] mockSleeperMatchups2022_2 = [ - self.__generateMockSleeperMatchup(matchupId=20220201, rosterId=202201, points=100), - self.__generateMockSleeperMatchup(matchupId=20220201, rosterId=202202, points=100), - self.__generateMockSleeperMatchup(matchupId=20220202, rosterId=202203, points=90.5), - self.__generateMockSleeperMatchup(matchupId=20220202, rosterId=202204, points=70.5), - self.__generateMockSleeperMatchup(matchupId=20220203, rosterId=202205, points=110), - self.__generateMockSleeperMatchup(matchupId=20220203, rosterId=202206, points=60), - self.__generateMockSleeperMatchup(matchupId=20220204, rosterId=202207, points=120), - self.__generateMockSleeperMatchup(matchupId=20220204, rosterId=202208, points=50), + self.__generateMockSleeperMatchup( + matchupId=20220201, rosterId=202201, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220201, rosterId=202202, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220202, rosterId=202203, points=90.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20220202, rosterId=202204, points=70.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20220203, rosterId=202205, points=110 + ), + self.__generateMockSleeperMatchup( + matchupId=20220203, rosterId=202206, points=60 + ), + self.__generateMockSleeperMatchup( + matchupId=20220204, rosterId=202207, points=120 + ), + self.__generateMockSleeperMatchup( + matchupId=20220204, rosterId=202208, points=50 + ), ] # playoffs mockSleeperMatchups2022_3 = [ - self.__generateMockSleeperMatchup(matchupId=20220301, rosterId=202202, points=100), - self.__generateMockSleeperMatchup(matchupId=20220301, rosterId=202203, points=90.5), + self.__generateMockSleeperMatchup( + matchupId=20220301, rosterId=202202, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220301, rosterId=202203, points=90.5 + ), ] # championship mockSleeperMatchups2022_4 = [ - self.__generateMockSleeperMatchup(matchupId=20220401, rosterId=202201, points=100), - self.__generateMockSleeperMatchup(matchupId=20220401, rosterId=202202, points=99), + self.__generateMockSleeperMatchup( + matchupId=20220401, rosterId=202201, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220401, rosterId=202202, points=99 + ), ] mockSleeperMatchups2023_1 = [ - self.__generateMockSleeperMatchup(matchupId=20230101, rosterId=202301, points=100), - self.__generateMockSleeperMatchup(matchupId=20230101, rosterId=202302, points=100), - self.__generateMockSleeperMatchup(matchupId=20230102, rosterId=202303, points=90.5), - self.__generateMockSleeperMatchup(matchupId=20230102, rosterId=202304, points=70.5), - self.__generateMockSleeperMatchup(matchupId=20230103, rosterId=202305, points=110), - self.__generateMockSleeperMatchup(matchupId=20230103, rosterId=202306, points=60), - self.__generateMockSleeperMatchup(matchupId=20230104, rosterId=202307, points=120), - self.__generateMockSleeperMatchup(matchupId=20230104, rosterId=202308, points=50), + self.__generateMockSleeperMatchup( + matchupId=20230101, rosterId=202301, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20230101, rosterId=202302, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20230102, rosterId=202303, points=90.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20230102, rosterId=202304, points=70.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20230103, rosterId=202305, points=110 + ), + self.__generateMockSleeperMatchup( + matchupId=20230103, rosterId=202306, points=60 + ), + self.__generateMockSleeperMatchup( + matchupId=20230104, rosterId=202307, points=120 + ), + self.__generateMockSleeperMatchup( + matchupId=20230104, rosterId=202308, points=50 + ), ] mockSleeperMatchups2023_2 = [ - self.__generateMockSleeperMatchup(matchupId=20230201, rosterId=202301, points=100), - self.__generateMockSleeperMatchup(matchupId=20230201, rosterId=202302, points=100), - self.__generateMockSleeperMatchup(matchupId=20230202, rosterId=202303, points=90.5), - self.__generateMockSleeperMatchup(matchupId=20230202, rosterId=202304, points=70.5), - self.__generateMockSleeperMatchup(matchupId=20230203, rosterId=202305, points=110), - self.__generateMockSleeperMatchup(matchupId=20230203, rosterId=202306, points=60), - self.__generateMockSleeperMatchup(matchupId=20230204, rosterId=202307, points=120), - self.__generateMockSleeperMatchup(matchupId=20230204, rosterId=202308, points=50), + self.__generateMockSleeperMatchup( + matchupId=20230201, rosterId=202301, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20230201, rosterId=202302, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20230202, rosterId=202303, points=90.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20230202, rosterId=202304, points=70.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20230203, rosterId=202305, points=110 + ), + self.__generateMockSleeperMatchup( + matchupId=20230203, rosterId=202306, points=60 + ), + self.__generateMockSleeperMatchup( + matchupId=20230204, rosterId=202307, points=120 + ), + self.__generateMockSleeperMatchup( + matchupId=20230204, rosterId=202308, points=50 + ), ] # playoffs mockSleeperMatchups2023_3 = [ - self.__generateMockSleeperMatchup(matchupId=20230301, rosterId=202302, points=100), - self.__generateMockSleeperMatchup(matchupId=20230301, rosterId=202303, points=90.5), + self.__generateMockSleeperMatchup( + matchupId=20230301, rosterId=202302, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20230301, rosterId=202303, points=90.5 + ), ] # championship mockSleeperMatchups2023_4 = [ - self.__generateMockSleeperMatchup(matchupId=20230401, rosterId=202301, points=100), - self.__generateMockSleeperMatchup(matchupId=20230401, rosterId=202302, points=99), + self.__generateMockSleeperMatchup( + matchupId=20230401, rosterId=202301, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20230401, rosterId=202302, points=99 + ), ] # create mock SleeperSportState objects - mockSleeperSportState2022 = self.__generateMockSleeperSportState(season="2022", leg=5) - mockSleeperSportState2023 = self.__generateMockSleeperSportState(season="2023", leg=5) + mockSleeperSportState2022 = self.__generateMockSleeperSportState( + season="2022", leg=5 + ) + mockSleeperSportState2023 = self.__generateMockSleeperSportState( + season="2023", leg=5 + ) # create mock SleeperPlayoffMatchup objects mockSleeperPlayoffMatchups2022 = [ @@ -405,7 +491,10 @@ def test_load_league_happyPath( mockSleeperMatchups2023_3, mockSleeperMatchups2023_4, ] - mockGetSportState.side_effect = [mockSleeperSportState2022, mockSleeperSportState2023] + mockGetSportState.side_effect = [ + mockSleeperSportState2022, + mockSleeperSportState2023, + ] mockGetWinnersBracket.side_effect = [ mockSleeperPlayoffMatchups2022, mockSleeperPlayoffMatchups2023, @@ -432,23 +521,55 @@ def test_load_league_happyPath( owner7 = Owner(name="User 7") owner8 = Owner(name="User 8") - team1_2022 = Team(ownerId=owner1.id, name="User 1", divisionId=division1_2022.id) - team2_2022 = Team(ownerId=owner2.id, name="User 2", divisionId=division1_2022.id) - team3_2022 = Team(ownerId=owner3.id, name="User 3", divisionId=division1_2022.id) - team4_2022 = Team(ownerId=owner4.id, name="User 4", divisionId=division1_2022.id) - team5_2022 = Team(ownerId=owner5.id, name="Team 5", divisionId=division2_2022.id) - team6_2022 = Team(ownerId=owner6.id, name="Team 6", divisionId=division2_2022.id) - team7_2022 = Team(ownerId=owner7.id, name="Team 7", divisionId=division2_2022.id) - team8_2022 = Team(ownerId=owner8.id, name="Team 8", divisionId=division2_2022.id) - - team1_2023 = Team(ownerId=owner1.id, name="User 1", divisionId=division1_2023.id) - team2_2023 = Team(ownerId=owner2.id, name="User 2", divisionId=division1_2023.id) - team3_2023 = Team(ownerId=owner3.id, name="User 3", divisionId=division1_2023.id) - team4_2023 = Team(ownerId=owner4.id, name="User 4", divisionId=division1_2023.id) - team5_2023 = Team(ownerId=owner5.id, name="Team 5", divisionId=division2_2023.id) - team6_2023 = Team(ownerId=owner6.id, name="Team 6", divisionId=division2_2023.id) - team7_2023 = Team(ownerId=owner7.id, name="Team 7", divisionId=division2_2023.id) - team8_2023 = Team(ownerId=owner8.id, name="Team 8", divisionId=division2_2023.id) + team1_2022 = Team( + ownerId=owner1.id, name="User 1", divisionId=division1_2022.id + ) + team2_2022 = Team( + ownerId=owner2.id, name="User 2", divisionId=division1_2022.id + ) + team3_2022 = Team( + ownerId=owner3.id, name="User 3", divisionId=division1_2022.id + ) + team4_2022 = Team( + ownerId=owner4.id, name="User 4", divisionId=division1_2022.id + ) + team5_2022 = Team( + ownerId=owner5.id, name="Team 5", divisionId=division2_2022.id + ) + team6_2022 = Team( + ownerId=owner6.id, name="Team 6", divisionId=division2_2022.id + ) + team7_2022 = Team( + ownerId=owner7.id, name="Team 7", divisionId=division2_2022.id + ) + team8_2022 = Team( + ownerId=owner8.id, name="Team 8", divisionId=division2_2022.id + ) + + team1_2023 = Team( + ownerId=owner1.id, name="User 1", divisionId=division1_2023.id + ) + team2_2023 = Team( + ownerId=owner2.id, name="User 2", divisionId=division1_2023.id + ) + team3_2023 = Team( + ownerId=owner3.id, name="User 3", divisionId=division1_2023.id + ) + team4_2023 = Team( + ownerId=owner4.id, name="User 4", divisionId=division1_2023.id + ) + team5_2023 = Team( + ownerId=owner5.id, name="Team 5", divisionId=division2_2023.id + ) + team6_2023 = Team( + ownerId=owner6.id, name="Team 6", divisionId=division2_2023.id + ) + team7_2023 = Team( + ownerId=owner7.id, name="Team 7", divisionId=division2_2023.id + ) + team8_2023 = Team( + ownerId=owner8.id, name="Team 8", divisionId=division2_2023.id + ) expectedLeague = League( name="Test League 2023", @@ -730,7 +851,9 @@ def test_load_league_happyPath( ), ], ) - self.assertTrue(league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True)) + self.assertTrue( + league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True) + ) # check multiWeekMatchupIds for year in league.years: for week in year.weeks: @@ -803,41 +926,83 @@ def test_load_league_happyPath_withOwnerNamesAndAliases( # create mock SleeperMatchup objects # matchup id will be YYYY (year) WW (week number) MM (matchup number) mockSleeperMatchups2022_1 = [ - self.__generateMockSleeperMatchup(matchupId=20220101, rosterId=202201, points=100), - self.__generateMockSleeperMatchup(matchupId=20220101, rosterId=202202, points=100), - self.__generateMockSleeperMatchup(matchupId=20220102, rosterId=202203, points=90.5), - self.__generateMockSleeperMatchup(matchupId=20220102, rosterId=202204, points=70.5), - self.__generateMockSleeperMatchup(matchupId=20220103, rosterId=202205, points=110), - self.__generateMockSleeperMatchup(matchupId=20220103, rosterId=202206, points=60), - self.__generateMockSleeperMatchup(matchupId=20220104, rosterId=202207, points=120), - self.__generateMockSleeperMatchup(matchupId=20220104, rosterId=202208, points=50), + self.__generateMockSleeperMatchup( + matchupId=20220101, rosterId=202201, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220101, rosterId=202202, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220102, rosterId=202203, points=90.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20220102, rosterId=202204, points=70.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20220103, rosterId=202205, points=110 + ), + self.__generateMockSleeperMatchup( + matchupId=20220103, rosterId=202206, points=60 + ), + self.__generateMockSleeperMatchup( + matchupId=20220104, rosterId=202207, points=120 + ), + self.__generateMockSleeperMatchup( + matchupId=20220104, rosterId=202208, points=50 + ), ] mockSleeperMatchups2022_2 = [ - self.__generateMockSleeperMatchup(matchupId=20220201, rosterId=202201, points=100), - self.__generateMockSleeperMatchup(matchupId=20220201, rosterId=202202, points=100), - self.__generateMockSleeperMatchup(matchupId=20220202, rosterId=202203, points=90.5), - self.__generateMockSleeperMatchup(matchupId=20220202, rosterId=202204, points=70.5), - self.__generateMockSleeperMatchup(matchupId=20220203, rosterId=202205, points=110), - self.__generateMockSleeperMatchup(matchupId=20220203, rosterId=202206, points=60), - self.__generateMockSleeperMatchup(matchupId=20220204, rosterId=202207, points=120), - self.__generateMockSleeperMatchup(matchupId=20220204, rosterId=202208, points=50), + self.__generateMockSleeperMatchup( + matchupId=20220201, rosterId=202201, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220201, rosterId=202202, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220202, rosterId=202203, points=90.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20220202, rosterId=202204, points=70.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20220203, rosterId=202205, points=110 + ), + self.__generateMockSleeperMatchup( + matchupId=20220203, rosterId=202206, points=60 + ), + self.__generateMockSleeperMatchup( + matchupId=20220204, rosterId=202207, points=120 + ), + self.__generateMockSleeperMatchup( + matchupId=20220204, rosterId=202208, points=50 + ), ] # playoffs mockSleeperMatchups2022_3 = [ - self.__generateMockSleeperMatchup(matchupId=20220301, rosterId=202202, points=100), - self.__generateMockSleeperMatchup(matchupId=20220301, rosterId=202203, points=90.5), + self.__generateMockSleeperMatchup( + matchupId=20220301, rosterId=202202, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220301, rosterId=202203, points=90.5 + ), ] # championship mockSleeperMatchups2022_4 = [ - self.__generateMockSleeperMatchup(matchupId=20220401, rosterId=202201, points=100), - self.__generateMockSleeperMatchup(matchupId=20220401, rosterId=202202, points=99), + self.__generateMockSleeperMatchup( + matchupId=20220401, rosterId=202201, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220401, rosterId=202202, points=99 + ), ] # create mock SleeperSportState objects - mockSleeperSportState2022 = self.__generateMockSleeperSportState(season="2022", leg=5) + mockSleeperSportState2022 = self.__generateMockSleeperSportState( + season="2022", leg=5 + ) # create mock SleeperPlayoffMatchup objects mockSleeperPlayoffMatchups2022 = [ @@ -1054,7 +1219,9 @@ def test_load_league_happyPath_withOwnerNamesAndAliases( ) ], ) - self.assertTrue(league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True)) + self.assertTrue( + league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True) + ) # check multiWeekMatchupIds for year in league.years: for week in year.weeks: @@ -1172,76 +1339,160 @@ def test_load_league_happyPath( # create mock SleeperMatchup objects # matchup id will be YYYY (year) WW (week number) MM (matchup number) mockSleeperMatchups2022_1 = [ - self.__generateMockSleeperMatchup(matchupId=20220101, rosterId=202201, points=100), - self.__generateMockSleeperMatchup(matchupId=20220101, rosterId=202202, points=100), - self.__generateMockSleeperMatchup(matchupId=20220102, rosterId=202203, points=90.5), - self.__generateMockSleeperMatchup(matchupId=20220102, rosterId=202204, points=70.5), - self.__generateMockSleeperMatchup(matchupId=20220103, rosterId=202205, points=110), - self.__generateMockSleeperMatchup(matchupId=20220103, rosterId=202206, points=60), - self.__generateMockSleeperMatchup(matchupId=20220104, rosterId=202207, points=120), - self.__generateMockSleeperMatchup(matchupId=20220104, rosterId=202208, points=50), + self.__generateMockSleeperMatchup( + matchupId=20220101, rosterId=202201, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220101, rosterId=202202, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220102, rosterId=202203, points=90.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20220102, rosterId=202204, points=70.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20220103, rosterId=202205, points=110 + ), + self.__generateMockSleeperMatchup( + matchupId=20220103, rosterId=202206, points=60 + ), + self.__generateMockSleeperMatchup( + matchupId=20220104, rosterId=202207, points=120 + ), + self.__generateMockSleeperMatchup( + matchupId=20220104, rosterId=202208, points=50 + ), ] mockSleeperMatchups2022_2 = [ - self.__generateMockSleeperMatchup(matchupId=20220201, rosterId=202201, points=100), - self.__generateMockSleeperMatchup(matchupId=20220201, rosterId=202202, points=100), - self.__generateMockSleeperMatchup(matchupId=20220202, rosterId=202203, points=90.5), - self.__generateMockSleeperMatchup(matchupId=20220202, rosterId=202204, points=70.5), - self.__generateMockSleeperMatchup(matchupId=20220203, rosterId=202205, points=110), - self.__generateMockSleeperMatchup(matchupId=20220203, rosterId=202206, points=60), - self.__generateMockSleeperMatchup(matchupId=20220204, rosterId=202207, points=120), - self.__generateMockSleeperMatchup(matchupId=20220204, rosterId=202208, points=50), + self.__generateMockSleeperMatchup( + matchupId=20220201, rosterId=202201, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220201, rosterId=202202, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220202, rosterId=202203, points=90.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20220202, rosterId=202204, points=70.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20220203, rosterId=202205, points=110 + ), + self.__generateMockSleeperMatchup( + matchupId=20220203, rosterId=202206, points=60 + ), + self.__generateMockSleeperMatchup( + matchupId=20220204, rosterId=202207, points=120 + ), + self.__generateMockSleeperMatchup( + matchupId=20220204, rosterId=202208, points=50 + ), ] # playoffs mockSleeperMatchups2022_3 = [ - self.__generateMockSleeperMatchup(matchupId=20220301, rosterId=202202, points=100), - self.__generateMockSleeperMatchup(matchupId=20220301, rosterId=202203, points=90.5), + self.__generateMockSleeperMatchup( + matchupId=20220301, rosterId=202202, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220301, rosterId=202203, points=90.5 + ), ] # championship mockSleeperMatchups2022_4 = [ - self.__generateMockSleeperMatchup(matchupId=20220401, rosterId=202201, points=100), - self.__generateMockSleeperMatchup(matchupId=20220401, rosterId=202202, points=99), + self.__generateMockSleeperMatchup( + matchupId=20220401, rosterId=202201, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220401, rosterId=202202, points=99 + ), ] mockSleeperMatchups2023_1 = [ - self.__generateMockSleeperMatchup(matchupId=20230101, rosterId=202301, points=100), - self.__generateMockSleeperMatchup(matchupId=20230101, rosterId=202302, points=100), - self.__generateMockSleeperMatchup(matchupId=20230102, rosterId=202303, points=90.5), - self.__generateMockSleeperMatchup(matchupId=20230102, rosterId=202304, points=70.5), - self.__generateMockSleeperMatchup(matchupId=20230103, rosterId=202305, points=110), - self.__generateMockSleeperMatchup(matchupId=20230103, rosterId=202306, points=60), - self.__generateMockSleeperMatchup(matchupId=20230104, rosterId=202307, points=120), - self.__generateMockSleeperMatchup(matchupId=20230104, rosterId=202308, points=50), + self.__generateMockSleeperMatchup( + matchupId=20230101, rosterId=202301, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20230101, rosterId=202302, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20230102, rosterId=202303, points=90.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20230102, rosterId=202304, points=70.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20230103, rosterId=202305, points=110 + ), + self.__generateMockSleeperMatchup( + matchupId=20230103, rosterId=202306, points=60 + ), + self.__generateMockSleeperMatchup( + matchupId=20230104, rosterId=202307, points=120 + ), + self.__generateMockSleeperMatchup( + matchupId=20230104, rosterId=202308, points=50 + ), ] mockSleeperMatchups2023_2 = [ - self.__generateMockSleeperMatchup(matchupId=20230201, rosterId=202301, points=100), - self.__generateMockSleeperMatchup(matchupId=20230201, rosterId=202302, points=100), - self.__generateMockSleeperMatchup(matchupId=20230202, rosterId=202303, points=90.5), - self.__generateMockSleeperMatchup(matchupId=20230202, rosterId=202304, points=70.5), - self.__generateMockSleeperMatchup(matchupId=20230203, rosterId=202305, points=110), - self.__generateMockSleeperMatchup(matchupId=20230203, rosterId=202306, points=60), - self.__generateMockSleeperMatchup(matchupId=20230204, rosterId=202307, points=120), - self.__generateMockSleeperMatchup(matchupId=20230204, rosterId=202308, points=50), + self.__generateMockSleeperMatchup( + matchupId=20230201, rosterId=202301, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20230201, rosterId=202302, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20230202, rosterId=202303, points=90.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20230202, rosterId=202304, points=70.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20230203, rosterId=202305, points=110 + ), + self.__generateMockSleeperMatchup( + matchupId=20230203, rosterId=202306, points=60 + ), + self.__generateMockSleeperMatchup( + matchupId=20230204, rosterId=202307, points=120 + ), + self.__generateMockSleeperMatchup( + matchupId=20230204, rosterId=202308, points=50 + ), ] # playoffs mockSleeperMatchups2023_3 = [ - self.__generateMockSleeperMatchup(matchupId=20230301, rosterId=202302, points=100), - self.__generateMockSleeperMatchup(matchupId=20230301, rosterId=202303, points=90.5), + self.__generateMockSleeperMatchup( + matchupId=20230301, rosterId=202302, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20230301, rosterId=202303, points=90.5 + ), ] # championship mockSleeperMatchups2023_4 = [ - self.__generateMockSleeperMatchup(matchupId=20230401, rosterId=202301, points=100), - self.__generateMockSleeperMatchup(matchupId=20230401, rosterId=202302, points=99), + self.__generateMockSleeperMatchup( + matchupId=20230401, rosterId=202301, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20230401, rosterId=202302, points=99 + ), ] # create mock SleeperSportState objects - mockSleeperSportState2022 = self.__generateMockSleeperSportState(season="2022", leg=5) - mockSleeperSportState2023 = self.__generateMockSleeperSportState(season="2023", leg=5) + mockSleeperSportState2022 = self.__generateMockSleeperSportState( + season="2022", leg=5 + ) + mockSleeperSportState2023 = self.__generateMockSleeperSportState( + season="2023", leg=5 + ) # create mock SleeperPlayoffMatchup objects mockSleeperPlayoffMatchups2022 = [ @@ -1295,14 +1546,19 @@ def test_load_league_happyPath( mockSleeperMatchups2023_3, mockSleeperMatchups2023_4, ] - mockGetSportState.side_effect = [mockSleeperSportState2022, mockSleeperSportState2023] + mockGetSportState.side_effect = [ + mockSleeperSportState2022, + mockSleeperSportState2023, + ] mockGetWinnersBracket.side_effect = [ mockSleeperPlayoffMatchups2022, mockSleeperPlayoffMatchups2023, ] # create instance of SleeperLeagueLoader and call load_league method - sleeper_league_loader = SleeperLeagueLoader("123", [2022, 2023], leagueName="custom name") + sleeper_league_loader = SleeperLeagueLoader( + "123", [2022, 2023], leagueName="custom name" + ) league = sleeper_league_loader.loadLeague() self.assertEqual("custom name", league.name) @@ -1373,47 +1629,93 @@ def test_load_league_happyPath_playoffRoundType_twoWeekChampionshipRound( # create mock SleeperMatchup objects # matchup id will be YYYY (year) WW (week number) MM (matchup number) mockSleeperMatchups2022_1 = [ - self.__generateMockSleeperMatchup(matchupId=20220101, rosterId=202201, points=100), - self.__generateMockSleeperMatchup(matchupId=20220101, rosterId=202202, points=100), - self.__generateMockSleeperMatchup(matchupId=20220102, rosterId=202203, points=90.5), - self.__generateMockSleeperMatchup(matchupId=20220102, rosterId=202204, points=70.5), - self.__generateMockSleeperMatchup(matchupId=20220103, rosterId=202205, points=110), - self.__generateMockSleeperMatchup(matchupId=20220103, rosterId=202206, points=60), - self.__generateMockSleeperMatchup(matchupId=20220104, rosterId=202207, points=120), - self.__generateMockSleeperMatchup(matchupId=20220104, rosterId=202208, points=50), + self.__generateMockSleeperMatchup( + matchupId=20220101, rosterId=202201, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220101, rosterId=202202, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220102, rosterId=202203, points=90.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20220102, rosterId=202204, points=70.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20220103, rosterId=202205, points=110 + ), + self.__generateMockSleeperMatchup( + matchupId=20220103, rosterId=202206, points=60 + ), + self.__generateMockSleeperMatchup( + matchupId=20220104, rosterId=202207, points=120 + ), + self.__generateMockSleeperMatchup( + matchupId=20220104, rosterId=202208, points=50 + ), ] mockSleeperMatchups2022_2 = [ - self.__generateMockSleeperMatchup(matchupId=20220201, rosterId=202201, points=100), - self.__generateMockSleeperMatchup(matchupId=20220201, rosterId=202202, points=100), - self.__generateMockSleeperMatchup(matchupId=20220202, rosterId=202203, points=90.5), - self.__generateMockSleeperMatchup(matchupId=20220202, rosterId=202204, points=70.5), - self.__generateMockSleeperMatchup(matchupId=20220203, rosterId=202205, points=110), - self.__generateMockSleeperMatchup(matchupId=20220203, rosterId=202206, points=60), - self.__generateMockSleeperMatchup(matchupId=20220204, rosterId=202207, points=120), - self.__generateMockSleeperMatchup(matchupId=20220204, rosterId=202208, points=50), + self.__generateMockSleeperMatchup( + matchupId=20220201, rosterId=202201, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220201, rosterId=202202, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220202, rosterId=202203, points=90.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20220202, rosterId=202204, points=70.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20220203, rosterId=202205, points=110 + ), + self.__generateMockSleeperMatchup( + matchupId=20220203, rosterId=202206, points=60 + ), + self.__generateMockSleeperMatchup( + matchupId=20220204, rosterId=202207, points=120 + ), + self.__generateMockSleeperMatchup( + matchupId=20220204, rosterId=202208, points=50 + ), ] # playoffs mockSleeperMatchups2022_3 = [ - self.__generateMockSleeperMatchup(matchupId=20220301, rosterId=202202, points=100), - self.__generateMockSleeperMatchup(matchupId=20220301, rosterId=202203, points=90.5), + self.__generateMockSleeperMatchup( + matchupId=20220301, rosterId=202202, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220301, rosterId=202203, points=90.5 + ), ] # championship 1 mockSleeperMatchups2022_4 = [ - self.__generateMockSleeperMatchup(matchupId=20220401, rosterId=202201, points=100), - self.__generateMockSleeperMatchup(matchupId=20220401, rosterId=202202, points=99), + self.__generateMockSleeperMatchup( + matchupId=20220401, rosterId=202201, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220401, rosterId=202202, points=99 + ), ] # championship 2 mockSleeperMatchups2022_5 = [ - self.__generateMockSleeperMatchup(matchupId=20220501, rosterId=202201, points=100), - self.__generateMockSleeperMatchup(matchupId=20220501, rosterId=202202, points=99), + self.__generateMockSleeperMatchup( + matchupId=20220501, rosterId=202201, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220501, rosterId=202202, points=99 + ), ] # create mock SleeperSportState objects - mockSleeperSportState2022 = self.__generateMockSleeperSportState(season="2022", leg=6) + mockSleeperSportState2022 = self.__generateMockSleeperSportState( + season="2022", leg=6 + ) # create mock SleeperPlayoffMatchup objects mockSleeperPlayoffMatchups2022 = [ @@ -1474,14 +1776,30 @@ def test_load_league_happyPath_playoffRoundType_twoWeekChampionshipRound( division1_2022 = Division(name="d1_2022") division2_2022 = Division(name="d2_2022") - team1_2022 = Team(ownerId=owner1.id, name="User 1", divisionId=division1_2022.id) - team2_2022 = Team(ownerId=owner2.id, name="User 2", divisionId=division1_2022.id) - team3_2022 = Team(ownerId=owner3.id, name="User 3", divisionId=division1_2022.id) - team4_2022 = Team(ownerId=owner4.id, name="User 4", divisionId=division1_2022.id) - team5_2022 = Team(ownerId=owner5.id, name="Team 5", divisionId=division2_2022.id) - team6_2022 = Team(ownerId=owner6.id, name="Team 6", divisionId=division2_2022.id) - team7_2022 = Team(ownerId=owner7.id, name="Team 7", divisionId=division2_2022.id) - team8_2022 = Team(ownerId=owner8.id, name="Team 8", divisionId=division2_2022.id) + team1_2022 = Team( + ownerId=owner1.id, name="User 1", divisionId=division1_2022.id + ) + team2_2022 = Team( + ownerId=owner2.id, name="User 2", divisionId=division1_2022.id + ) + team3_2022 = Team( + ownerId=owner3.id, name="User 3", divisionId=division1_2022.id + ) + team4_2022 = Team( + ownerId=owner4.id, name="User 4", divisionId=division1_2022.id + ) + team5_2022 = Team( + ownerId=owner5.id, name="Team 5", divisionId=division2_2022.id + ) + team6_2022 = Team( + ownerId=owner6.id, name="Team 6", divisionId=division2_2022.id + ) + team7_2022 = Team( + ownerId=owner7.id, name="Team 7", divisionId=division2_2022.id + ) + team8_2022 = Team( + ownerId=owner8.id, name="Team 8", divisionId=division2_2022.id + ) expectedLeague = League( name="Test League 2022", @@ -1630,7 +1948,9 @@ def test_load_league_happyPath_playoffRoundType_twoWeekChampionshipRound( ) ], ) - self.assertTrue(league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True)) + self.assertTrue( + league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True) + ) # check multiWeekMatchupIds for year in league.years: for week in year.weeks[:3]: @@ -1639,7 +1959,8 @@ def test_load_league_happyPath_playoffRoundType_twoWeekChampionshipRound( for week in year.weeks[3:]: for matchup in week.matchups: self.assertEqual( - f"{matchup.teamAId}{matchup.teamBId}", matchup.multiWeekMatchupId + f"{matchup.teamAId}{matchup.teamBId}", + matchup.multiWeekMatchupId, ) @patch("sleeper.api.LeagueAPIClient.get_league") @@ -1708,53 +2029,103 @@ def test_load_league_happyPath_playoffRoundType_twoWeeksPerRound( # create mock SleeperMatchup objects # matchup id will be YYYY (year) WW (week number) MM (matchup number) mockSleeperMatchups2022_1 = [ - self.__generateMockSleeperMatchup(matchupId=20220101, rosterId=202201, points=100), - self.__generateMockSleeperMatchup(matchupId=20220101, rosterId=202202, points=100), - self.__generateMockSleeperMatchup(matchupId=20220102, rosterId=202203, points=90.5), - self.__generateMockSleeperMatchup(matchupId=20220102, rosterId=202204, points=70.5), - self.__generateMockSleeperMatchup(matchupId=20220103, rosterId=202205, points=110), - self.__generateMockSleeperMatchup(matchupId=20220103, rosterId=202206, points=60), - self.__generateMockSleeperMatchup(matchupId=20220104, rosterId=202207, points=120), - self.__generateMockSleeperMatchup(matchupId=20220104, rosterId=202208, points=50), + self.__generateMockSleeperMatchup( + matchupId=20220101, rosterId=202201, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220101, rosterId=202202, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220102, rosterId=202203, points=90.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20220102, rosterId=202204, points=70.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20220103, rosterId=202205, points=110 + ), + self.__generateMockSleeperMatchup( + matchupId=20220103, rosterId=202206, points=60 + ), + self.__generateMockSleeperMatchup( + matchupId=20220104, rosterId=202207, points=120 + ), + self.__generateMockSleeperMatchup( + matchupId=20220104, rosterId=202208, points=50 + ), ] mockSleeperMatchups2022_2 = [ - self.__generateMockSleeperMatchup(matchupId=20220201, rosterId=202201, points=100), - self.__generateMockSleeperMatchup(matchupId=20220201, rosterId=202202, points=100), - self.__generateMockSleeperMatchup(matchupId=20220202, rosterId=202203, points=90.5), - self.__generateMockSleeperMatchup(matchupId=20220202, rosterId=202204, points=70.5), - self.__generateMockSleeperMatchup(matchupId=20220203, rosterId=202205, points=110), - self.__generateMockSleeperMatchup(matchupId=20220203, rosterId=202206, points=60), - self.__generateMockSleeperMatchup(matchupId=20220204, rosterId=202207, points=120), - self.__generateMockSleeperMatchup(matchupId=20220204, rosterId=202208, points=50), + self.__generateMockSleeperMatchup( + matchupId=20220201, rosterId=202201, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220201, rosterId=202202, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220202, rosterId=202203, points=90.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20220202, rosterId=202204, points=70.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20220203, rosterId=202205, points=110 + ), + self.__generateMockSleeperMatchup( + matchupId=20220203, rosterId=202206, points=60 + ), + self.__generateMockSleeperMatchup( + matchupId=20220204, rosterId=202207, points=120 + ), + self.__generateMockSleeperMatchup( + matchupId=20220204, rosterId=202208, points=50 + ), ] # playoffs 1 mockSleeperMatchups2022_3 = [ - self.__generateMockSleeperMatchup(matchupId=20220301, rosterId=202202, points=100), - self.__generateMockSleeperMatchup(matchupId=20220301, rosterId=202203, points=90.5), + self.__generateMockSleeperMatchup( + matchupId=20220301, rosterId=202202, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220301, rosterId=202203, points=90.5 + ), ] # playoffs 2 mockSleeperMatchups2022_4 = [ - self.__generateMockSleeperMatchup(matchupId=20220401, rosterId=202202, points=100), - self.__generateMockSleeperMatchup(matchupId=20220401, rosterId=202203, points=90.5), + self.__generateMockSleeperMatchup( + matchupId=20220401, rosterId=202202, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220401, rosterId=202203, points=90.5 + ), ] # championship 1 mockSleeperMatchups2022_5 = [ - self.__generateMockSleeperMatchup(matchupId=20220501, rosterId=202201, points=100), - self.__generateMockSleeperMatchup(matchupId=20220501, rosterId=202202, points=99), + self.__generateMockSleeperMatchup( + matchupId=20220501, rosterId=202201, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220501, rosterId=202202, points=99 + ), ] # championship 2 mockSleeperMatchups2022_6 = [ - self.__generateMockSleeperMatchup(matchupId=20220601, rosterId=202201, points=100), - self.__generateMockSleeperMatchup(matchupId=20220601, rosterId=202202, points=99), + self.__generateMockSleeperMatchup( + matchupId=20220601, rosterId=202201, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220601, rosterId=202202, points=99 + ), ] # create mock SleeperSportState objects - mockSleeperSportState2022 = self.__generateMockSleeperSportState(season="2022", leg=7) + mockSleeperSportState2022 = self.__generateMockSleeperSportState( + season="2022", leg=7 + ) # create mock SleeperPlayoffMatchup objects mockSleeperPlayoffMatchups2022 = [ @@ -1824,14 +2195,30 @@ def test_load_league_happyPath_playoffRoundType_twoWeeksPerRound( division1_2022 = Division(name="d1_2022") division2_2022 = Division(name="d2_2022") - team1_2022 = Team(ownerId=owner1.id, name="User 1", divisionId=division1_2022.id) - team2_2022 = Team(ownerId=owner2.id, name="User 2", divisionId=division1_2022.id) - team3_2022 = Team(ownerId=owner3.id, name="User 3", divisionId=division1_2022.id) - team4_2022 = Team(ownerId=owner4.id, name="User 4", divisionId=division1_2022.id) - team5_2022 = Team(ownerId=owner5.id, name="Team 5", divisionId=division2_2022.id) - team6_2022 = Team(ownerId=owner6.id, name="Team 6", divisionId=division2_2022.id) - team7_2022 = Team(ownerId=owner7.id, name="Team 7", divisionId=division2_2022.id) - team8_2022 = Team(ownerId=owner8.id, name="Team 8", divisionId=division2_2022.id) + team1_2022 = Team( + ownerId=owner1.id, name="User 1", divisionId=division1_2022.id + ) + team2_2022 = Team( + ownerId=owner2.id, name="User 2", divisionId=division1_2022.id + ) + team3_2022 = Team( + ownerId=owner3.id, name="User 3", divisionId=division1_2022.id + ) + team4_2022 = Team( + ownerId=owner4.id, name="User 4", divisionId=division1_2022.id + ) + team5_2022 = Team( + ownerId=owner5.id, name="Team 5", divisionId=division2_2022.id + ) + team6_2022 = Team( + ownerId=owner6.id, name="Team 6", divisionId=division2_2022.id + ) + team7_2022 = Team( + ownerId=owner7.id, name="Team 7", divisionId=division2_2022.id + ) + team8_2022 = Team( + ownerId=owner8.id, name="Team 8", divisionId=division2_2022.id + ) expectedLeague = League( name="Test League 2022", @@ -1994,7 +2381,9 @@ def test_load_league_happyPath_playoffRoundType_twoWeeksPerRound( ) ], ) - self.assertTrue(league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True)) + self.assertTrue( + league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True) + ) # check multiWeekMatchupIds for year in league.years: for week in year.weeks[:2]: @@ -2003,7 +2392,8 @@ def test_load_league_happyPath_playoffRoundType_twoWeeksPerRound( for week in year.weeks[2:]: for matchup in week.matchups: self.assertEqual( - f"{matchup.teamAId}{matchup.teamBId}", matchup.multiWeekMatchupId + f"{matchup.teamAId}{matchup.teamBId}", + matchup.multiWeekMatchupId, ) @patch("sleeper.api.LeagueAPIClient.get_league") @@ -2048,11 +2438,17 @@ def test_load_league_happyPath_playoffRoundType_unsupported_raisesException( # create mock SleeperMatchup objects # matchup id will be YYYY (year) WW (week number) MM (matchup number) mockSleeperMatchups2022_1 = [ - self.__generateMockSleeperMatchup(matchupId=20220101, rosterId=202201, points=100), - self.__generateMockSleeperMatchup(matchupId=20220101, rosterId=202202, points=100), + self.__generateMockSleeperMatchup( + matchupId=20220101, rosterId=202201, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220101, rosterId=202202, points=100 + ), ] # create mock SleeperSportState objects - mockSleeperSportState2022 = self.__generateMockSleeperSportState(season="2022", leg=None) + mockSleeperSportState2022 = self.__generateMockSleeperSportState( + season="2022", leg=None + ) # create mock SleeperPlayoffMatchup objects mockSleeperPlayoffMatchups2022 = [ @@ -2076,7 +2472,9 @@ def test_load_league_happyPath_playoffRoundType_unsupported_raisesException( with self.assertRaises(LeagueLoaderException) as context: sleeper_league_loader = SleeperLeagueLoader("123", [2022]) sleeper_league_loader.loadLeague() - self.assertEqual("PlayoffRoundType 'None' is not supported.", str(context.exception)) + self.assertEqual( + "PlayoffRoundType 'None' is not supported.", str(context.exception) + ) @patch("sleeper.api.LeagueAPIClient.get_league") @patch("sleeper.api.LeagueAPIClient.get_users_in_league") @@ -2188,76 +2586,160 @@ def test_load_league_happyPath_leagueMedianGames( # create mock SleeperMatchup objects # matchup id will be YYYY (year) WW (week number) MM (matchup number) mockSleeperMatchups2022_1 = [ - self.__generateMockSleeperMatchup(matchupId=20220101, rosterId=202201, points=100), - self.__generateMockSleeperMatchup(matchupId=20220101, rosterId=202202, points=100), - self.__generateMockSleeperMatchup(matchupId=20220102, rosterId=202203, points=90.5), - self.__generateMockSleeperMatchup(matchupId=20220102, rosterId=202204, points=70.5), - self.__generateMockSleeperMatchup(matchupId=20220103, rosterId=202205, points=110), - self.__generateMockSleeperMatchup(matchupId=20220103, rosterId=202206, points=60), - self.__generateMockSleeperMatchup(matchupId=20220104, rosterId=202207, points=120), - self.__generateMockSleeperMatchup(matchupId=20220104, rosterId=202208, points=50), + self.__generateMockSleeperMatchup( + matchupId=20220101, rosterId=202201, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220101, rosterId=202202, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220102, rosterId=202203, points=90.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20220102, rosterId=202204, points=70.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20220103, rosterId=202205, points=110 + ), + self.__generateMockSleeperMatchup( + matchupId=20220103, rosterId=202206, points=60 + ), + self.__generateMockSleeperMatchup( + matchupId=20220104, rosterId=202207, points=120 + ), + self.__generateMockSleeperMatchup( + matchupId=20220104, rosterId=202208, points=50 + ), ] mockSleeperMatchups2022_2 = [ - self.__generateMockSleeperMatchup(matchupId=20220201, rosterId=202201, points=100), - self.__generateMockSleeperMatchup(matchupId=20220201, rosterId=202202, points=100), - self.__generateMockSleeperMatchup(matchupId=20220202, rosterId=202203, points=90.5), - self.__generateMockSleeperMatchup(matchupId=20220202, rosterId=202204, points=70.5), - self.__generateMockSleeperMatchup(matchupId=20220203, rosterId=202205, points=110), - self.__generateMockSleeperMatchup(matchupId=20220203, rosterId=202206, points=60), - self.__generateMockSleeperMatchup(matchupId=20220204, rosterId=202207, points=120), - self.__generateMockSleeperMatchup(matchupId=20220204, rosterId=202208, points=50), + self.__generateMockSleeperMatchup( + matchupId=20220201, rosterId=202201, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220201, rosterId=202202, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220202, rosterId=202203, points=90.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20220202, rosterId=202204, points=70.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20220203, rosterId=202205, points=110 + ), + self.__generateMockSleeperMatchup( + matchupId=20220203, rosterId=202206, points=60 + ), + self.__generateMockSleeperMatchup( + matchupId=20220204, rosterId=202207, points=120 + ), + self.__generateMockSleeperMatchup( + matchupId=20220204, rosterId=202208, points=50 + ), ] # playoffs mockSleeperMatchups2022_3 = [ - self.__generateMockSleeperMatchup(matchupId=20220301, rosterId=202202, points=100), - self.__generateMockSleeperMatchup(matchupId=20220301, rosterId=202203, points=90.5), + self.__generateMockSleeperMatchup( + matchupId=20220301, rosterId=202202, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220301, rosterId=202203, points=90.5 + ), ] # championship mockSleeperMatchups2022_4 = [ - self.__generateMockSleeperMatchup(matchupId=20220401, rosterId=202201, points=100), - self.__generateMockSleeperMatchup(matchupId=20220401, rosterId=202202, points=99), + self.__generateMockSleeperMatchup( + matchupId=20220401, rosterId=202201, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20220401, rosterId=202202, points=99 + ), ] mockSleeperMatchups2023_1 = [ - self.__generateMockSleeperMatchup(matchupId=20230101, rosterId=202301, points=100), - self.__generateMockSleeperMatchup(matchupId=20230101, rosterId=202302, points=100), - self.__generateMockSleeperMatchup(matchupId=20230102, rosterId=202303, points=90.5), - self.__generateMockSleeperMatchup(matchupId=20230102, rosterId=202304, points=70.5), - self.__generateMockSleeperMatchup(matchupId=20230103, rosterId=202305, points=110), - self.__generateMockSleeperMatchup(matchupId=20230103, rosterId=202306, points=60), - self.__generateMockSleeperMatchup(matchupId=20230104, rosterId=202307, points=120), - self.__generateMockSleeperMatchup(matchupId=20230104, rosterId=202308, points=50), + self.__generateMockSleeperMatchup( + matchupId=20230101, rosterId=202301, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20230101, rosterId=202302, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20230102, rosterId=202303, points=90.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20230102, rosterId=202304, points=70.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20230103, rosterId=202305, points=110 + ), + self.__generateMockSleeperMatchup( + matchupId=20230103, rosterId=202306, points=60 + ), + self.__generateMockSleeperMatchup( + matchupId=20230104, rosterId=202307, points=120 + ), + self.__generateMockSleeperMatchup( + matchupId=20230104, rosterId=202308, points=50 + ), ] mockSleeperMatchups2023_2 = [ - self.__generateMockSleeperMatchup(matchupId=20230201, rosterId=202301, points=100), - self.__generateMockSleeperMatchup(matchupId=20230201, rosterId=202302, points=100), - self.__generateMockSleeperMatchup(matchupId=20230202, rosterId=202303, points=90.5), - self.__generateMockSleeperMatchup(matchupId=20230202, rosterId=202304, points=70.5), - self.__generateMockSleeperMatchup(matchupId=20230203, rosterId=202305, points=110), - self.__generateMockSleeperMatchup(matchupId=20230203, rosterId=202306, points=60), - self.__generateMockSleeperMatchup(matchupId=20230204, rosterId=202307, points=120), - self.__generateMockSleeperMatchup(matchupId=20230204, rosterId=202308, points=50), + self.__generateMockSleeperMatchup( + matchupId=20230201, rosterId=202301, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20230201, rosterId=202302, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20230202, rosterId=202303, points=90.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20230202, rosterId=202304, points=70.5 + ), + self.__generateMockSleeperMatchup( + matchupId=20230203, rosterId=202305, points=110 + ), + self.__generateMockSleeperMatchup( + matchupId=20230203, rosterId=202306, points=60 + ), + self.__generateMockSleeperMatchup( + matchupId=20230204, rosterId=202307, points=120 + ), + self.__generateMockSleeperMatchup( + matchupId=20230204, rosterId=202308, points=50 + ), ] # playoffs mockSleeperMatchups2023_3 = [ - self.__generateMockSleeperMatchup(matchupId=20230301, rosterId=202302, points=100), - self.__generateMockSleeperMatchup(matchupId=20230301, rosterId=202303, points=90.5), + self.__generateMockSleeperMatchup( + matchupId=20230301, rosterId=202302, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20230301, rosterId=202303, points=90.5 + ), ] # championship mockSleeperMatchups2023_4 = [ - self.__generateMockSleeperMatchup(matchupId=20230401, rosterId=202301, points=100), - self.__generateMockSleeperMatchup(matchupId=20230401, rosterId=202302, points=99), + self.__generateMockSleeperMatchup( + matchupId=20230401, rosterId=202301, points=100 + ), + self.__generateMockSleeperMatchup( + matchupId=20230401, rosterId=202302, points=99 + ), ] # create mock SleeperSportState objects - mockSleeperSportState2022 = self.__generateMockSleeperSportState(season="2022", leg=5) - mockSleeperSportState2023 = self.__generateMockSleeperSportState(season="2023", leg=5) + mockSleeperSportState2022 = self.__generateMockSleeperSportState( + season="2022", leg=5 + ) + mockSleeperSportState2023 = self.__generateMockSleeperSportState( + season="2023", leg=5 + ) # create mock SleeperPlayoffMatchup objects mockSleeperPlayoffMatchups2022 = [ @@ -2311,7 +2793,10 @@ def test_load_league_happyPath_leagueMedianGames( mockSleeperMatchups2023_3, mockSleeperMatchups2023_4, ] - mockGetSportState.side_effect = [mockSleeperSportState2022, mockSleeperSportState2023] + mockGetSportState.side_effect = [ + mockSleeperSportState2022, + mockSleeperSportState2023, + ] mockGetWinnersBracket.side_effect = [ mockSleeperPlayoffMatchups2022, mockSleeperPlayoffMatchups2023, @@ -2338,23 +2823,55 @@ def test_load_league_happyPath_leagueMedianGames( division1_2023 = Division(name="d1_2023") division2_2023 = Division(name="d2_2023") - team1_2022 = Team(ownerId=owner1.id, name="User 1", divisionId=division1_2022.id) - team2_2022 = Team(ownerId=owner2.id, name="User 2", divisionId=division1_2022.id) - team3_2022 = Team(ownerId=owner3.id, name="User 3", divisionId=division1_2022.id) - team4_2022 = Team(ownerId=owner4.id, name="User 4", divisionId=division1_2022.id) - team5_2022 = Team(ownerId=owner5.id, name="Team 5", divisionId=division2_2022.id) - team6_2022 = Team(ownerId=owner6.id, name="Team 6", divisionId=division2_2022.id) - team7_2022 = Team(ownerId=owner7.id, name="Team 7", divisionId=division2_2022.id) - team8_2022 = Team(ownerId=owner8.id, name="Team 8", divisionId=division2_2022.id) - - team1_2023 = Team(ownerId=owner1.id, name="User 1", divisionId=division1_2023.id) - team2_2023 = Team(ownerId=owner2.id, name="User 2", divisionId=division1_2023.id) - team3_2023 = Team(ownerId=owner3.id, name="User 3", divisionId=division1_2023.id) - team4_2023 = Team(ownerId=owner4.id, name="User 4", divisionId=division1_2023.id) - team5_2023 = Team(ownerId=owner5.id, name="Team 5", divisionId=division2_2023.id) - team6_2023 = Team(ownerId=owner6.id, name="Team 6", divisionId=division2_2023.id) - team7_2023 = Team(ownerId=owner7.id, name="Team 7", divisionId=division2_2023.id) - team8_2023 = Team(ownerId=owner8.id, name="Team 8", divisionId=division2_2023.id) + team1_2022 = Team( + ownerId=owner1.id, name="User 1", divisionId=division1_2022.id + ) + team2_2022 = Team( + ownerId=owner2.id, name="User 2", divisionId=division1_2022.id + ) + team3_2022 = Team( + ownerId=owner3.id, name="User 3", divisionId=division1_2022.id + ) + team4_2022 = Team( + ownerId=owner4.id, name="User 4", divisionId=division1_2022.id + ) + team5_2022 = Team( + ownerId=owner5.id, name="Team 5", divisionId=division2_2022.id + ) + team6_2022 = Team( + ownerId=owner6.id, name="Team 6", divisionId=division2_2022.id + ) + team7_2022 = Team( + ownerId=owner7.id, name="Team 7", divisionId=division2_2022.id + ) + team8_2022 = Team( + ownerId=owner8.id, name="Team 8", divisionId=division2_2022.id + ) + + team1_2023 = Team( + ownerId=owner1.id, name="User 1", divisionId=division1_2023.id + ) + team2_2023 = Team( + ownerId=owner2.id, name="User 2", divisionId=division1_2023.id + ) + team3_2023 = Team( + ownerId=owner3.id, name="User 3", divisionId=division1_2023.id + ) + team4_2023 = Team( + ownerId=owner4.id, name="User 4", divisionId=division1_2023.id + ) + team5_2023 = Team( + ownerId=owner5.id, name="Team 5", divisionId=division2_2023.id + ) + team6_2023 = Team( + ownerId=owner6.id, name="Team 6", divisionId=division2_2023.id + ) + team7_2023 = Team( + ownerId=owner7.id, name="Team 7", divisionId=division2_2023.id + ) + team8_2023 = Team( + ownerId=owner8.id, name="Team 8", divisionId=division2_2023.id + ) expectedLeague = League( name="Test League 2023", @@ -2636,7 +3153,9 @@ def test_load_league_happyPath_leagueMedianGames( ), ], ) - self.assertTrue(league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True)) + self.assertTrue( + league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True) + ) # check multiWeekMatchupIds for year in league.years: for week in year.weeks: diff --git a/test/test_league_loader/test_YahooLeagueLoader.py b/test/test_league_loader/test_YahooLeagueLoader.py index abf5afb2..c588b1ba 100644 --- a/test/test_league_loader/test_YahooLeagueLoader.py +++ b/test/test_league_loader/test_YahooLeagueLoader.py @@ -28,7 +28,13 @@ def mockWeeksMethod(): return mockWeeksMethod def __getMockYahooTeam( - self, *, teamId: int, teamKey: int, name: str, managerNickname: str, managerId: int + self, + *, + teamId: int, + teamKey: int, + name: str, + managerNickname: str, + managerId: int, ) -> Mock: mockTeam = Mock() mockTeam.team_id = teamId @@ -47,7 +53,7 @@ def __getMockYahooMatchup( isTied: int, isPlayoffs: int, isConsolation: int, - league: Mock + league: Mock, ) -> Mock: # duplicate mockYahooTeam to avoid using the same object in memory dupLeague = copy.deepcopy(league) @@ -61,7 +67,9 @@ def __getMockYahooMatchup( mockYahooMatchup.league = dupLeague return mockYahooMatchup - def __setMockYahooTeamPoints(self, mockYahooTeam: Mock, teamPointsTotal: int | float) -> Mock: + def __setMockYahooTeamPoints( + self, mockYahooTeam: Mock, teamPointsTotal: int | float + ) -> Mock: # duplicate mockYahooTeam to avoid using the same object in memory dupMockYahooTeam = copy.deepcopy(mockYahooTeam) dupMockYahooTeam.team_points.total = teamPointsTotal @@ -78,14 +86,18 @@ def test_loadLeague_nonIntPassingStringForLeagueId(self): clientSecret=badClientSecret, loginTimeoutSeconds=1, ) - self.assertEqual("League ID 'a' could not be turned into an int.", str(context.exception)) + self.assertEqual( + "League ID 'a' could not be turned into an int.", str(context.exception) + ) @mock.patch("multiprocessing.Process") def test_loadLeague_intendedFailure(self, mockMultiprocessingProcess): mockLoginProcess = mockMultiprocessingProcess.return_value mockLoginProcess.is_alive.return_value = True # Simulate login process failure with self.assertRaises(TimeoutError) as context: - yahooLeagueLoader = YahooLeagueLoader("123", [2022], clientId="cid", clientSecret="cs") + yahooLeagueLoader = YahooLeagueLoader( + "123", [2022], clientId="cid", clientSecret="cs" + ) yahooLeagueLoader.loadLeague() self.assertEqual("Login to yahoofantasy timed out.", str(context.exception)) @@ -93,7 +105,10 @@ def test_loadLeague_intendedFailure(self, mockMultiprocessingProcess): @mock.patch("yahoofantasy.Context.__init__") @mock.patch("yahoofantasy.Context.get_leagues") def test_loadLeague_happyPath( - self, mockYahooContextGetLeagues, mockYahooContextInit, mockMultiprocessingProcess + self, + mockYahooContextGetLeagues, + mockYahooContextInit, + mockMultiprocessingProcess, ): # mock real league 2022 mockLeague2022 = Mock() @@ -214,8 +229,12 @@ def test_loadLeague_happyPath( league=mockLeague2022, ) mockYahooMatchup1_1_2022.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam1_2022, teamPointsTotal=100), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam2_2022, teamPointsTotal=100), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam1_2022, teamPointsTotal=100 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam2_2022, teamPointsTotal=100 + ), ] mockYahooMatchup1_2_2022 = self.__getMockYahooMatchup( week=1, @@ -227,8 +246,12 @@ def test_loadLeague_happyPath( league=mockLeague2022, ) mockYahooMatchup1_2_2022.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam3_2022, teamPointsTotal=100.1), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam4_2022, teamPointsTotal=90.1), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam3_2022, teamPointsTotal=100.1 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam4_2022, teamPointsTotal=90.1 + ), ] mockYahooMatchup1_3_2022 = self.__getMockYahooMatchup( week=1, @@ -240,8 +263,12 @@ def test_loadLeague_happyPath( league=mockLeague2022, ) mockYahooMatchup1_3_2022.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam5_2022, teamPointsTotal=100), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam6_2022, teamPointsTotal=90), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam5_2022, teamPointsTotal=100 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam6_2022, teamPointsTotal=90 + ), ] mockYahooMatchup1_4_2022 = self.__getMockYahooMatchup( week=1, @@ -253,8 +280,12 @@ def test_loadLeague_happyPath( league=mockLeague2022, ) mockYahooMatchup1_4_2022.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam7_2022, teamPointsTotal=100), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam8_2022, teamPointsTotal=90), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam7_2022, teamPointsTotal=100 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam8_2022, teamPointsTotal=90 + ), ] # playoffs mockYahooMatchup2_1_2022 = self.__getMockYahooMatchup( @@ -267,8 +298,12 @@ def test_loadLeague_happyPath( league=mockLeague2022, ) mockYahooMatchup2_1_2022.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam2_2022, teamPointsTotal=101), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam3_2022, teamPointsTotal=91), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam2_2022, teamPointsTotal=101 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam3_2022, teamPointsTotal=91 + ), ] # championship mockYahooMatchup3_1_2022 = self.__getMockYahooMatchup( @@ -281,8 +316,12 @@ def test_loadLeague_happyPath( league=mockLeague2022, ) mockYahooMatchup3_1_2022.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam1_2022, teamPointsTotal=102), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam2_2022, teamPointsTotal=92), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam1_2022, teamPointsTotal=102 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam2_2022, teamPointsTotal=92 + ), ] # mock matchups 2023 @@ -297,8 +336,12 @@ def test_loadLeague_happyPath( league=mockLeague2023, ) mockYahooMatchup1_1_2023.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam1_2023, teamPointsTotal=100), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam2_2023, teamPointsTotal=100), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam1_2023, teamPointsTotal=100 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam2_2023, teamPointsTotal=100 + ), ] mockYahooMatchup1_2_2023 = self.__getMockYahooMatchup( week=1, @@ -310,8 +353,12 @@ def test_loadLeague_happyPath( league=mockLeague2023, ) mockYahooMatchup1_2_2023.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam3_2023, teamPointsTotal=100.1), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam4_2023, teamPointsTotal=90.1), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam3_2023, teamPointsTotal=100.1 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam4_2023, teamPointsTotal=90.1 + ), ] mockYahooMatchup1_3_2023 = self.__getMockYahooMatchup( week=1, @@ -323,8 +370,12 @@ def test_loadLeague_happyPath( league=mockLeague2023, ) mockYahooMatchup1_3_2023.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam5_2023, teamPointsTotal=100), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam6_2023, teamPointsTotal=90), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam5_2023, teamPointsTotal=100 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam6_2023, teamPointsTotal=90 + ), ] mockYahooMatchup1_4_2023 = self.__getMockYahooMatchup( week=1, @@ -336,8 +387,12 @@ def test_loadLeague_happyPath( league=mockLeague2023, ) mockYahooMatchup1_4_2023.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam7_2023, teamPointsTotal=100), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam8_2023, teamPointsTotal=90), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam7_2023, teamPointsTotal=100 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam8_2023, teamPointsTotal=90 + ), ] # playoffs mockYahooMatchup2_1_2023 = self.__getMockYahooMatchup( @@ -350,8 +405,12 @@ def test_loadLeague_happyPath( league=mockLeague2023, ) mockYahooMatchup2_1_2023.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam2_2023, teamPointsTotal=101), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam3_2023, teamPointsTotal=91), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam2_2023, teamPointsTotal=101 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam3_2023, teamPointsTotal=91 + ), ] # championship mockYahooMatchup3_1_2023 = self.__getMockYahooMatchup( @@ -364,8 +423,12 @@ def test_loadLeague_happyPath( league=mockLeague2023, ) mockYahooMatchup3_1_2023.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam1_2023, teamPointsTotal=102), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam2_2023, teamPointsTotal=92), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam1_2023, teamPointsTotal=102 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam2_2023, teamPointsTotal=92 + ), ] # mock weeks 2022 @@ -412,7 +475,9 @@ def test_loadLeague_happyPath( [mockLeague2022_fake1, mockLeague2022, mockLeague2022_fake2], ] mockLoginProcess = mockMultiprocessingProcess.return_value - mockLoginProcess.is_alive.return_value = False # Simulate login process completion + mockLoginProcess.is_alive.return_value = ( + False # Simulate login process completion + ) # load league yahooLeagueLoader = YahooLeagueLoader( @@ -630,7 +695,9 @@ def test_loadLeague_happyPath( target=yahooLeagueLoader.login, args=("cid", "cs") ) - self.assertTrue(league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True)) + self.assertTrue( + league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True) + ) # check multiWeekMatchupIds for year in league.years: for week in year.weeks: @@ -641,7 +708,10 @@ def test_loadLeague_happyPath( @mock.patch("yahoofantasy.Context.__init__") @mock.patch("yahoofantasy.Context.get_leagues") def test_loadLeague_withOwnerNamesAndAliases( - self, mockYahooContextGetLeagues, mockYahooContextInit, mockMultiprocessingProcess + self, + mockYahooContextGetLeagues, + mockYahooContextInit, + mockMultiprocessingProcess, ): # mock real league 2022 mockLeague2022 = Mock() @@ -762,8 +832,12 @@ def test_loadLeague_withOwnerNamesAndAliases( league=mockLeague2022, ) mockYahooMatchup1_1_2022.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam1_2022, teamPointsTotal=100), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam2_2022, teamPointsTotal=100), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam1_2022, teamPointsTotal=100 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam2_2022, teamPointsTotal=100 + ), ] mockYahooMatchup1_2_2022 = self.__getMockYahooMatchup( week=1, @@ -775,8 +849,12 @@ def test_loadLeague_withOwnerNamesAndAliases( league=mockLeague2022, ) mockYahooMatchup1_2_2022.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam3_2022, teamPointsTotal=100.1), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam4_2022, teamPointsTotal=90.1), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam3_2022, teamPointsTotal=100.1 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam4_2022, teamPointsTotal=90.1 + ), ] mockYahooMatchup1_3_2022 = self.__getMockYahooMatchup( week=1, @@ -788,8 +866,12 @@ def test_loadLeague_withOwnerNamesAndAliases( league=mockLeague2022, ) mockYahooMatchup1_3_2022.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam5_2022, teamPointsTotal=100), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam6_2022, teamPointsTotal=90), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam5_2022, teamPointsTotal=100 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam6_2022, teamPointsTotal=90 + ), ] mockYahooMatchup1_4_2022 = self.__getMockYahooMatchup( week=1, @@ -801,8 +883,12 @@ def test_loadLeague_withOwnerNamesAndAliases( league=mockLeague2022, ) mockYahooMatchup1_4_2022.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam7_2022, teamPointsTotal=100), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam8_2022, teamPointsTotal=90), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam7_2022, teamPointsTotal=100 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam8_2022, teamPointsTotal=90 + ), ] # playoffs mockYahooMatchup2_1_2022 = self.__getMockYahooMatchup( @@ -815,8 +901,12 @@ def test_loadLeague_withOwnerNamesAndAliases( league=mockLeague2022, ) mockYahooMatchup2_1_2022.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam2_2022, teamPointsTotal=101), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam3_2022, teamPointsTotal=91), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam2_2022, teamPointsTotal=101 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam3_2022, teamPointsTotal=91 + ), ] # championship mockYahooMatchup3_1_2022 = self.__getMockYahooMatchup( @@ -829,8 +919,12 @@ def test_loadLeague_withOwnerNamesAndAliases( league=mockLeague2022, ) mockYahooMatchup3_1_2022.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam1_2022, teamPointsTotal=102), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam2_2022, teamPointsTotal=92), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam1_2022, teamPointsTotal=102 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam2_2022, teamPointsTotal=92 + ), ] # mock matchups 2023 @@ -845,8 +939,12 @@ def test_loadLeague_withOwnerNamesAndAliases( league=mockLeague2023, ) mockYahooMatchup1_1_2023.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam1_2023, teamPointsTotal=100), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam2_2023, teamPointsTotal=100), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam1_2023, teamPointsTotal=100 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam2_2023, teamPointsTotal=100 + ), ] mockYahooMatchup1_2_2023 = self.__getMockYahooMatchup( week=1, @@ -858,8 +956,12 @@ def test_loadLeague_withOwnerNamesAndAliases( league=mockLeague2023, ) mockYahooMatchup1_2_2023.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam3_2023, teamPointsTotal=100.1), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam4_2023, teamPointsTotal=90.1), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam3_2023, teamPointsTotal=100.1 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam4_2023, teamPointsTotal=90.1 + ), ] mockYahooMatchup1_3_2023 = self.__getMockYahooMatchup( week=1, @@ -871,8 +973,12 @@ def test_loadLeague_withOwnerNamesAndAliases( league=mockLeague2023, ) mockYahooMatchup1_3_2023.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam5_2023, teamPointsTotal=100), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam6_2023, teamPointsTotal=90), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam5_2023, teamPointsTotal=100 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam6_2023, teamPointsTotal=90 + ), ] mockYahooMatchup1_4_2023 = self.__getMockYahooMatchup( week=1, @@ -884,8 +990,12 @@ def test_loadLeague_withOwnerNamesAndAliases( league=mockLeague2023, ) mockYahooMatchup1_4_2023.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam7_2023, teamPointsTotal=100), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam8_2023, teamPointsTotal=90), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam7_2023, teamPointsTotal=100 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam8_2023, teamPointsTotal=90 + ), ] # playoffs mockYahooMatchup2_1_2023 = self.__getMockYahooMatchup( @@ -898,8 +1008,12 @@ def test_loadLeague_withOwnerNamesAndAliases( league=mockLeague2023, ) mockYahooMatchup2_1_2023.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam2_2023, teamPointsTotal=101), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam3_2023, teamPointsTotal=91), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam2_2023, teamPointsTotal=101 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam3_2023, teamPointsTotal=91 + ), ] # championship mockYahooMatchup3_1_2023 = self.__getMockYahooMatchup( @@ -912,8 +1026,12 @@ def test_loadLeague_withOwnerNamesAndAliases( league=mockLeague2023, ) mockYahooMatchup3_1_2023.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam1_2023, teamPointsTotal=102), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam2_2023, teamPointsTotal=92), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam1_2023, teamPointsTotal=102 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam2_2023, teamPointsTotal=92 + ), ] # mock weeks 2022 @@ -960,7 +1078,9 @@ def test_loadLeague_withOwnerNamesAndAliases( [mockLeague2022_fake1, mockLeague2022, mockLeague2022_fake2], ] mockLoginProcess = mockMultiprocessingProcess.return_value - mockLoginProcess.is_alive.return_value = False # Simulate login process completion + mockLoginProcess.is_alive.return_value = ( + False # Simulate login process completion + ) # load league yahooLeagueLoader = YahooLeagueLoader( @@ -1191,7 +1311,9 @@ def test_loadLeague_withOwnerNamesAndAliases( target=yahooLeagueLoader.login, args=("cid", "cs") ) - self.assertTrue(league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True)) + self.assertTrue( + league.equals(expectedLeague, ignoreBaseIds=True, ignoreIds=True) + ) # check multiWeekMatchupIds for year in league.years: for week in year.weeks: @@ -1202,7 +1324,10 @@ def test_loadLeague_withOwnerNamesAndAliases( @mock.patch("yahoofantasy.Context.__init__") @mock.patch("yahoofantasy.Context.get_leagues") def test_loadLeague_happyPath( - self, mockYahooContextGetLeagues, mockYahooContextInit, mockMultiprocessingProcess + self, + mockYahooContextGetLeagues, + mockYahooContextInit, + mockMultiprocessingProcess, ): # mock real league 2022 mockLeague2022 = Mock() @@ -1323,8 +1448,12 @@ def test_loadLeague_happyPath( league=mockLeague2022, ) mockYahooMatchup1_1_2022.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam1_2022, teamPointsTotal=100), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam2_2022, teamPointsTotal=100), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam1_2022, teamPointsTotal=100 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam2_2022, teamPointsTotal=100 + ), ] mockYahooMatchup1_2_2022 = self.__getMockYahooMatchup( week=1, @@ -1336,8 +1465,12 @@ def test_loadLeague_happyPath( league=mockLeague2022, ) mockYahooMatchup1_2_2022.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam3_2022, teamPointsTotal=100.1), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam4_2022, teamPointsTotal=90.1), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam3_2022, teamPointsTotal=100.1 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam4_2022, teamPointsTotal=90.1 + ), ] mockYahooMatchup1_3_2022 = self.__getMockYahooMatchup( week=1, @@ -1349,8 +1482,12 @@ def test_loadLeague_happyPath( league=mockLeague2022, ) mockYahooMatchup1_3_2022.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam5_2022, teamPointsTotal=100), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam6_2022, teamPointsTotal=90), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam5_2022, teamPointsTotal=100 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam6_2022, teamPointsTotal=90 + ), ] mockYahooMatchup1_4_2022 = self.__getMockYahooMatchup( week=1, @@ -1362,8 +1499,12 @@ def test_loadLeague_happyPath( league=mockLeague2022, ) mockYahooMatchup1_4_2022.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam7_2022, teamPointsTotal=100), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam8_2022, teamPointsTotal=90), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam7_2022, teamPointsTotal=100 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam8_2022, teamPointsTotal=90 + ), ] # playoffs mockYahooMatchup2_1_2022 = self.__getMockYahooMatchup( @@ -1376,8 +1517,12 @@ def test_loadLeague_happyPath( league=mockLeague2022, ) mockYahooMatchup2_1_2022.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam2_2022, teamPointsTotal=101), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam3_2022, teamPointsTotal=91), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam2_2022, teamPointsTotal=101 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam3_2022, teamPointsTotal=91 + ), ] # championship mockYahooMatchup3_1_2022 = self.__getMockYahooMatchup( @@ -1390,8 +1535,12 @@ def test_loadLeague_happyPath( league=mockLeague2022, ) mockYahooMatchup3_1_2022.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam1_2022, teamPointsTotal=102), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam2_2022, teamPointsTotal=92), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam1_2022, teamPointsTotal=102 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam2_2022, teamPointsTotal=92 + ), ] # mock matchups 2023 @@ -1406,8 +1555,12 @@ def test_loadLeague_happyPath( league=mockLeague2023, ) mockYahooMatchup1_1_2023.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam1_2023, teamPointsTotal=100), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam2_2023, teamPointsTotal=100), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam1_2023, teamPointsTotal=100 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam2_2023, teamPointsTotal=100 + ), ] mockYahooMatchup1_2_2023 = self.__getMockYahooMatchup( week=1, @@ -1419,8 +1572,12 @@ def test_loadLeague_happyPath( league=mockLeague2023, ) mockYahooMatchup1_2_2023.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam3_2023, teamPointsTotal=100.1), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam4_2023, teamPointsTotal=90.1), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam3_2023, teamPointsTotal=100.1 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam4_2023, teamPointsTotal=90.1 + ), ] mockYahooMatchup1_3_2023 = self.__getMockYahooMatchup( week=1, @@ -1432,8 +1589,12 @@ def test_loadLeague_happyPath( league=mockLeague2023, ) mockYahooMatchup1_3_2023.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam5_2023, teamPointsTotal=100), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam6_2023, teamPointsTotal=90), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam5_2023, teamPointsTotal=100 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam6_2023, teamPointsTotal=90 + ), ] mockYahooMatchup1_4_2023 = self.__getMockYahooMatchup( week=1, @@ -1445,8 +1606,12 @@ def test_loadLeague_happyPath( league=mockLeague2023, ) mockYahooMatchup1_4_2023.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam7_2023, teamPointsTotal=100), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam8_2023, teamPointsTotal=90), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam7_2023, teamPointsTotal=100 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam8_2023, teamPointsTotal=90 + ), ] # playoffs mockYahooMatchup2_1_2023 = self.__getMockYahooMatchup( @@ -1459,8 +1624,12 @@ def test_loadLeague_happyPath( league=mockLeague2023, ) mockYahooMatchup2_1_2023.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam2_2023, teamPointsTotal=101), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam3_2023, teamPointsTotal=91), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam2_2023, teamPointsTotal=101 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam3_2023, teamPointsTotal=91 + ), ] # championship mockYahooMatchup3_1_2023 = self.__getMockYahooMatchup( @@ -1473,8 +1642,12 @@ def test_loadLeague_happyPath( league=mockLeague2023, ) mockYahooMatchup3_1_2023.teams.team = [ - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam1_2023, teamPointsTotal=102), - self.__setMockYahooTeamPoints(mockYahooTeam=mockYahooTeam2_2023, teamPointsTotal=92), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam1_2023, teamPointsTotal=102 + ), + self.__setMockYahooTeamPoints( + mockYahooTeam=mockYahooTeam2_2023, teamPointsTotal=92 + ), ] # mock weeks 2022 @@ -1521,11 +1694,17 @@ def test_loadLeague_happyPath( [mockLeague2022_fake1, mockLeague2022, mockLeague2022_fake2], ] mockLoginProcess = mockMultiprocessingProcess.return_value - mockLoginProcess.is_alive.return_value = False # Simulate login process completion + mockLoginProcess.is_alive.return_value = ( + False # Simulate login process completion + ) # load league yahooLeagueLoader = YahooLeagueLoader( - "456", [2022, 2023], clientId="cid", clientSecret="cs", leagueName="custom name" + "456", + [2022, 2023], + clientId="cid", + clientSecret="cs", + leagueName="custom name", ) league = yahooLeagueLoader.loadLeague() diff --git a/test/test_model/test_filter/test_AllTimeFilters.py b/test/test_model/test_filter/test_AllTimeFilters.py index 247e8db6..91078969 100644 --- a/test/test_model/test_filter/test_AllTimeFilters.py +++ b/test/test_model/test_filter/test_AllTimeFilters.py @@ -46,7 +46,8 @@ def test_includeMatchupTypes_onlyPostSeasonIsTrue(self): ) self.assertEqual( - [MatchupType.PLAYOFF, MatchupType.CHAMPIONSHIP], allTimeFilters.includeMatchupTypes + [MatchupType.PLAYOFF, MatchupType.CHAMPIONSHIP], + allTimeFilters.includeMatchupTypes, ) def test_includeMatchupTypes_onlyRegularSeasonIsTrue(self): @@ -60,4 +61,6 @@ def test_includeMatchupTypes_onlyRegularSeasonIsTrue(self): onlyRegularSeason=True, ) - self.assertEqual([MatchupType.REGULAR_SEASON], allTimeFilters.includeMatchupTypes) + self.assertEqual( + [MatchupType.REGULAR_SEASON], allTimeFilters.includeMatchupTypes + ) diff --git a/test/test_model/test_league/test_League.py b/test/test_model/test_league/test_League.py index f846e456..19cd0246 100644 --- a/test/test_model/test_league/test_League.py +++ b/test/test_model/test_league/test_League.py @@ -1,6 +1,5 @@ import copy import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams from leeger.enum.MatchupType import MatchupType from leeger.exception import DoesNotExistException @@ -11,6 +10,7 @@ from leeger.model.league.Owner import Owner from leeger.model.league.Week import Week from leeger.model.league.Year import Year +from test.helper.prototypes import getNDefaultOwnersAndTeams class TestLeague(unittest.TestCase): @@ -138,7 +138,8 @@ def test_league_add_happyPath(self): self.assertEqual("'LEAGUE 1' + 'LEAGUE 2' League", combinedLeague.name) self.assertEqual(2, len(combinedLeague.owners)) self.assertEqual( - [owner.name for owner in league_1.owners], [owner.name for owner in league_1.owners] + [owner.name for owner in league_1.owners], + [owner.name for owner in league_1.owners], ) self.assertEqual(2, len(combinedLeague.years)) self.assertEqual(2000, combinedLeague.years[0].yearNumber) @@ -176,8 +177,12 @@ def test_league_add_originalLeaguesAreTheSameAfterAdding(self): league_2_copy = copy.deepcopy(league_2) league_1 + league_2 - self.assertTrue(league_1.equals(league_1_copy, ignoreBaseIds=True, ignoreIds=True)) - self.assertTrue(league_2.equals(league_2_copy, ignoreBaseIds=True, ignoreIds=True)) + self.assertTrue( + league_1.equals(league_1_copy, ignoreBaseIds=True, ignoreIds=True) + ) + self.assertTrue( + league_2.equals(league_2_copy, ignoreBaseIds=True, ignoreIds=True) + ) def test_league_add_teamsWithSameOwnersHaveSameOwnerIdAcrossYears(self): # create League 1 @@ -249,7 +254,9 @@ def test_league_add_addingOrderDoesNotMatter(self): combinedLeague2 = league_2 + league_1 self.assertIsInstance(combinedLeague1, League) self.assertIsInstance(combinedLeague2, League) - self.assertTrue(combinedLeague1.equals(combinedLeague2, ignoreBaseIds=True, ignoreIds=True)) + self.assertTrue( + combinedLeague1.equals(combinedLeague2, ignoreBaseIds=True, ignoreIds=True) + ) def test_league_add_sameLeagueName_nameIsntChanged(self): # create League 1 @@ -284,7 +291,9 @@ def test_league_add_sameLeagueName_nameIsntChanged(self): self.assertIsInstance(combinedLeague, League) self.assertEqual("LEAGUE", combinedLeague.name) - def test_league_add_leaguesHaveOwnersThatDontHaveMatchingNames_ownersAreCombined(self): + def test_league_add_leaguesHaveOwnersThatDontHaveMatchingNames_ownersAreCombined( + self, + ): # create League 1 owners_1, teams_1 = getNDefaultOwnersAndTeams(2) owners_1[0].name = "league 1 owner 1" @@ -426,7 +435,8 @@ def test_league_add_duplicateYearsAcrossCombinedLeagues_raisesException(self): with self.assertRaises(InvalidLeagueFormatException) as context: league_1 + league_2 self.assertEqual( - "Can only have 1 of each year number within a league.", str(context.exception) + "Can only have 1 of each year number within a league.", + str(context.exception), ) def test_league_toJson(self): @@ -457,15 +467,28 @@ def test_league_toJson(self): self.assertEqual(1, len(leagueJson["years"][0]["weeks"])) self.assertEqual(1, leagueJson["years"][0]["weeks"][0]["weekNumber"]) self.assertEqual(1, len(leagueJson["years"][0]["weeks"][0]["matchups"])) - self.assertEqual(teams[0].id, leagueJson["years"][0]["weeks"][0]["matchups"][0]["teamAId"]) - self.assertEqual(teams[1].id, leagueJson["years"][0]["weeks"][0]["matchups"][0]["teamBId"]) - self.assertEqual(1.1, leagueJson["years"][0]["weeks"][0]["matchups"][0]["teamAScore"]) - self.assertEqual(2.2, leagueJson["years"][0]["weeks"][0]["matchups"][0]["teamBScore"]) self.assertEqual( - "REGULAR_SEASON", leagueJson["years"][0]["weeks"][0]["matchups"][0]["matchupType"] + teams[0].id, leagueJson["years"][0]["weeks"][0]["matchups"][0]["teamAId"] + ) + self.assertEqual( + teams[1].id, leagueJson["years"][0]["weeks"][0]["matchups"][0]["teamBId"] + ) + self.assertEqual( + 1.1, leagueJson["years"][0]["weeks"][0]["matchups"][0]["teamAScore"] + ) + self.assertEqual( + 2.2, leagueJson["years"][0]["weeks"][0]["matchups"][0]["teamBScore"] + ) + self.assertEqual( + "REGULAR_SEASON", + leagueJson["years"][0]["weeks"][0]["matchups"][0]["matchupType"], + ) + self.assertFalse( + leagueJson["years"][0]["weeks"][0]["matchups"][0]["teamAHasTiebreaker"] + ) + self.assertFalse( + leagueJson["years"][0]["weeks"][0]["matchups"][0]["teamBHasTiebreaker"] ) - self.assertFalse(leagueJson["years"][0]["weeks"][0]["matchups"][0]["teamAHasTiebreaker"]) - self.assertFalse(leagueJson["years"][0]["weeks"][0]["matchups"][0]["teamBHasTiebreaker"]) def test_getYearByYearNumber_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) @@ -538,7 +561,9 @@ def test_getOwnerByName_ownerNotInLeague_raisesException(self): with self.assertRaises(DoesNotExistException) as context: league.getOwnerByName("owner0") - self.assertEqual("League does not have an owner with name 'owner0'", str(context.exception)) + self.assertEqual( + "League does not have an owner with name 'owner0'", str(context.exception) + ) def test_league_fromJson(self): owners, teams = getNDefaultOwnersAndTeams(2) diff --git a/test/test_model/test_league/test_Matchup.py b/test/test_model/test_league/test_Matchup.py index 54d4ac80..7989e024 100644 --- a/test/test_model/test_league/test_Matchup.py +++ b/test/test_model/test_league/test_Matchup.py @@ -1,11 +1,11 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams from leeger.enum.MatchupType import MatchupType from leeger.exception import DoesNotExistException from leeger.exception.InvalidMatchupFormatException import InvalidMatchupFormatException from leeger.model.league.Matchup import Matchup from leeger.model.league_helper.Performance import Performance +from test.helper.prototypes import getNDefaultOwnersAndTeams class TestMatchup(unittest.TestCase): @@ -31,7 +31,9 @@ def test_matchup_init(self): self.assertEqual("id", matchup.multiWeekMatchupId) def test_matchup_init_defaultValues_1(self): - matchup = Matchup(teamAId="teamAId", teamBId="teamBId", teamAScore=1.1, teamBScore=2.2) + matchup = Matchup( + teamAId="teamAId", teamBId="teamBId", teamAScore=1.1, teamBScore=2.2 + ) self.assertEqual("teamAId", matchup.teamAId) self.assertEqual("teamBId", matchup.teamBId) @@ -232,7 +234,9 @@ def test_getPerformanceForTeamId_teamIdNotInMatchup_raisesException(self): with self.assertRaises(DoesNotExistException) as context: matchup.getPerformanceForTeamId("3") - self.assertEqual("Matchup does not have a team with ID '3'.", str(context.exception)) + self.assertEqual( + "Matchup does not have a team with ID '3'.", str(context.exception) + ) def test_matchup_fromJson(self): owners, teams = getNDefaultOwnersAndTeams(2) diff --git a/test/test_model/test_league/test_Week.py b/test/test_model/test_league/test_Week.py index ccedcdfe..5fe56ee4 100644 --- a/test/test_model/test_league/test_Week.py +++ b/test/test_model/test_league/test_Week.py @@ -1,20 +1,28 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams from leeger.enum.MatchupType import MatchupType from leeger.exception import DoesNotExistException from leeger.model.league.Matchup import Matchup from leeger.model.league.Week import Week +from test.helper.prototypes import getNDefaultOwnersAndTeams class TestWeek(unittest.TestCase): def test_week_init(self): matchup1 = Matchup(teamAId="", teamBId="", teamAScore=0, teamBScore=0) matchup2 = Matchup( - teamAId="", teamBId="", teamAScore=0, teamBScore=0, matchupType=MatchupType.PLAYOFF + teamAId="", + teamBId="", + teamAScore=0, + teamBScore=0, + matchupType=MatchupType.PLAYOFF, ) matchup3 = Matchup( - teamAId="", teamBId="", teamAScore=0, teamBScore=0, matchupType=MatchupType.CHAMPIONSHIP + teamAId="", + teamBId="", + teamAScore=0, + teamBScore=0, + matchupType=MatchupType.CHAMPIONSHIP, ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -89,7 +97,9 @@ def test_isChampionshipWeek_weekHasAChampionshipMatchup_returnsTrue(self): self.assertIsInstance(response2, bool) self.assertTrue(response2) - def test_isChampionshipWeek_weekDoesNotHaveAnyChampionshipMatchups_returnsFalse(self): + def test_isChampionshipWeek_weekDoesNotHaveAnyChampionshipMatchups_returnsFalse( + self, + ): _, teams = getNDefaultOwnersAndTeams(2) matchup1 = Matchup( @@ -293,7 +303,8 @@ def test_getMatchupWithTeamId_teamIdNotInMatchups_raisesException(self): with self.assertRaises(DoesNotExistException) as context: week.getMatchupWithTeamId("bad ID") self.assertEqual( - "Week does not have a matchup with team ID 'bad ID'.", str(context.exception) + "Week does not have a matchup with team ID 'bad ID'.", + str(context.exception), ) def test_week_fromJson(self): diff --git a/test/test_model/test_league/test_Year.py b/test/test_model/test_league/test_Year.py index f02071ba..be5c9b19 100644 --- a/test/test_model/test_league/test_Year.py +++ b/test/test_model/test_league/test_Year.py @@ -1,5 +1,4 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams from leeger.enum.MatchupType import MatchupType from leeger.exception import DoesNotExistException @@ -9,6 +8,7 @@ from leeger.model.league.Team import Team from leeger.model.league.Week import Week from leeger.model.league.Year import Year +from test.helper.prototypes import getNDefaultOwnersAndTeams class TestYear(unittest.TestCase): @@ -229,7 +229,9 @@ def test_getTeamByName_teamNotInYear_raisesException(self): with self.assertRaises(DoesNotExistException) as context: year.getTeamByName("team0") - self.assertEqual("Year does not have a team with name 'team0'.", str(context.exception)) + self.assertEqual( + "Year does not have a team with name 'team0'.", str(context.exception) + ) def test_getWeekByWeekNumber_happyPath(self): _, teams = getNDefaultOwnersAndTeams(2) @@ -262,4 +264,6 @@ def test_getWeekByWeekNumber_teamNotInYear_raisesException(self): with self.assertRaises(DoesNotExistException) as context: year.getWeekByWeekNumber(2) - self.assertEqual("Year does not have a week with week number 2.", str(context.exception)) + self.assertEqual( + "Year does not have a week with week number 2.", str(context.exception) + ) diff --git a/test/test_model/test_league_helper/test_Performance.py b/test/test_model/test_league_helper/test_Performance.py index 806268a0..74d764c4 100644 --- a/test/test_model/test_league_helper/test_Performance.py +++ b/test/test_model/test_league_helper/test_Performance.py @@ -1,10 +1,10 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams from leeger.enum.MatchupType import MatchupType from leeger.exception import InvalidMatchupFormatException from leeger.model.league import Matchup from leeger.model.league_helper.Performance import Performance +from test.helper.prototypes import getNDefaultOwnersAndTeams class TestPerformance(unittest.TestCase): @@ -135,7 +135,9 @@ def test_performance_add_happyPath(self): self.assertFalse(response.teamBHasTiebreaker) self.assertEqual("id", response.multiWeekMatchupId) - def test_performance_add_performancesHaveDifferentMatchupTypes_raisesException(self): + def test_performance_add_performancesHaveDifferentMatchupTypes_raisesException( + self, + ): performance_1 = Performance( teamId="team1Id", teamScore=1.1, @@ -159,7 +161,9 @@ def test_performance_add_performancesHaveDifferentMatchupTypes_raisesException(s str(context.exception), ) - def test_performance_add_performancesHaveDifferentMultiWeekMatchupIds_raisesException(self): + def test_performance_add_performancesHaveDifferentMultiWeekMatchupIds_raisesException( + self, + ): performance_1 = Performance( teamId="team1Id", teamScore=1.1, diff --git a/test/test_util/test_GeneralUtil.py b/test/test_util/test_GeneralUtil.py index da9e18a2..88645947 100644 --- a/test/test_util/test_GeneralUtil.py +++ b/test/test_util/test_GeneralUtil.py @@ -19,22 +19,30 @@ def test_warnForUnusedKwargs_happyPath(self): with self.assertLogs() as captured: GeneralUtil.warnForUnusedKwargs(kwargs) self.assertEqual(2, len(captured.records)) - self.assertEqual("Keyword argument 'a' unused.", captured.records[0].getMessage()) - self.assertEqual("Keyword argument 'b' unused.", captured.records[1].getMessage()) + self.assertEqual( + "Keyword argument 'a' unused.", captured.records[0].getMessage() + ) + self.assertEqual( + "Keyword argument 'b' unused.", captured.records[1].getMessage() + ) # with default exclude keys kwargs = {"b": 1, "validate": 2} with self.assertLogs() as captured: GeneralUtil.warnForUnusedKwargs(kwargs) self.assertEqual(1, len(captured.records)) - self.assertEqual("Keyword argument 'b' unused.", captured.records[0].getMessage()) + self.assertEqual( + "Keyword argument 'b' unused.", captured.records[0].getMessage() + ) # with exclude keys kwargs = {"a": 1, "b": 2} with self.assertLogs() as captured: GeneralUtil.warnForUnusedKwargs(kwargs, excludeKeys=["a"]) self.assertEqual(1, len(captured.records)) - self.assertEqual("Keyword argument 'b' unused.", captured.records[0].getMessage()) + self.assertEqual( + "Keyword argument 'b' unused.", captured.records[0].getMessage() + ) def test_safeSum_happyPath(self): response = GeneralUtil.safeSum(None, 1, 1) @@ -79,7 +87,9 @@ def test_findDifferentFields_noDifference_simpleDict(self): # with ignore key names (all keys) d1 = {"foo": "baz", "bar": "bot"} d2 = {"foo": "baz", "bar": "bot"} - response = GeneralUtil.findDifferentFields(d1, d2, ignoreKeyNames=["foo", "bar"]) + response = GeneralUtil.findDifferentFields( + d1, d2, ignoreKeyNames=["foo", "bar"] + ) self.assertEqual(list(), response) # with parent key given @@ -107,7 +117,8 @@ def test_findDifferentFields_someDifference_simpleDict(self): d2 = {"foo": ["ba", "ba", "bo", "bo"]} response = GeneralUtil.findDifferentFields(d1, d2) self.assertEqual( - [("foo", (["baz", "bar", "bot", "boy"], ["ba", "ba", "bo", "bo"]))], response + [("foo", (["baz", "bar", "bot", "boy"], ["ba", "ba", "bo", "bo"]))], + response, ) # lists have unequal length, shows key as difference @@ -128,7 +139,8 @@ def test_findDifferentFields_someDifference_simpleDict(self): d2 = {"foo": ("ba", "ba", "bo", "bo")} response = GeneralUtil.findDifferentFields(d1, d2) self.assertEqual( - [("foo", (("baz", "bar", "bot", "boy"), ("ba", "ba", "bo", "bo")))], response + [("foo", (("baz", "bar", "bot", "boy"), ("ba", "ba", "bo", "bo")))], + response, ) # tuples have unequal length, shows key as difference @@ -152,7 +164,9 @@ def test_findDifferentFields_someDifference_simpleDict(self): # difference with ignore key names (all difference keys) d1 = {"foo": "baz", "bar": "bot"} d2 = {"foo": "ba", "bar": "bo"} - response = GeneralUtil.findDifferentFields(d1, d2, ignoreKeyNames=["foo", "bar"]) + response = GeneralUtil.findDifferentFields( + d1, d2, ignoreKeyNames=["foo", "bar"] + ) self.assertEqual(list(), response) # with parent key given @@ -166,7 +180,9 @@ def test_findDifferentFields_nestedDict(self): d1 = {"foo": {"baz": "bar"}, "bot": {"boo": "boy"}} d2 = {"foo": {"baz": "ba"}, "bot": {"boo": "bo"}} response = GeneralUtil.findDifferentFields(d1, d2) - self.assertEqual([("foo.baz", ("bar", "ba")), ("bot.boo", ("boy", "bo"))], response) + self.assertEqual( + [("foo.baz", ("bar", "ba")), ("bot.boo", ("boy", "bo"))], response + ) # with list nested # same list length, single index difference @@ -185,7 +201,9 @@ def test_findDifferentFields_nestedDict(self): d1 = {"foo": {"bar": ["bot", "boy", "boz"]}} d2 = {"foo": {"bar": ["bo", "bo", "boz"]}} response = GeneralUtil.findDifferentFields(d1, d2) - self.assertEqual([("foo.bar[0]", ("bot", "bo")), ("foo.bar[1]", ("boy", "bo"))], response) + self.assertEqual( + [("foo.bar[0]", ("bot", "bo")), ("foo.bar[1]", ("boy", "bo"))], response + ) # different list length d1 = {"foo": {"bar": ["bot", "boy"]}} @@ -209,4 +227,6 @@ def test_findDifferentFields_nestedDict(self): d1 = {"foo": {"baz": "bar"}, "bot": {"boo": "boy"}} d2 = {"foo": {"baz": "ba"}, "bot": {"boo": "bo"}} response = GeneralUtil.findDifferentFields(d1, d2, parentKey="abc") - self.assertEqual([("abc.foo.baz", ("bar", "ba")), ("abc.bot.boo", ("boy", "bo"))], response) + self.assertEqual( + [("abc.foo.baz", ("bar", "ba")), ("abc.bot.boo", ("boy", "bo"))], response + ) diff --git a/test/test_util/test_equality.py b/test/test_util/test_equality.py index 21b415b3..cfb2cbe5 100644 --- a/test/test_util/test_equality.py +++ b/test/test_util/test_equality.py @@ -139,7 +139,9 @@ def test_equals(self, mockGetLogger): ) self.assertFalse(result) - mockLogger.info.assert_called_once_with("Differences: [('Foo.field1', ('a', 'b'))]") + mockLogger.info.assert_called_once_with( + "Differences: [('Foo.field1', ('a', 'b'))]" + ) mockLogger.reset_mock() # basic unequal object logging differences with json method name diff --git a/test/test_util/test_excel.py b/test/test_util/test_excel.py index ec4fb0ec..e7b73f75 100644 --- a/test/test_util/test_excel.py +++ b/test/test_util/test_excel.py @@ -2,7 +2,6 @@ import tempfile import unittest from decimal import Decimal -from test.helper.prototypes import getNDefaultOwnersAndTeams from openpyxl import load_workbook from openpyxl.utils import get_column_letter @@ -14,6 +13,7 @@ from leeger.model.league.Week import Week from leeger.model.league.Year import Year from leeger.util.excel import leagueToExcel +from test.helper.prototypes import getNDefaultOwnersAndTeams class TestExcel(unittest.TestCase): @@ -25,17 +25,34 @@ def test_leagueToExcel_filePathGiven_happyPath(self): teams1[1].name = "b" teams1[0].divisionId = division1.id teams1[1].divisionId = division2.id - matchup1 = Matchup(teamAId=teams1[0].id, teamBId=teams1[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams1[0].id, teamBId=teams1[1].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) - year1 = Year(yearNumber=2000, teams=teams1, weeks=[week1], divisions=[division1, division2]) + year1 = Year( + yearNumber=2000, + teams=teams1, + weeks=[week1], + divisions=[division1, division2], + ) - teams2 = [Team(ownerId=owners[0].id, name="a2"), Team(ownerId=owners[1].id, name="b2")] - matchup2 = Matchup(teamAId=teams2[0].id, teamBId=teams2[1].id, teamAScore=1, teamBScore=2) + teams2 = [ + Team(ownerId=owners[0].id, name="a2"), + Team(ownerId=owners[1].id, name="b2"), + ] + matchup2 = Matchup( + teamAId=teams2[0].id, teamBId=teams2[1].id, teamAScore=1, teamBScore=2 + ) week2 = Week(weekNumber=1, matchups=[matchup2]) year2 = Year(yearNumber=2001, teams=teams2, weeks=[week2]) - teams3 = [Team(ownerId=owners[0].id, name="a3"), Team(ownerId=owners[1].id, name="b3")] - matchup3 = Matchup(teamAId=teams3[0].id, teamBId=teams3[1].id, teamAScore=1, teamBScore=2) + teams3 = [ + Team(ownerId=owners[0].id, name="a3"), + Team(ownerId=owners[1].id, name="b3"), + ] + matchup3 = Matchup( + teamAId=teams3[0].id, teamBId=teams3[1].id, teamAScore=1, teamBScore=2 + ) week3 = Week(weekNumber=1, matchups=[matchup3]) year3 = Year(yearNumber=2002, teams=teams3, weeks=[week3]) @@ -419,22 +436,34 @@ def test_leagueToExcel_filePathGiven_happyPath(self): (workbook["2002 Matchups"], worksheet2002MatchupValues), ] - for i, (currentWorksheet, allWorksheetValues) in enumerate(yearWorksheetsAndValues): + for i, (currentWorksheet, allWorksheetValues) in enumerate( + yearWorksheetsAndValues + ): for j, worksheetValues in enumerate(allWorksheetValues): for k, worksheetValue in enumerate(worksheetValues): row = j + 1 column = get_column_letter(k + 1) - self.assertEqual(worksheetValue, currentWorksheet[f"{column}{row}"].value) + self.assertEqual( + worksheetValue, currentWorksheet[f"{column}{row}"].value + ) # check that "next" cell is empty self.assertIsNone(currentWorksheet["A4"].value) # check legend self.assertEqual("Filters Applied", currentWorksheet["A6"].value) self.assertEqual("Week Number Start: 1", currentWorksheet["A7"].value) self.assertEqual("Week Number End: 1", currentWorksheet["A8"].value) - self.assertEqual("Only Regular Season: False", currentWorksheet["A9"].value) - self.assertEqual("Only Post Season: False", currentWorksheet["A10"].value) - self.assertEqual("Only Championship: False", currentWorksheet["A11"].value) - self.assertEqual("Include Multi-Week Matchups: True", currentWorksheet["A12"].value) + self.assertEqual( + "Only Regular Season: False", currentWorksheet["A9"].value + ) + self.assertEqual( + "Only Post Season: False", currentWorksheet["A10"].value + ) + self.assertEqual( + "Only Championship: False", currentWorksheet["A11"].value + ) + self.assertEqual( + "Include Multi-Week Matchups: True", currentWorksheet["A12"].value + ) self.assertIsNone(currentWorksheet["A13"].value) # test all time teams worksheet values @@ -699,18 +728,30 @@ def test_leagueToExcel_filePathGiven_happyPath(self): values = allTimeTeamsValues[rowNumber - 1] for columnNumber, value in enumerate(values): cell = f"{get_column_letter(columnNumber + 1)}{rowNumber}" - self.assertEqual(values[columnNumber], allTimeTeamsWorksheet[cell].value) + self.assertEqual( + values[columnNumber], allTimeTeamsWorksheet[cell].value + ) # check that "next" cell is empty self.assertIsNone(allTimeTeamsWorksheet["A8"].value) # check legend self.assertEqual("Filters Applied", allTimeTeamsWorksheet["A10"].value) self.assertEqual("Week Number Start: 1", allTimeTeamsWorksheet["A11"].value) - self.assertEqual("Year Number Start: 2000", allTimeTeamsWorksheet["A12"].value) + self.assertEqual( + "Year Number Start: 2000", allTimeTeamsWorksheet["A12"].value + ) self.assertEqual("Week Number End: 1", allTimeTeamsWorksheet["A13"].value) - self.assertEqual("Year Number End: 2002", allTimeTeamsWorksheet["A14"].value) - self.assertEqual("Only Regular Season: False", allTimeTeamsWorksheet["A15"].value) - self.assertEqual("Only Post Season: False", allTimeTeamsWorksheet["A16"].value) - self.assertEqual("Only Championship: False", allTimeTeamsWorksheet["A17"].value) + self.assertEqual( + "Year Number End: 2002", allTimeTeamsWorksheet["A14"].value + ) + self.assertEqual( + "Only Regular Season: False", allTimeTeamsWorksheet["A15"].value + ) + self.assertEqual( + "Only Post Season: False", allTimeTeamsWorksheet["A16"].value + ) + self.assertEqual( + "Only Championship: False", allTimeTeamsWorksheet["A17"].value + ) self.assertIsNone(allTimeTeamsWorksheet["A18"].value) # test all time matchups worksheet values @@ -740,18 +781,34 @@ def test_leagueToExcel_filePathGiven_happyPath(self): values = allTimeMatchupsValues[rowNumber - 1] for columnNumber, value in enumerate(values): cell = f"{get_column_letter(columnNumber + 1)}{rowNumber}" - self.assertEqual(values[columnNumber], allTimeMatchupsWorksheet[cell].value) + self.assertEqual( + values[columnNumber], allTimeMatchupsWorksheet[cell].value + ) # check that "next" cell is empty self.assertIsNone(allTimeMatchupsWorksheet["A8"].value) # check legend self.assertEqual("Filters Applied", allTimeMatchupsWorksheet["A10"].value) - self.assertEqual("Week Number Start: 1", allTimeMatchupsWorksheet["A11"].value) - self.assertEqual("Year Number Start: 2000", allTimeMatchupsWorksheet["A12"].value) - self.assertEqual("Week Number End: 1", allTimeMatchupsWorksheet["A13"].value) - self.assertEqual("Year Number End: 2002", allTimeMatchupsWorksheet["A14"].value) - self.assertEqual("Only Regular Season: False", allTimeMatchupsWorksheet["A15"].value) - self.assertEqual("Only Post Season: False", allTimeMatchupsWorksheet["A16"].value) - self.assertEqual("Only Championship: False", allTimeMatchupsWorksheet["A17"].value) + self.assertEqual( + "Week Number Start: 1", allTimeMatchupsWorksheet["A11"].value + ) + self.assertEqual( + "Year Number Start: 2000", allTimeMatchupsWorksheet["A12"].value + ) + self.assertEqual( + "Week Number End: 1", allTimeMatchupsWorksheet["A13"].value + ) + self.assertEqual( + "Year Number End: 2002", allTimeMatchupsWorksheet["A14"].value + ) + self.assertEqual( + "Only Regular Season: False", allTimeMatchupsWorksheet["A15"].value + ) + self.assertEqual( + "Only Post Season: False", allTimeMatchupsWorksheet["A16"].value + ) + self.assertEqual( + "Only Championship: False", allTimeMatchupsWorksheet["A17"].value + ) self.assertIsNone(allTimeMatchupsWorksheet["A18"].value) # test all time owners worksheet values @@ -863,35 +920,59 @@ def test_leagueToExcel_filePathGiven_happyPath(self): values = allTimeOwnersValues[rowNumber - 1] for columnNumber, value in enumerate(values): cell = f"{get_column_letter(columnNumber + 1)}{rowNumber}" - self.assertEqual(values[columnNumber], allTimeOwnersWorksheet[cell].value) + self.assertEqual( + values[columnNumber], allTimeOwnersWorksheet[cell].value + ) # check that "next" cell is empty self.assertIsNone(allTimeOwnersWorksheet["A4"].value) # check legend self.assertEqual("Filters Applied", allTimeOwnersWorksheet["A6"].value) self.assertEqual("Week Number Start: 1", allTimeOwnersWorksheet["A7"].value) - self.assertEqual("Year Number Start: 2000", allTimeOwnersWorksheet["A8"].value) + self.assertEqual( + "Year Number Start: 2000", allTimeOwnersWorksheet["A8"].value + ) self.assertEqual("Week Number End: 1", allTimeOwnersWorksheet["A9"].value) - self.assertEqual("Year Number End: 2002", allTimeOwnersWorksheet["A10"].value) - self.assertEqual("Only Regular Season: False", allTimeOwnersWorksheet["A11"].value) - self.assertEqual("Only Post Season: False", allTimeOwnersWorksheet["A12"].value) - self.assertEqual("Only Championship: False", allTimeOwnersWorksheet["A13"].value) + self.assertEqual( + "Year Number End: 2002", allTimeOwnersWorksheet["A10"].value + ) + self.assertEqual( + "Only Regular Season: False", allTimeOwnersWorksheet["A11"].value + ) + self.assertEqual( + "Only Post Season: False", allTimeOwnersWorksheet["A12"].value + ) + self.assertEqual( + "Only Championship: False", allTimeOwnersWorksheet["A13"].value + ) self.assertIsNone(allTimeOwnersWorksheet["A14"].value) def test_leagueToExcel_filePathNotGiven_happyPath(self): owners, teams1 = getNDefaultOwnersAndTeams(2) teams1[0].name = "a" teams1[1].name = "b" - matchup1 = Matchup(teamAId=teams1[0].id, teamBId=teams1[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams1[0].id, teamBId=teams1[1].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) year1 = Year(yearNumber=2000, teams=teams1, weeks=[week1]) - teams2 = [Team(ownerId=owners[0].id, name="a2"), Team(ownerId=owners[1].id, name="b2")] - matchup2 = Matchup(teamAId=teams2[0].id, teamBId=teams2[1].id, teamAScore=1, teamBScore=2) + teams2 = [ + Team(ownerId=owners[0].id, name="a2"), + Team(ownerId=owners[1].id, name="b2"), + ] + matchup2 = Matchup( + teamAId=teams2[0].id, teamBId=teams2[1].id, teamAScore=1, teamBScore=2 + ) week2 = Week(weekNumber=1, matchups=[matchup2]) year2 = Year(yearNumber=2001, teams=teams2, weeks=[week2]) - teams3 = [Team(ownerId=owners[0].id, name="a3"), Team(ownerId=owners[1].id, name="b3")] - matchup3 = Matchup(teamAId=teams3[0].id, teamBId=teams3[1].id, teamAScore=1, teamBScore=2) + teams3 = [ + Team(ownerId=owners[0].id, name="a3"), + Team(ownerId=owners[1].id, name="b3"), + ] + matchup3 = Matchup( + teamAId=teams3[0].id, teamBId=teams3[1].id, teamAScore=1, teamBScore=2 + ) week3 = Week(weekNumber=1, matchups=[matchup3]) year3 = Year(yearNumber=2002, teams=teams3, weeks=[week3]) @@ -1272,7 +1353,9 @@ def test_leagueToExcel_filePathNotGiven_happyPath(self): (workbook["2002 Matchups"], worksheet2002MatchupValues), ] - for i, (currentWorksheet, allWorksheetValues) in enumerate(yearWorksheetsAndValues): + for i, (currentWorksheet, allWorksheetValues) in enumerate( + yearWorksheetsAndValues + ): for j, worksheetValues in enumerate(allWorksheetValues): for k, worksheetValue in enumerate(worksheetValues): row = j + 1 @@ -1287,10 +1370,18 @@ def test_leagueToExcel_filePathNotGiven_happyPath(self): self.assertEqual("Filters Applied", currentWorksheet["A6"].value) self.assertEqual("Week Number Start: 1", currentWorksheet["A7"].value) self.assertEqual("Week Number End: 1", currentWorksheet["A8"].value) - self.assertEqual("Only Regular Season: False", currentWorksheet["A9"].value) - self.assertEqual("Only Post Season: False", currentWorksheet["A10"].value) - self.assertEqual("Only Championship: False", currentWorksheet["A11"].value) - self.assertEqual("Include Multi-Week Matchups: True", currentWorksheet["A12"].value) + self.assertEqual( + "Only Regular Season: False", currentWorksheet["A9"].value + ) + self.assertEqual( + "Only Post Season: False", currentWorksheet["A10"].value + ) + self.assertEqual( + "Only Championship: False", currentWorksheet["A11"].value + ) + self.assertEqual( + "Include Multi-Week Matchups: True", currentWorksheet["A12"].value + ) self.assertIsNone(currentWorksheet["A13"].value) # test all time teams worksheet values @@ -1557,12 +1648,22 @@ def test_leagueToExcel_filePathNotGiven_happyPath(self): # check legend self.assertEqual("Filters Applied", allTimeTeamsWorksheet["A10"].value) self.assertEqual("Week Number Start: 1", allTimeTeamsWorksheet["A11"].value) - self.assertEqual("Year Number Start: 2000", allTimeTeamsWorksheet["A12"].value) + self.assertEqual( + "Year Number Start: 2000", allTimeTeamsWorksheet["A12"].value + ) self.assertEqual("Week Number End: 1", allTimeTeamsWorksheet["A13"].value) - self.assertEqual("Year Number End: 2002", allTimeTeamsWorksheet["A14"].value) - self.assertEqual("Only Regular Season: False", allTimeTeamsWorksheet["A15"].value) - self.assertEqual("Only Post Season: False", allTimeTeamsWorksheet["A16"].value) - self.assertEqual("Only Championship: False", allTimeTeamsWorksheet["A17"].value) + self.assertEqual( + "Year Number End: 2002", allTimeTeamsWorksheet["A14"].value + ) + self.assertEqual( + "Only Regular Season: False", allTimeTeamsWorksheet["A15"].value + ) + self.assertEqual( + "Only Post Season: False", allTimeTeamsWorksheet["A16"].value + ) + self.assertEqual( + "Only Championship: False", allTimeTeamsWorksheet["A17"].value + ) self.assertIsNone(allTimeTeamsWorksheet["A18"].value) # test all time matchups worksheet values @@ -1600,13 +1701,27 @@ def test_leagueToExcel_filePathNotGiven_happyPath(self): self.assertIsNone(allTimeMatchupsWorksheet["A8"].value) # check legend self.assertEqual("Filters Applied", allTimeMatchupsWorksheet["A10"].value) - self.assertEqual("Week Number Start: 1", allTimeMatchupsWorksheet["A11"].value) - self.assertEqual("Year Number Start: 2000", allTimeMatchupsWorksheet["A12"].value) - self.assertEqual("Week Number End: 1", allTimeMatchupsWorksheet["A13"].value) - self.assertEqual("Year Number End: 2002", allTimeMatchupsWorksheet["A14"].value) - self.assertEqual("Only Regular Season: False", allTimeMatchupsWorksheet["A15"].value) - self.assertEqual("Only Post Season: False", allTimeMatchupsWorksheet["A16"].value) - self.assertEqual("Only Championship: False", allTimeMatchupsWorksheet["A17"].value) + self.assertEqual( + "Week Number Start: 1", allTimeMatchupsWorksheet["A11"].value + ) + self.assertEqual( + "Year Number Start: 2000", allTimeMatchupsWorksheet["A12"].value + ) + self.assertEqual( + "Week Number End: 1", allTimeMatchupsWorksheet["A13"].value + ) + self.assertEqual( + "Year Number End: 2002", allTimeMatchupsWorksheet["A14"].value + ) + self.assertEqual( + "Only Regular Season: False", allTimeMatchupsWorksheet["A15"].value + ) + self.assertEqual( + "Only Post Season: False", allTimeMatchupsWorksheet["A16"].value + ) + self.assertEqual( + "Only Championship: False", allTimeMatchupsWorksheet["A17"].value + ) self.assertIsNone(allTimeMatchupsWorksheet["A18"].value) # test all time owners worksheet values @@ -1727,29 +1842,51 @@ def test_leagueToExcel_filePathNotGiven_happyPath(self): # check legend self.assertEqual("Filters Applied", allTimeOwnersWorksheet["A6"].value) self.assertEqual("Week Number Start: 1", allTimeOwnersWorksheet["A7"].value) - self.assertEqual("Year Number Start: 2000", allTimeOwnersWorksheet["A8"].value) + self.assertEqual( + "Year Number Start: 2000", allTimeOwnersWorksheet["A8"].value + ) self.assertEqual("Week Number End: 1", allTimeOwnersWorksheet["A9"].value) - self.assertEqual("Year Number End: 2002", allTimeOwnersWorksheet["A10"].value) - self.assertEqual("Only Regular Season: False", allTimeOwnersWorksheet["A11"].value) - self.assertEqual("Only Post Season: False", allTimeOwnersWorksheet["A12"].value) - self.assertEqual("Only Championship: False", allTimeOwnersWorksheet["A13"].value) + self.assertEqual( + "Year Number End: 2002", allTimeOwnersWorksheet["A10"].value + ) + self.assertEqual( + "Only Regular Season: False", allTimeOwnersWorksheet["A11"].value + ) + self.assertEqual( + "Only Post Season: False", allTimeOwnersWorksheet["A12"].value + ) + self.assertEqual( + "Only Championship: False", allTimeOwnersWorksheet["A13"].value + ) self.assertIsNone(allTimeOwnersWorksheet["A14"].value) def test_leagueToExcel_returnedWorkbookIsSameAsLoadedWorkbook(self): owners, teams1 = getNDefaultOwnersAndTeams(2) teams1[0].name = "a" teams1[1].name = "b" - matchup1 = Matchup(teamAId=teams1[0].id, teamBId=teams1[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams1[0].id, teamBId=teams1[1].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) year1 = Year(yearNumber=2000, teams=teams1, weeks=[week1]) - teams2 = [Team(ownerId=owners[0].id, name="a2"), Team(ownerId=owners[1].id, name="b2")] - matchup2 = Matchup(teamAId=teams2[0].id, teamBId=teams2[1].id, teamAScore=1, teamBScore=2) + teams2 = [ + Team(ownerId=owners[0].id, name="a2"), + Team(ownerId=owners[1].id, name="b2"), + ] + matchup2 = Matchup( + teamAId=teams2[0].id, teamBId=teams2[1].id, teamAScore=1, teamBScore=2 + ) week2 = Week(weekNumber=1, matchups=[matchup2]) year2 = Year(yearNumber=2001, teams=teams2, weeks=[week2]) - teams3 = [Team(ownerId=owners[0].id, name="a3"), Team(ownerId=owners[1].id, name="b3")] - matchup3 = Matchup(teamAId=teams3[0].id, teamBId=teams3[1].id, teamAScore=1, teamBScore=2) + teams3 = [ + Team(ownerId=owners[0].id, name="a3"), + Team(ownerId=owners[1].id, name="b3"), + ] + matchup3 = Matchup( + teamAId=teams3[0].id, teamBId=teams3[1].id, teamAScore=1, teamBScore=2 + ) week3 = Week(weekNumber=1, matchups=[matchup3]) year3 = Year(yearNumber=2002, teams=teams3, weeks=[week3]) @@ -1762,7 +1899,9 @@ def test_leagueToExcel_returnedWorkbookIsSameAsLoadedWorkbook(self): # open created Excel file to check that it was saved correctly loadedWorkbook = load_workbook(filename=fullPath) - self.assertEqual(len(returnedWorkbook.worksheets), len(loadedWorkbook.worksheets)) + self.assertEqual( + len(returnedWorkbook.worksheets), len(loadedWorkbook.worksheets) + ) for ws1, ws2 in zip(returnedWorkbook.worksheets, loadedWorkbook.worksheets): # Compare worksheet names and contents self.assertEqual(ws1.title, ws2.title) @@ -1786,17 +1925,29 @@ def test_leagueToExcel_fileAlreadyExists_raisesException(self): owners, teams1 = getNDefaultOwnersAndTeams(2) teams1[0].name = "a" teams1[1].name = "b" - matchup1 = Matchup(teamAId=teams1[0].id, teamBId=teams1[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams1[0].id, teamBId=teams1[1].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) year1 = Year(yearNumber=2000, teams=teams1, weeks=[week1]) - teams2 = [Team(ownerId=owners[0].id, name="a2"), Team(ownerId=owners[1].id, name="b2")] - matchup2 = Matchup(teamAId=teams2[0].id, teamBId=teams2[1].id, teamAScore=1, teamBScore=2) + teams2 = [ + Team(ownerId=owners[0].id, name="a2"), + Team(ownerId=owners[1].id, name="b2"), + ] + matchup2 = Matchup( + teamAId=teams2[0].id, teamBId=teams2[1].id, teamAScore=1, teamBScore=2 + ) week2 = Week(weekNumber=1, matchups=[matchup2]) year2 = Year(yearNumber=2001, teams=teams2, weeks=[week2]) - teams3 = [Team(ownerId=owners[0].id, name="a3"), Team(ownerId=owners[1].id, name="b3")] - matchup3 = Matchup(teamAId=teams3[0].id, teamBId=teams3[1].id, teamAScore=1, teamBScore=2) + teams3 = [ + Team(ownerId=owners[0].id, name="a3"), + Team(ownerId=owners[1].id, name="b3"), + ] + matchup3 = Matchup( + teamAId=teams3[0].id, teamBId=teams3[1].id, teamAScore=1, teamBScore=2 + ) week3 = Week(weekNumber=1, matchups=[matchup3]) year3 = Year(yearNumber=1999, teams=teams3, weeks=[week3]) diff --git a/test/test_util/test_excel_helper.py b/test/test_util/test_excel_helper.py index 756d4369..ff39c89d 100644 --- a/test/test_util/test_excel_helper.py +++ b/test/test_util/test_excel_helper.py @@ -1,5 +1,4 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams from leeger.model.league import YearSettings from leeger.model.league.League import League @@ -7,13 +6,16 @@ from leeger.model.league.Week import Week from leeger.model.league.Year import Year from leeger.util.excel_helper import allTimeTeamsStatSheet +from test.helper.prototypes import getNDefaultOwnersAndTeams class TestExcelHelper(unittest.TestCase): def test_allTimeTeamsStatSheet_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week = Week(weekNumber=1, matchups=[matchup]) year = Year(yearNumber=2000, teams=teams, weeks=[week]) @@ -45,7 +47,9 @@ def test_allTimeTeamsStatSheet_happyPath(self): self.assertEqual("Points Scored", allTimeTeamsStatSheet_[18][0]) self.assertEqual("Points Scored Per Game", allTimeTeamsStatSheet_[19][0]) self.assertEqual("Opponent Points Scored", allTimeTeamsStatSheet_[20][0]) - self.assertEqual("Opponent Points Scored Per Game", allTimeTeamsStatSheet_[21][0]) + self.assertEqual( + "Opponent Points Scored Per Game", allTimeTeamsStatSheet_[21][0] + ) self.assertEqual("Scoring Share", allTimeTeamsStatSheet_[22][0]) self.assertEqual("Opponent Scoring Share", allTimeTeamsStatSheet_[23][0]) self.assertEqual("Max Scoring Share", allTimeTeamsStatSheet_[24][0]) @@ -61,16 +65,22 @@ def test_allTimeTeamsStatSheet_happyPath(self): def test_allTimeTeamsStatSheet_leagueMedianGamesIsTrueInAnyYearSettings(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week = Week(weekNumber=1, matchups=[matchup]) yearSettings = YearSettings(leagueMedianGames=True) - year1 = Year(yearNumber=2000, teams=teams, weeks=[week], yearSettings=yearSettings) + year1 = Year( + yearNumber=2000, teams=teams, weeks=[week], yearSettings=yearSettings + ) _, teams = getNDefaultOwnersAndTeams(2) teams[0].ownerId = owners[0].id teams[1].ownerId = owners[1].id - matchup = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week = Week(weekNumber=1, matchups=[matchup]) year2 = Year(yearNumber=2001, teams=teams, weeks=[week]) @@ -105,7 +115,9 @@ def test_allTimeTeamsStatSheet_leagueMedianGamesIsTrueInAnyYearSettings(self): self.assertEqual("Points Scored", allTimeTeamsStatSheet_[21][0]) self.assertEqual("Points Scored Per Game", allTimeTeamsStatSheet_[22][0]) self.assertEqual("Opponent Points Scored", allTimeTeamsStatSheet_[23][0]) - self.assertEqual("Opponent Points Scored Per Game", allTimeTeamsStatSheet_[24][0]) + self.assertEqual( + "Opponent Points Scored Per Game", allTimeTeamsStatSheet_[24][0] + ) self.assertEqual("Scoring Share", allTimeTeamsStatSheet_[25][0]) self.assertEqual("Opponent Scoring Share", allTimeTeamsStatSheet_[26][0]) self.assertEqual("Max Scoring Share", allTimeTeamsStatSheet_[27][0]) diff --git a/test/test_util/test_navigator/test_LeagueNavigator.py b/test/test_util/test_navigator/test_LeagueNavigator.py index 99c656a4..32e5ce47 100644 --- a/test/test_util/test_navigator/test_LeagueNavigator.py +++ b/test/test_util/test_navigator/test_LeagueNavigator.py @@ -1,5 +1,4 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams, getTeamsFromOwners from leeger.enum.MatchupType import MatchupType from leeger.exception.DoesNotExistException import DoesNotExistException @@ -12,6 +11,7 @@ from leeger.model.league.Week import Week from leeger.model.league.Year import Year from leeger.util.navigator.LeagueNavigator import LeagueNavigator +from test.helper.prototypes import getNDefaultOwnersAndTeams, getTeamsFromOwners class TestLeagueNavigator(unittest.TestCase): @@ -22,7 +22,9 @@ def test_getYearByYearNumber_happyPath(self): a_team1 = Team(ownerId=owner1.id, name="1") a_team2 = Team(ownerId=owner2.id, name="2") - a_matchup1 = Matchup(teamAId=a_team1.id, teamBId=a_team2.id, teamAScore=1, teamBScore=2) + a_matchup1 = Matchup( + teamAId=a_team1.id, teamBId=a_team2.id, teamAScore=1, teamBScore=2 + ) a_matchup2 = Matchup( teamAId=a_team1.id, teamBId=a_team2.id, @@ -52,13 +54,17 @@ def test_getYearByYearNumber_happyPath(self): a_week4 = Week(weekNumber=4, matchups=[a_matchup4]) a_year = Year( - yearNumber=2000, teams=[a_team1, a_team2], weeks=[a_week1, a_week2, a_week3, a_week4] + yearNumber=2000, + teams=[a_team1, a_team2], + weeks=[a_week1, a_week2, a_week3, a_week4], ) b_team1 = Team(ownerId=owner1.id, name="1") b_team2 = Team(ownerId=owner2.id, name="2") - b_matchup1 = Matchup(teamAId=b_team1.id, teamBId=b_team2.id, teamAScore=1, teamBScore=2) + b_matchup1 = Matchup( + teamAId=b_team1.id, teamBId=b_team2.id, teamAScore=1, teamBScore=2 + ) b_matchup2 = Matchup( teamAId=b_team1.id, teamBId=b_team2.id, @@ -88,7 +94,9 @@ def test_getYearByYearNumber_happyPath(self): b_week4 = Week(weekNumber=4, matchups=[b_matchup4]) b_year = Year( - yearNumber=2001, teams=[b_team1, b_team2], weeks=[b_week1, b_week2, b_week3, b_week4] + yearNumber=2001, + teams=[b_team1, b_team2], + weeks=[b_week1, b_week2, b_week3, b_week4], ) league = League(name="TEST", owners=[owner1, owner2], years=[a_year, b_year]) @@ -105,7 +113,9 @@ def test_getYearByYearNumber_yearDoesntExistInLeague_raisesException(self): a_team1 = Team(ownerId=owner1.id, name="1") a_team2 = Team(ownerId=owner2.id, name="2") - a_matchup1 = Matchup(teamAId=a_team1.id, teamBId=a_team2.id, teamAScore=1, teamBScore=2) + a_matchup1 = Matchup( + teamAId=a_team1.id, teamBId=a_team2.id, teamAScore=1, teamBScore=2 + ) a_matchup2 = Matchup( teamAId=a_team1.id, teamBId=a_team2.id, @@ -135,14 +145,18 @@ def test_getYearByYearNumber_yearDoesntExistInLeague_raisesException(self): a_week4 = Week(weekNumber=4, matchups=[a_matchup4]) a_year = Year( - yearNumber=2000, teams=[a_team1, a_team2], weeks=[a_week1, a_week2, a_week3, a_week4] + yearNumber=2000, + teams=[a_team1, a_team2], + weeks=[a_week1, a_week2, a_week3, a_week4], ) league = League(name="TEST", owners=[owner1, owner2], years=[a_year]) with self.assertRaises(DoesNotExistException) as context: LeagueNavigator.getYearByYearNumber(league, 2001) - self.assertEqual("Year 2001 does not exist in the given League.", str(context.exception)) + self.assertEqual( + "Year 2001 does not exist in the given League.", str(context.exception) + ) def test_getAllOwnerIds_happyPath(self): owner1 = Owner(name="1") @@ -151,7 +165,9 @@ def test_getAllOwnerIds_happyPath(self): a_team1 = Team(ownerId=owner1.id, name="1") a_team2 = Team(ownerId=owner2.id, name="2") - a_matchup1 = Matchup(teamAId=a_team1.id, teamBId=a_team2.id, teamAScore=1, teamBScore=2) + a_matchup1 = Matchup( + teamAId=a_team1.id, teamBId=a_team2.id, teamAScore=1, teamBScore=2 + ) a_week1 = Week(weekNumber=1, matchups=[a_matchup1]) @@ -173,7 +189,9 @@ def test_getTeamById_happyPath(self): a_team1 = Team(ownerId=owner1.id, name="1") a_team2 = Team(ownerId=owner2.id, name="2") - a_matchup1 = Matchup(teamAId=a_team1.id, teamBId=a_team2.id, teamAScore=1, teamBScore=2) + a_matchup1 = Matchup( + teamAId=a_team1.id, teamBId=a_team2.id, teamAScore=1, teamBScore=2 + ) a_week1 = Week(weekNumber=1, matchups=[a_matchup1]) @@ -196,7 +214,9 @@ def test_getTeamById_teamIdNotFound_raisesException(self): a_team1 = Team(ownerId=owner1.id, name="1") a_team2 = Team(ownerId=owner2.id, name="2") - a_matchup1 = Matchup(teamAId=a_team1.id, teamBId=a_team2.id, teamAScore=1, teamBScore=2) + a_matchup1 = Matchup( + teamAId=a_team1.id, teamBId=a_team2.id, teamAScore=1, teamBScore=2 + ) a_week1 = Week(weekNumber=1, matchups=[a_matchup1]) @@ -207,7 +227,8 @@ def test_getTeamById_teamIdNotFound_raisesException(self): with self.assertRaises(DoesNotExistException) as context: LeagueNavigator.getTeamById(league, "imABadID") self.assertEqual( - "Team with ID imABadID does not exist in the given League.", str(context.exception) + "Team with ID imABadID does not exist in the given League.", + str(context.exception), ) def test_getOwnerById_happyPath(self): @@ -217,7 +238,9 @@ def test_getOwnerById_happyPath(self): a_team1 = Team(ownerId=owner1.id, name="1") a_team2 = Team(ownerId=owner2.id, name="2") - a_matchup1 = Matchup(teamAId=a_team1.id, teamBId=a_team2.id, teamAScore=1, teamBScore=2) + a_matchup1 = Matchup( + teamAId=a_team1.id, teamBId=a_team2.id, teamAScore=1, teamBScore=2 + ) a_week1 = Week(weekNumber=1, matchups=[a_matchup1]) @@ -240,7 +263,9 @@ def test_getOwnerById_ownerIdNotFound_raisesException(self): a_team1 = Team(ownerId=owner1.id, name="1") a_team2 = Team(ownerId=owner2.id, name="2") - a_matchup1 = Matchup(teamAId=a_team1.id, teamBId=a_team2.id, teamAScore=1, teamBScore=2) + a_matchup1 = Matchup( + teamAId=a_team1.id, teamBId=a_team2.id, teamAScore=1, teamBScore=2 + ) a_week1 = Week(weekNumber=1, matchups=[a_matchup1]) @@ -251,7 +276,8 @@ def test_getOwnerById_ownerIdNotFound_raisesException(self): with self.assertRaises(DoesNotExistException) as context: LeagueNavigator.getOwnerById(league, "imABadID") self.assertEqual( - "Owner with ID imABadID does not exist in the given League.", str(context.exception) + "Owner with ID imABadID does not exist in the given League.", + str(context.exception), ) def test_getNumberOfGamesPlayed_happyPath(self): @@ -260,7 +286,9 @@ def test_getNumberOfGamesPlayed_happyPath(self): teamsC = getTeamsFromOwners(owners) teamsD = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -280,7 +308,9 @@ def test_getNumberOfGamesPlayed_happyPath(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -300,7 +330,9 @@ def test_getNumberOfGamesPlayed_happyPath(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -320,7 +352,9 @@ def test_getNumberOfGamesPlayed_happyPath(self): week3_c = Week(weekNumber=3, matchups=[matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c, week2_c, week3_c]) - matchup1_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) + matchup1_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) matchup2_d = Matchup( teamAId=teamsD[0].id, teamBId=teamsD[1].id, @@ -367,9 +401,15 @@ def test_getNumberOfGamesPlayed_countLeagueMedianGamesAsTwoGames_countsLeagueMed teamsD = getTeamsFromOwners(owners) yearSettings = YearSettings(leagueMedianGames=True) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup2_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) - matchup3_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) week1_a = Week(weekNumber=1, matchups=[matchup1_a]) week2_a = Week(weekNumber=2, matchups=[matchup2_a]) week3_a = Week(weekNumber=3, matchups=[matchup3_a]) @@ -380,9 +420,15 @@ def test_getNumberOfGamesPlayed_countLeagueMedianGamesAsTwoGames_countsLeagueMed yearSettings=yearSettings, ) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) - matchup2_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1) - matchup3_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1 + ) + matchup3_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=2, teamBScore=1 + ) week1_b = Week(weekNumber=1, matchups=[matchup1_b]) week2_b = Week(weekNumber=2, matchups=[matchup2_b]) week3_b = Week(weekNumber=3, matchups=[matchup3_b]) @@ -393,9 +439,15 @@ def test_getNumberOfGamesPlayed_countLeagueMedianGamesAsTwoGames_countsLeagueMed yearSettings=yearSettings, ) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) - matchup2_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) - matchup3_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) + matchup2_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=2 + ) week1_c = Week(weekNumber=1, matchups=[matchup1_c]) week2_c = Week(weekNumber=2, matchups=[matchup2_c]) week3_c = Week(weekNumber=3, matchups=[matchup3_c]) @@ -406,9 +458,15 @@ def test_getNumberOfGamesPlayed_countLeagueMedianGamesAsTwoGames_countsLeagueMed yearSettings=yearSettings, ) - matchup1_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) - matchup2_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) - matchup3_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) + matchup1_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) + matchup2_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) + matchup3_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) week1_d = Week(weekNumber=1, matchups=[matchup1_d]) week2_d = Week(weekNumber=2, matchups=[matchup2_d]) week3_d = Week(weekNumber=3, matchups=[matchup3_d]) @@ -445,7 +503,9 @@ def test_getNumberOfGamesPlayed_countMultiWeekMatchupsAsOneGameIsTrue(self): teamsC = getTeamsFromOwners(owners) teamsD = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -467,7 +527,9 @@ def test_getNumberOfGamesPlayed_countMultiWeekMatchupsAsOneGameIsTrue(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -487,7 +549,9 @@ def test_getNumberOfGamesPlayed_countMultiWeekMatchupsAsOneGameIsTrue(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -507,7 +571,9 @@ def test_getNumberOfGamesPlayed_countMultiWeekMatchupsAsOneGameIsTrue(self): week3_c = Week(weekNumber=3, matchups=[matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c, week2_c, week3_c]) - matchup1_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) + matchup1_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) matchup2_d = Matchup( teamAId=teamsD[0].id, teamBId=teamsD[1].id, @@ -553,7 +619,9 @@ def test_getNumberOfGamesPlayed_onlyRegularSeason(self): teamsC = getTeamsFromOwners(owners) teamsD = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -573,7 +641,9 @@ def test_getNumberOfGamesPlayed_onlyRegularSeason(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -593,7 +663,9 @@ def test_getNumberOfGamesPlayed_onlyRegularSeason(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -613,7 +685,9 @@ def test_getNumberOfGamesPlayed_onlyRegularSeason(self): week3_c = Week(weekNumber=3, matchups=[matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c, week2_c, week3_c]) - matchup1_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) + matchup1_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) matchup2_d = Matchup( teamAId=teamsD[0].id, teamBId=teamsD[1].id, @@ -657,7 +731,9 @@ def test_getNumberOfGamesPlayed_onlyPostSeason(self): teamsC = getTeamsFromOwners(owners) teamsD = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -677,7 +753,9 @@ def test_getNumberOfGamesPlayed_onlyPostSeason(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -697,7 +775,9 @@ def test_getNumberOfGamesPlayed_onlyPostSeason(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -717,7 +797,9 @@ def test_getNumberOfGamesPlayed_onlyPostSeason(self): week3_c = Week(weekNumber=3, matchups=[matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c, week2_c, week3_c]) - matchup1_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) + matchup1_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) matchup2_d = Matchup( teamAId=teamsD[0].id, teamBId=teamsD[1].id, @@ -761,7 +843,9 @@ def test_getNumberOfGamesPlayed_onlyChampionship(self): teamsC = getTeamsFromOwners(owners) teamsD = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -781,7 +865,9 @@ def test_getNumberOfGamesPlayed_onlyChampionship(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -801,7 +887,9 @@ def test_getNumberOfGamesPlayed_onlyChampionship(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -821,7 +909,9 @@ def test_getNumberOfGamesPlayed_onlyChampionship(self): week3_c = Week(weekNumber=3, matchups=[matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c, week2_c, week3_c]) - matchup1_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) + matchup1_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) matchup2_d = Matchup( teamAId=teamsD[0].id, teamBId=teamsD[1].id, @@ -865,7 +955,9 @@ def test_getNumberOfGamesPlayed_yearNumberStartWeekNumberStart(self): teamsC = getTeamsFromOwners(owners) teamsD = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -885,7 +977,9 @@ def test_getNumberOfGamesPlayed_yearNumberStartWeekNumberStart(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -905,7 +999,9 @@ def test_getNumberOfGamesPlayed_yearNumberStartWeekNumberStart(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -925,7 +1021,9 @@ def test_getNumberOfGamesPlayed_yearNumberStartWeekNumberStart(self): week3_c = Week(weekNumber=3, matchups=[matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c, week2_c, week3_c]) - matchup1_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) + matchup1_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) matchup2_d = Matchup( teamAId=teamsD[0].id, teamBId=teamsD[1].id, @@ -969,7 +1067,9 @@ def test_getNumberOfGamesPlayed_yearNumberEndWeekNumberEnd(self): teamsC = getTeamsFromOwners(owners) teamsD = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -989,7 +1089,9 @@ def test_getNumberOfGamesPlayed_yearNumberEndWeekNumberEnd(self): week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -1009,7 +1111,9 @@ def test_getNumberOfGamesPlayed_yearNumberEndWeekNumberEnd(self): week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -1029,7 +1133,9 @@ def test_getNumberOfGamesPlayed_yearNumberEndWeekNumberEnd(self): week3_c = Week(weekNumber=3, matchups=[matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c, week2_c, week3_c]) - matchup1_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) + matchup1_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) matchup2_d = Matchup( teamAId=teamsD[0].id, teamBId=teamsD[1].id, @@ -1067,13 +1173,17 @@ def test_getNumberOfGamesPlayed_yearNumberEndWeekNumberEnd(self): self.assertEqual(8, response[owners[0].id]) self.assertEqual(8, response[owners[1].id]) - def test_getNumberOfGamesPlayed_yearNumberStartWeekNumberStartYearNumberEndWeekNumberEnd(self): + def test_getNumberOfGamesPlayed_yearNumberStartWeekNumberStartYearNumberEndWeekNumberEnd( + self, + ): owners, teamsA = getNDefaultOwnersAndTeams(2) teamsB = getTeamsFromOwners(owners) teamsC = getTeamsFromOwners(owners) teamsD = getTeamsFromOwners(owners) - matchup1_a = Matchup(teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2) + matchup1_a = Matchup( + teamAId=teamsA[0].id, teamBId=teamsA[1].id, teamAScore=1, teamBScore=2 + ) matchup2_a = Matchup( teamAId=teamsA[0].id, teamBId=teamsA[1].id, @@ -1093,7 +1203,9 @@ def test_getNumberOfGamesPlayed_yearNumberStartWeekNumberStartYearNumberEndWeekN week3_a = Week(weekNumber=3, matchups=[matchup3_a]) yearA = Year(yearNumber=2000, teams=teamsA, weeks=[week1_a, week2_a, week3_a]) - matchup1_b = Matchup(teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2) + matchup1_b = Matchup( + teamAId=teamsB[0].id, teamBId=teamsB[1].id, teamAScore=1, teamBScore=2 + ) matchup2_b = Matchup( teamAId=teamsB[0].id, teamBId=teamsB[1].id, @@ -1113,7 +1225,9 @@ def test_getNumberOfGamesPlayed_yearNumberStartWeekNumberStartYearNumberEndWeekN week3_b = Week(weekNumber=3, matchups=[matchup3_b]) yearB = Year(yearNumber=2001, teams=teamsB, weeks=[week1_b, week2_b, week3_b]) - matchup1_c = Matchup(teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1) + matchup1_c = Matchup( + teamAId=teamsC[0].id, teamBId=teamsC[1].id, teamAScore=1, teamBScore=1 + ) matchup2_c = Matchup( teamAId=teamsC[0].id, teamBId=teamsC[1].id, @@ -1133,7 +1247,9 @@ def test_getNumberOfGamesPlayed_yearNumberStartWeekNumberStartYearNumberEndWeekN week3_c = Week(weekNumber=3, matchups=[matchup3_c]) yearC = Year(yearNumber=2002, teams=teamsC, weeks=[week1_c, week2_c, week3_c]) - matchup1_d = Matchup(teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2) + matchup1_d = Matchup( + teamAId=teamsD[0].id, teamBId=teamsD[1].id, teamAScore=1, teamBScore=2 + ) matchup2_d = Matchup( teamAId=teamsD[0].id, teamBId=teamsD[1].id, @@ -1288,7 +1404,8 @@ def test_getAllScoresInLeague_happyPath(self): self.assertIsInstance(response, list) self.assertEqual(16, len(response)) self.assertEqual( - [3, 4, 5, 6, 9, 10, 11, 12, 15, 16, 17, 18, 21, 22, 23, 24], sorted(response) + [3, 4, 5, 6, 9, 10, 11, 12, 15, 16, 17, 18, 21, 22, 23, 24], + sorted(response), ) def test_getAllScoresInLeague_simplifyMultiWeekMatchupsIsTrue(self): @@ -1325,7 +1442,9 @@ def test_getAllScoresInLeague_simplifyMultiWeekMatchupsIsTrue(self): league = League(name="TEST", owners=owners, years=[yearA]) - response = LeagueNavigator.getAllScoresInLeague(league, simplifyMultiWeekMatchups=True) + response = LeagueNavigator.getAllScoresInLeague( + league, simplifyMultiWeekMatchups=True + ) self.assertIsInstance(response, list) self.assertEqual(4, len(response)) diff --git a/test/test_util/test_navigator/test_MatchupNavigator.py b/test/test_util/test_navigator/test_MatchupNavigator.py index fbeabfaa..c5d5614e 100644 --- a/test/test_util/test_navigator/test_MatchupNavigator.py +++ b/test/test_util/test_navigator/test_MatchupNavigator.py @@ -1,18 +1,24 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams from leeger.enum import MatchupType from leeger.model.league.Matchup import Matchup from leeger.util.navigator.MatchupNavigator import MatchupNavigator +from test.helper.prototypes import getNDefaultOwnersAndTeams class TestMatchupNavigator(unittest.TestCase): def test_getTeamIdOfMatchupWinner_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(6) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=2, teamBScore=1 + ) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=1 + ) response1 = MatchupNavigator.getTeamIdOfMatchupWinner(matchup1) response2 = MatchupNavigator.getTeamIdOfMatchupWinner(matchup2) @@ -91,8 +97,12 @@ def test_simplifyMultiWeekMatchups_emptyListGiven_raisesException(self): def test_getMedianScore_happyPath(self): _, teams = getNDefaultOwnersAndTeams(4) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[2].id, teamBId=teams[3].id, teamAScore=3, teamBScore=4 + ) response = MatchupNavigator.getMedianScore([matchup1, matchup2]) diff --git a/test/test_util/test_navigator/test_WeekNavigator.py b/test/test_util/test_navigator/test_WeekNavigator.py index fa59a592..ab80f2d5 100644 --- a/test/test_util/test_navigator/test_WeekNavigator.py +++ b/test/test_util/test_navigator/test_WeekNavigator.py @@ -1,11 +1,11 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams from leeger.enum.MatchupType import MatchupType from leeger.model.filter.WeekFilters import WeekFilters from leeger.model.league.Matchup import Matchup from leeger.model.league.Week import Week from leeger.util.navigator.WeekNavigator import WeekNavigator +from test.helper.prototypes import getNDefaultOwnersAndTeams class TestWeekNavigator(unittest.TestCase): @@ -98,7 +98,9 @@ def test_getTeamIdsAndOpponentScores_happyPath(self): def test_getNumberOfValidTeamsInWeek_happyPath(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, diff --git a/test/test_util/test_navigator/test_YearNavigator.py b/test/test_util/test_navigator/test_YearNavigator.py index c6379c0f..012a1f22 100644 --- a/test/test_util/test_navigator/test_YearNavigator.py +++ b/test/test_util/test_navigator/test_YearNavigator.py @@ -1,5 +1,4 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams from leeger.enum.MatchupType import MatchupType from leeger.exception.DoesNotExistException import DoesNotExistException @@ -12,6 +11,7 @@ from leeger.model.league.Week import Week from leeger.model.league.Year import Year from leeger.util.navigator.YearNavigator import YearNavigator +from test.helper.prototypes import getNDefaultOwnersAndTeams class TestYearNavigator(unittest.TestCase): @@ -29,7 +29,8 @@ def test_getTeamById_notFound_raisesException(self): with self.assertRaises(DoesNotExistException) as context: YearNavigator.getTeamById(year, "badId") self.assertEqual( - "Team with ID 'badId' does not exist in the given Year.", str(context.exception) + "Team with ID 'badId' does not exist in the given Year.", + str(context.exception), ) def test_getDivisionById_happyPath(self): @@ -46,7 +47,8 @@ def test_getDivisionById_notFound_raisesException(self): with self.assertRaises(DoesNotExistException) as context: YearNavigator.getDivisionById(year, "badId") self.assertEqual( - "Division with ID 'badId' does not exist in the given Year.", str(context.exception) + "Division with ID 'badId' does not exist in the given Year.", + str(context.exception), ) def test_getYearByYearNumber_happyPath(self): @@ -56,7 +58,9 @@ def test_getYearByYearNumber_happyPath(self): a_team1 = Team(ownerId=owner1.id, name="1") a_team2 = Team(ownerId=owner2.id, name="2") - a_matchup1 = Matchup(teamAId=a_team1.id, teamBId=a_team2.id, teamAScore=1, teamBScore=2) + a_matchup1 = Matchup( + teamAId=a_team1.id, teamBId=a_team2.id, teamAScore=1, teamBScore=2 + ) a_matchup2 = Matchup( teamAId=a_team1.id, teamBId=a_team2.id, @@ -86,7 +90,9 @@ def test_getYearByYearNumber_happyPath(self): a_week4 = Week(weekNumber=4, matchups=[a_matchup4]) a_year = Year( - yearNumber=2000, teams=[a_team1, a_team2], weeks=[a_week1, a_week2, a_week3, a_week4] + yearNumber=2000, + teams=[a_team1, a_team2], + weeks=[a_week1, a_week2, a_week3, a_week4], ) response = YearNavigator.getAllTeamIds(a_year) @@ -99,8 +105,12 @@ def test_getYearByYearNumber_happyPath(self): def test_getNumberOfGamesPlayed_happyPath(self): _, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -120,14 +130,23 @@ def test_getNumberOfGamesPlayed_countLeagueMedianGamesAsTwoGames_countsLeagueMed ): _, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) yearSettings = YearSettings(leagueMedianGames=True) - year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2], yearSettings=yearSettings) + year = Year( + yearNumber=2000, + teams=teams, + weeks=[week1, week2], + yearSettings=yearSettings, + ) yearFilters = YearFilters(weekNumberStart=1, weekNumberEnd=2) response = YearNavigator.getNumberOfGamesPlayed( @@ -212,7 +231,9 @@ def test_getNumberOfGamesPlayed_countMultiWeekMatchupsAsOneGameIsFalse_countsMul def test_getNumberOfGamesPlayed_onlyPostSeasonIsTrue(self): _, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -234,7 +255,9 @@ def test_getNumberOfGamesPlayed_onlyPostSeasonIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - yearFilters = YearFilters(weekNumberStart=1, weekNumberEnd=3, onlyPostSeason=True) + yearFilters = YearFilters( + weekNumberStart=1, weekNumberEnd=3, onlyPostSeason=True + ) response = YearNavigator.getNumberOfGamesPlayed(year, yearFilters) self.assertIsInstance(response, dict) @@ -245,7 +268,9 @@ def test_getNumberOfGamesPlayed_onlyPostSeasonIsTrue(self): def test_getNumberOfGamesPlayed_onlyRegularSeasonIsTrue(self): _, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -267,7 +292,9 @@ def test_getNumberOfGamesPlayed_onlyRegularSeasonIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - yearFilters = YearFilters(weekNumberStart=1, weekNumberEnd=3, onlyRegularSeason=True) + yearFilters = YearFilters( + weekNumberStart=1, weekNumberEnd=3, onlyRegularSeason=True + ) response = YearNavigator.getNumberOfGamesPlayed(year, yearFilters) self.assertIsInstance(response, dict) @@ -278,7 +305,9 @@ def test_getNumberOfGamesPlayed_onlyRegularSeasonIsTrue(self): def test_getNumberOfGamesPlayed_weekNumberStartGiven(self): _, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -311,7 +340,9 @@ def test_getNumberOfGamesPlayed_weekNumberStartGiven(self): def test_getNumberOfGamesPlayed_weekNumberEndGiven(self): _, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -344,7 +375,9 @@ def test_getNumberOfGamesPlayed_weekNumberEndGiven(self): def test_getNumberOfGamesPlayed_weekNumberStartGivenAndWeekNumberEndGiven(self): _, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -385,7 +418,9 @@ def test_getNumberOfGamesPlayed_weekNumberStartGivenAndWeekNumberEndGiven(self): def test_getAllScoresInYear_happyPath(self): _, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -393,7 +428,9 @@ def test_getAllScoresInYear_happyPath(self): teamBScore=4, matchupType=MatchupType.IGNORE, ) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=5, teamBScore=6) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=5, teamBScore=6 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -424,7 +461,9 @@ def test_getAllScoresInYear_simplifyMultiWeekMatchupsIsTrue(self): teamBScore=4, multiWeekMatchupId="1", ) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=5, teamBScore=6) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=5, teamBScore=6 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -432,7 +471,9 @@ def test_getAllScoresInYear_simplifyMultiWeekMatchupsIsTrue(self): year = Year(yearNumber=2000, teams=teams, weeks=[week1, week2, week3]) - response = YearNavigator.getAllScoresInYear(year, simplifyMultiWeekMatchups=True) + response = YearNavigator.getAllScoresInYear( + year, simplifyMultiWeekMatchups=True + ) self.assertIsInstance(response, list) self.assertEqual(4, len(response)) @@ -482,9 +523,15 @@ def test_getAllMultiWeekMatchups_happyPath(self): def test_getAllMultiWeekMatchups_noMultiWeekMatchupsFound_returnsEmptyDict(self): _, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=3, teamBScore=4) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=5, teamBScore=6) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=3, teamBScore=4 + ) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=5, teamBScore=6 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=[matchup2]) @@ -497,7 +544,9 @@ def test_getAllMultiWeekMatchups_noMultiWeekMatchupsFound_returnsEmptyDict(self) self.assertIsInstance(response, dict) self.assertEqual(0, len(response.keys())) - def test_getAllMultiWeekMatchups_includeMultiWeekMatchupsIsFalse_raisesException(self): + def test_getAllMultiWeekMatchups_includeMultiWeekMatchupsIsFalse_raisesException( + self, + ): with self.assertRaises(ValueError) as context: YearNavigator.getAllMultiWeekMatchups( None, @@ -509,13 +558,16 @@ def test_getAllMultiWeekMatchups_includeMultiWeekMatchupsIsFalse_raisesException ), ) self.assertEqual( - "Multi-Week matchups must be included in this calculation.", str(context.exception) + "Multi-Week matchups must be included in this calculation.", + str(context.exception), ) def test_getAllMatchupsInYear_noFilterGiven_happyPath(self): _, teams = getNDefaultOwnersAndTeams(2) - a_matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + a_matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) a_matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -544,7 +596,9 @@ def test_getAllMatchupsInYear_noFilterGiven_happyPath(self): a_week3 = Week(weekNumber=3, matchups=[a_matchup3]) a_week4 = Week(weekNumber=4, matchups=[a_matchup4]) - a_year = Year(yearNumber=2000, teams=teams, weeks=[a_week1, a_week2, a_week3, a_week4]) + a_year = Year( + yearNumber=2000, teams=teams, weeks=[a_week1, a_week2, a_week3, a_week4] + ) response = YearNavigator.getAllMatchupsInYear(a_year) @@ -558,8 +612,12 @@ def test_getAllMatchupsInYear_noFilterGiven_happyPath(self): def test_getAllMatchupsInYear_filterGiven_happyPath(self): _, teams = getNDefaultOwnersAndTeams(2) - a_matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) - a_matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + a_matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) + a_matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) a_matchup3 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -581,7 +639,9 @@ def test_getAllMatchupsInYear_filterGiven_happyPath(self): a_week3 = Week(weekNumber=3, matchups=[a_matchup3]) a_week4 = Week(weekNumber=4, matchups=[a_matchup4]) - a_year = Year(yearNumber=2000, teams=teams, weeks=[a_week1, a_week2, a_week3, a_week4]) + a_year = Year( + yearNumber=2000, teams=teams, weeks=[a_week1, a_week2, a_week3, a_week4] + ) response = YearNavigator.getAllMatchupsInYear( a_year, YearFilters(weekNumberStart=2, weekNumberEnd=3, onlyPostSeason=True) @@ -591,7 +651,9 @@ def test_getAllMatchupsInYear_filterGiven_happyPath(self): self.assertEqual(1, len(response)) self.assertEqual(a_matchup3.id, response[0].id) - def test_getAllMatchupsInYear_filterGiven_includeMultiWeekMatchupsIsTrue_happyPath(self): + def test_getAllMatchupsInYear_filterGiven_includeMultiWeekMatchupsIsTrue_happyPath( + self, + ): _, teams = getNDefaultOwnersAndTeams(2) a_matchup1 = Matchup( @@ -608,7 +670,9 @@ def test_getAllMatchupsInYear_filterGiven_includeMultiWeekMatchupsIsTrue_happyPa teamBScore=2, multiWeekMatchupId="1", ) - a_matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + a_matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) a_week1 = Week(weekNumber=1, matchups=[a_matchup1]) a_week2 = Week(weekNumber=2, matchups=[a_matchup2]) @@ -632,7 +696,9 @@ def test_getAllMatchupsInYear_filterGiven_includeMultiWeekMatchupsIsTrue_happyPa self.assertEqual(a_matchup2.id, response[1].id) self.assertEqual(a_matchup3.id, response[2].id) - def test_getAllMatchupsInYear_filterGiven_includeMultiWeekMatchupsIsFalse_happyPath(self): + def test_getAllMatchupsInYear_filterGiven_includeMultiWeekMatchupsIsFalse_happyPath( + self, + ): _, teams = getNDefaultOwnersAndTeams(2) a_matchup1 = Matchup( @@ -649,7 +715,9 @@ def test_getAllMatchupsInYear_filterGiven_includeMultiWeekMatchupsIsFalse_happyP teamBScore=2, multiWeekMatchupId="1", ) - a_matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + a_matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) a_week1 = Week(weekNumber=1, matchups=[a_matchup1]) a_week2 = Week(weekNumber=2, matchups=[a_matchup2]) @@ -688,7 +756,9 @@ def test_getAllSimplifiedMatchupsInYear_noFilterGiven_happyPath(self): teamBScore=2, multiWeekMatchupId="1", ) - a_matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + a_matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) a_week1 = Week(weekNumber=1, matchups=[a_matchup1]) a_week2 = Week(weekNumber=2, matchups=[a_matchup2]) @@ -709,7 +779,9 @@ def test_getAllSimplifiedMatchupsInYear_noFilterGiven_happyPath(self): def test_getAllSimplifiedMatchupsInYear_filterGiven_happyPath(self): _, teams = getNDefaultOwnersAndTeams(2) - a_matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + a_matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) a_matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -755,7 +827,9 @@ def test_getAllSimplifiedMatchupsInYear_filterGiven_happyPath(self): self.assertEqual(2, response[0].teamAScore) self.assertEqual(4, response[0].teamBScore) - def test_getAllSimplifiedMatchupsInYear_includeMultiWeekMatchupsIsFalse_raisesException(self): + def test_getAllSimplifiedMatchupsInYear_includeMultiWeekMatchupsIsFalse_raisesException( + self, + ): with self.assertRaises(ValueError) as context: YearNavigator.getAllSimplifiedMatchupsInYear( None, @@ -767,5 +841,6 @@ def test_getAllSimplifiedMatchupsInYear_includeMultiWeekMatchupsIsFalse_raisesEx ), ) self.assertEqual( - "Multi-Week matchups must be included in this calculation.", str(context.exception) + "Multi-Week matchups must be included in this calculation.", + str(context.exception), ) diff --git a/test/test_util/test_stat_sheet.py b/test/test_util/test_stat_sheet.py index 31aeaf18..7bfa502b 100644 --- a/test/test_util/test_stat_sheet.py +++ b/test/test_util/test_stat_sheet.py @@ -1,5 +1,4 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams from leeger.model.league import YearSettings from leeger.model.league.League import League @@ -8,6 +7,7 @@ from leeger.model.league.Year import Year from leeger.model.stat.AllTimeStatSheet import AllTimeStatSheet from leeger.model.stat.YearStatSheet import YearStatSheet +from test.helper.prototypes import getNDefaultOwnersAndTeams class TestStatSheet(unittest.TestCase): @@ -16,7 +16,9 @@ def test_leagueStatSheet(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week = Week(weekNumber=1, matchups=[matchup]) year = Year(yearNumber=2000, teams=teams, weeks=[week]) @@ -72,10 +74,14 @@ def test_leagueStatSheet_leagueMedianGamesIsTrueInAnyYearSettings(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week = Week(weekNumber=1, matchups=[matchup]) yearSettings = YearSettings(leagueMedianGames=True) - year = Year(yearNumber=2000, teams=teams, weeks=[week], yearSettings=yearSettings) + year = Year( + yearNumber=2000, teams=teams, weeks=[week], yearSettings=yearSettings + ) league = League(name="TEST", owners=owners, years=[year]) @@ -89,7 +95,9 @@ def test_yearStatSheet(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week = Week(weekNumber=1, matchups=[matchup]) year = Year(yearNumber=2000, teams=teams, weeks=[week]) @@ -148,7 +156,9 @@ def test_yearStatSheet_ownerNamesAndYearsGiven(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week = Week(weekNumber=1, matchups=[matchup]) year = Year(yearNumber=2000, teams=teams, weeks=[week]) @@ -211,10 +221,14 @@ def test_yearStatSheet_leagueMedianGamesIsTrue(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week = Week(weekNumber=1, matchups=[matchup]) yearSettings = YearSettings(leagueMedianGames=True) - year = Year(yearNumber=2000, teams=teams, weeks=[week], yearSettings=yearSettings) + year = Year( + yearNumber=2000, teams=teams, weeks=[week], yearSettings=yearSettings + ) yearStatSheet = yearStatSheet(year) diff --git a/test/test_validate/test_divisionValidation.py b/test/test_validate/test_divisionValidation.py index 47bcf557..b2f84dd0 100644 --- a/test/test_validate/test_divisionValidation.py +++ b/test/test_validate/test_divisionValidation.py @@ -1,6 +1,8 @@ import unittest -from leeger.exception.InvalidDivisionFormatException import InvalidDivisionFormatException +from leeger.exception.InvalidDivisionFormatException import ( + InvalidDivisionFormatException, +) from leeger.model.league.Division import Division from leeger.validate import divisionValidation diff --git a/test/test_validate/test_leagueValidation.py b/test/test_validate/test_leagueValidation.py index 344ee47e..7586c44f 100644 --- a/test/test_validate/test_leagueValidation.py +++ b/test/test_validate/test_leagueValidation.py @@ -1,5 +1,4 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams from leeger.enum.MatchupType import MatchupType from leeger.exception.InvalidLeagueFormatException import InvalidLeagueFormatException @@ -10,6 +9,7 @@ from leeger.model.league.Week import Week from leeger.model.league.Year import Year from leeger.validate import leagueValidation +from test.helper.prototypes import getNDefaultOwnersAndTeams class TestLeagueValidation(unittest.TestCase): @@ -20,7 +20,9 @@ def test_runAllChecks_happyPath(self): a_team1 = Team(ownerId=owner1.id, name="1") a_team2 = Team(ownerId=owner2.id, name="2") - a_matchup1 = Matchup(teamAId=a_team1.id, teamBId=a_team2.id, teamAScore=1, teamBScore=2) + a_matchup1 = Matchup( + teamAId=a_team1.id, teamBId=a_team2.id, teamAScore=1, teamBScore=2 + ) a_matchup2 = Matchup( teamAId=a_team1.id, teamBId=a_team2.id, @@ -50,13 +52,17 @@ def test_runAllChecks_happyPath(self): a_week4 = Week(weekNumber=4, matchups=[a_matchup4]) a_year = Year( - yearNumber=2000, teams=[a_team1, a_team2], weeks=[a_week1, a_week2, a_week3, a_week4] + yearNumber=2000, + teams=[a_team1, a_team2], + weeks=[a_week1, a_week2, a_week3, a_week4], ) b_team1 = Team(ownerId=owner1.id, name="1") b_team2 = Team(ownerId=owner2.id, name="2") - b_matchup1 = Matchup(teamAId=b_team1.id, teamBId=b_team2.id, teamAScore=1, teamBScore=2) + b_matchup1 = Matchup( + teamAId=b_team1.id, teamBId=b_team2.id, teamAScore=1, teamBScore=2 + ) b_matchup2 = Matchup( teamAId=b_team1.id, teamBId=b_team2.id, @@ -86,7 +92,9 @@ def test_runAllChecks_happyPath(self): b_week4 = Week(weekNumber=4, matchups=[b_matchup4]) b_year = Year( - yearNumber=2001, teams=[b_team1, b_team2], weeks=[b_week1, b_week2, b_week3, b_week4] + yearNumber=2001, + teams=[b_team1, b_team2], + weeks=[b_week1, b_week2, b_week3, b_week4], ) leagueValidation.runAllChecks( @@ -109,7 +117,8 @@ def test_checkYearsAreInCorrectOrder_yearsArentInCorrectOrder_raisesException(se League(name="TEST", owners=list(), years=[b_year, a_year]) ) self.assertEqual( - "Years are not in chronological order (oldest -> newest).", str(context.exception) + "Years are not in chronological order (oldest -> newest).", + str(context.exception), ) def test_checkNoDuplicateYearNumbers_duplicateYearNumbers_raisesException(self): @@ -128,7 +137,8 @@ def test_checkNoDuplicateYearNumbers_duplicateYearNumbers_raisesException(self): League(name="TEST", owners=list(), years=[a_year, b_year]) ) self.assertEqual( - "Can only have 1 of each year number within a league.", str(context.exception) + "Can only have 1 of each year number within a league.", + str(context.exception), ) def test_checkForDuplicateOwners_duplicateOwnerInstances_raisesException(self): @@ -160,11 +170,15 @@ def test_checkNoDuplicateOwnerNames_duplicateOwnerNames_raisesException(self): def test_checkForDuplicateTeams_duplicateTeams_raisesException(self): owners, teams = getNDefaultOwnersAndTeams(2) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) year1 = Year(yearNumber=2000, teams=teams, weeks=[week1]) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week2 = Week(weekNumber=1, matchups=[matchup2]) year2 = Year(yearNumber=2001, teams=teams, weeks=[week2]) @@ -189,27 +203,37 @@ def test_checkLeagueHasAtLeastOneYear_leagueHasNoYears_raisesException(self): def test_checkAllTypes_leagueNameIsntTypeString_raisesException(self): with self.assertRaises(InvalidLeagueFormatException) as context: - leagueValidation.checkAllTypes(League(name=None, owners=list(), years=list())) + leagueValidation.checkAllTypes( + League(name=None, owners=list(), years=list()) + ) self.assertEqual("name must be type 'str'.", str(context.exception)) def test_checkAllTypes_leagueOwnersIsntTypeList_raisesException(self): # not given a list with self.assertRaises(InvalidLeagueFormatException) as context: - leagueValidation.checkAllTypes(League(name="TEST", owners=None, years=list())) + leagueValidation.checkAllTypes( + League(name="TEST", owners=None, years=list()) + ) self.assertEqual("owners must be type 'list[Owner]'.", str(context.exception)) # given a list of non Owner with self.assertRaises(InvalidLeagueFormatException) as context: - leagueValidation.checkAllTypes(League(name="TEST", owners=["foo"], years=list())) + leagueValidation.checkAllTypes( + League(name="TEST", owners=["foo"], years=list()) + ) self.assertEqual("owners must be type 'list[Owner]'.", str(context.exception)) def test_checkAllTypes_leagueYearsIsntTypeList_raisesException(self): # not given a list with self.assertRaises(InvalidLeagueFormatException) as context: - leagueValidation.checkAllTypes(League(name="TEST", owners=list(), years=None)) + leagueValidation.checkAllTypes( + League(name="TEST", owners=list(), years=None) + ) self.assertEqual("years must be type 'list[Year]'.", str(context.exception)) # given a list of non Year with self.assertRaises(InvalidLeagueFormatException) as context: - leagueValidation.checkAllTypes(League(name="TEST", owners=list(), years=["foo"])) + leagueValidation.checkAllTypes( + League(name="TEST", owners=list(), years=["foo"]) + ) self.assertEqual("years must be type 'list[Year]'.", str(context.exception)) diff --git a/test/test_validate/test_matchupValidation.py b/test/test_validate/test_matchupValidation.py index 16c5c94c..5238c056 100644 --- a/test/test_validate/test_matchupValidation.py +++ b/test/test_validate/test_matchupValidation.py @@ -19,10 +19,13 @@ def test_checkForIllegalMatchupOutcomes_playoffMatchupIsTie_raisesException(self ) ) self.assertEqual( - "Playoff and Championship matchups cannot end in a tie.", str(context.exception) + "Playoff and Championship matchups cannot end in a tie.", + str(context.exception), ) - def test_checkForIllegalMatchupOutcomes_championshipMatchupIsTie_raisesException(self): + def test_checkForIllegalMatchupOutcomes_championshipMatchupIsTie_raisesException( + self, + ): with self.assertRaises(InvalidMatchupFormatException) as context: matchupValidation.checkForIllegalMatchupOutcomes( Matchup( @@ -34,10 +37,13 @@ def test_checkForIllegalMatchupOutcomes_championshipMatchupIsTie_raisesException ) ) self.assertEqual( - "Playoff and Championship matchups cannot end in a tie.", str(context.exception) + "Playoff and Championship matchups cannot end in a tie.", + str(context.exception), ) - def test_checkThatTeamIdsAreNotTheSame_teamAIdAndTeamBIdAreTheSame_raisesException(self): + def test_checkThatTeamIdsAreNotTheSame_teamAIdAndTeamBIdAreTheSame_raisesException( + self, + ): with self.assertRaises(InvalidMatchupFormatException) as context: matchupValidation.checkThatTeamIdsAreNotTheSame( Matchup( @@ -48,7 +54,9 @@ def test_checkThatTeamIdsAreNotTheSame_teamAIdAndTeamBIdAreTheSame_raisesExcepti matchupType=MatchupType.CHAMPIONSHIP, ) ) - self.assertEqual("Team A and Team B cannot have the same ID.", str(context.exception)) + self.assertEqual( + "Team A and Team B cannot have the same ID.", str(context.exception) + ) #################### # TYPE CHECK TESTS # @@ -73,21 +81,33 @@ def test_checkAllTypes_teamAScoreIsntTypeFloatOrInt_raisesException(self): matchupValidation.checkAllTypes( Matchup(teamAId="aId", teamBId="bId", teamAScore=None, teamBScore=2) ) - self.assertEqual("teamAScore must be type 'float' or 'int'.", str(context.exception)) + self.assertEqual( + "teamAScore must be type 'float' or 'int'.", str(context.exception) + ) def test_checkAllTypes_teamBScoreIsntTypeFloatOrInt_raisesException(self): with self.assertRaises(InvalidMatchupFormatException) as context: matchupValidation.checkAllTypes( Matchup(teamAId="aId", teamBId="bId", teamAScore=1, teamBScore=None) ) - self.assertEqual("teamBScore must be type 'float' or 'int'.", str(context.exception)) + self.assertEqual( + "teamBScore must be type 'float' or 'int'.", str(context.exception) + ) def test_checkAllTypes_matchupTypeIsntTypeMatchup_raisesException(self): with self.assertRaises(InvalidMatchupFormatException) as context: matchupValidation.checkAllTypes( - Matchup(teamAId="aId", teamBId="bId", teamAScore=1, teamBScore=2, matchupType=None) + Matchup( + teamAId="aId", + teamBId="bId", + teamAScore=1, + teamBScore=2, + matchupType=None, + ) ) - self.assertEqual("matchupType must be type 'MatchupType'.", str(context.exception)) + self.assertEqual( + "matchupType must be type 'MatchupType'.", str(context.exception) + ) def test_checkAllTypes_multiWeekMatchupIsntNoneOrTypeStr_raisesException(self): with self.assertRaises(InvalidMatchupFormatException) as context: @@ -101,4 +121,6 @@ def test_checkAllTypes_multiWeekMatchupIsntNoneOrTypeStr_raisesException(self): multiWeekMatchupId=1, ) ) - self.assertEqual("multiWeekMatchupId must be 'None' or type 'str'.", str(context.exception)) + self.assertEqual( + "multiWeekMatchupId must be 'None' or type 'str'.", str(context.exception) + ) diff --git a/test/test_validate/test_teamValidation.py b/test/test_validate/test_teamValidation.py index 3ae52fae..c88e3ada 100644 --- a/test/test_validate/test_teamValidation.py +++ b/test/test_validate/test_teamValidation.py @@ -19,4 +19,6 @@ def test_checkAllTypes_teamNameIsntTypeStr_raisesException(self): def test_checkAllTypes_divisionIdIsntTypeStrOrNone_raisesException(self): with self.assertRaises(InvalidTeamFormatException) as context: teamValidation.checkAllTypes(Team(ownerId="id", name="team", divisionId=1)) - self.assertEqual("divisionId must be 'None' or type 'str'.", str(context.exception)) + self.assertEqual( + "divisionId must be 'None' or type 'str'.", str(context.exception) + ) diff --git a/test/test_validate/test_weekValidation.py b/test/test_validate/test_weekValidation.py index a94f6019..18a0a3d1 100644 --- a/test/test_validate/test_weekValidation.py +++ b/test/test_validate/test_weekValidation.py @@ -8,9 +8,13 @@ class TestWeekValidation(unittest.TestCase): - def test_checkWeekHasAtLeastOneMatchup_weekDoesntHaveAtLeastOneMatchup_raisesException(self): + def test_checkWeekHasAtLeastOneMatchup_weekDoesntHaveAtLeastOneMatchup_raisesException( + self, + ): with self.assertRaises(InvalidWeekFormatException) as context: - weekValidation.checkWeekHasAtLeastOneMatchup(Week(weekNumber=1, matchups=list())) + weekValidation.checkWeekHasAtLeastOneMatchup( + Week(weekNumber=1, matchups=list()) + ) self.assertEqual("Week 1 must have at least 1 matchup.", str(context.exception)) def test_checkForDuplicateMatchups_duplicateMatchupInstances_raisesException(self): @@ -19,7 +23,9 @@ def test_checkForDuplicateMatchups_duplicateMatchupInstances_raisesException(sel weekValidation.checkForDuplicateMatchups( Week(weekNumber=1, matchups=[matchup, matchup]) ) - self.assertEqual("Matchups must all be unique instances.", str(context.exception)) + self.assertEqual( + "Matchups must all be unique instances.", str(context.exception) + ) def test_checkWeekDoesNotHaveMoreThanOneChampionshipMatchup_multipleChampionshipMatchups_raisesException( self, @@ -55,13 +61,19 @@ def test_checkWeekHasMatchupsWithNoDuplicateTeamIds_teamHasMultipleMatchupsInWee weekValidation.checkWeekHasMatchupsWithNoDuplicateTeamIds( Week(weekNumber=1, matchups=[matchup1, matchup2]) ) - self.assertEqual("Week 1 has matchups with duplicate team IDs.", str(context.exception)) + self.assertEqual( + "Week 1 has matchups with duplicate team IDs.", str(context.exception) + ) def test_checkWeekWithPlayoffOrChampionshipMatchupDoesNotHaveRegularSeasonMatchup_weekHasPlayoffMatchupAndRegularSeasonMatchup_raisesException( self, ): matchup1 = Matchup( - teamAId="a", teamBId="b", teamAScore=1, teamBScore=2, matchupType=MatchupType.PLAYOFF + teamAId="a", + teamBId="b", + teamAScore=1, + teamBScore=2, + matchupType=MatchupType.PLAYOFF, ) matchup2 = Matchup( teamAId="c", @@ -119,7 +131,8 @@ def test_checkMultiWeekMatchupsWithSameIdAreOnlyInOneMatchupPerWeek_weekHasSameM Week(weekNumber=1, matchups=[matchup1, matchup2]) ) self.assertEqual( - "Week 1 has the multi-week matchup ID '1' in multiple matchups.", str(context.exception) + "Week 1 has the multi-week matchup ID '1' in multiple matchups.", + str(context.exception), ) """ @@ -135,9 +148,13 @@ def test_checkAllTypes_weekMatchupsIsntTypeList_raisesException(self): # not given a list with self.assertRaises(InvalidWeekFormatException) as context: weekValidation.checkAllTypes(Week(weekNumber=1, matchups=None)) - self.assertEqual("matchups must be type 'list[Matchup]'.", str(context.exception)) + self.assertEqual( + "matchups must be type 'list[Matchup]'.", str(context.exception) + ) # given a list of non Matchup with self.assertRaises(InvalidWeekFormatException) as context: weekValidation.checkAllTypes(Week(weekNumber=1, matchups=["foo"])) - self.assertEqual("matchups must be type 'list[Matchup]'.", str(context.exception)) + self.assertEqual( + "matchups must be type 'list[Matchup]'.", str(context.exception) + ) diff --git a/test/test_validate/test_yearValidation.py b/test/test_validate/test_yearValidation.py index ba8f5435..6a37db1d 100644 --- a/test/test_validate/test_yearValidation.py +++ b/test/test_validate/test_yearValidation.py @@ -1,5 +1,4 @@ import unittest -from test.helper.prototypes import getNDefaultOwnersAndTeams from leeger.enum.MatchupType import MatchupType from leeger.exception.InvalidYearFormatException import InvalidYearFormatException @@ -10,6 +9,7 @@ from leeger.model.league.Week import Week from leeger.model.league.Year import Year from leeger.validate import yearValidation +from test.helper.prototypes import getNDefaultOwnersAndTeams class TestYearValidation(unittest.TestCase): @@ -18,7 +18,9 @@ def test_checkAtLeastOneWeekInYear_yearHasNoWeeks_raisesException(self): yearValidation.checkAtLeastOneWeekInYear( Year(yearNumber=2000, teams=list(), weeks=list()) ) - self.assertEqual("Year 2000 does not have at least 1 week.", str(context.exception)) + self.assertEqual( + "Year 2000 does not have at least 1 week.", str(context.exception) + ) def test_checkWeekNumberingInYear_yearDuplicateWeekNumbers_raisesException(self): week1 = Week(weekNumber=1, matchups=list()) @@ -28,7 +30,9 @@ def test_checkWeekNumberingInYear_yearDuplicateWeekNumbers_raisesException(self) yearValidation.checkWeekNumberingInYear( Year(yearNumber=2000, teams=list(), weeks=[week1, week1duplicate]) ) - self.assertEqual("Year 2000 has duplicate week numbers.", str(context.exception)) + self.assertEqual( + "Year 2000 has duplicate week numbers.", str(context.exception) + ) def test_checkWeekNumberingInYear_lowestWeekNumberIsNotOne_raisesException(self): week2 = Week(weekNumber=2, matchups=list()) @@ -37,7 +41,9 @@ def test_checkWeekNumberingInYear_lowestWeekNumberIsNotOne_raisesException(self) yearValidation.checkWeekNumberingInYear( Year(yearNumber=2000, teams=list(), weeks=[week2]) ) - self.assertEqual("First week in year 2000 must be 1, not 2.", str(context.exception)) + self.assertEqual( + "First week in year 2000 must be 1, not 2.", str(context.exception) + ) def test_checkWeekNumberingInYear_weekNumbersNotOneThroughN_raisesException(self): week1 = Week(weekNumber=1, matchups=list()) @@ -50,7 +56,8 @@ def test_checkWeekNumberingInYear_weekNumbersNotOneThroughN_raisesException(self Year(yearNumber=2000, teams=list(), weeks=[week1, week2, week4]) ) # no week 3 self.assertEqual( - "Year 2000 does not have week numbers in order (1-n).", str(context.exception) + "Year 2000 does not have week numbers in order (1-n).", + str(context.exception), ) with self.assertRaises(InvalidYearFormatException) as context: @@ -58,12 +65,19 @@ def test_checkWeekNumberingInYear_weekNumbersNotOneThroughN_raisesException(self Year(yearNumber=2000, teams=list(), weeks=[week1, week2, week4, week3]) ) # weeks not in order self.assertEqual( - "Year 2000 does not have week numbers in order (1-n).", str(context.exception) + "Year 2000 does not have week numbers in order (1-n).", + str(context.exception), ) - def test_checkPlayoffWeekOrderingInYear_nonPlayoffWeekAfterPlayoffWeek_raisesException(self): + def test_checkPlayoffWeekOrderingInYear_nonPlayoffWeekAfterPlayoffWeek_raisesException( + self, + ): matchup1 = Matchup( - teamAId="", teamBId="", teamAScore=0, teamBScore=0, matchupType=MatchupType.PLAYOFF + teamAId="", + teamBId="", + teamAScore=0, + teamBScore=0, + matchupType=MatchupType.PLAYOFF, ) week1 = Week(weekNumber=1, matchups=[matchup1]) week2 = Week(weekNumber=2, matchups=list()) @@ -73,7 +87,8 @@ def test_checkPlayoffWeekOrderingInYear_nonPlayoffWeekAfterPlayoffWeek_raisesExc Year(yearNumber=2000, teams=list(), weeks=[week1, week2]) ) self.assertEqual( - "Year 2000 has a non-playoff week after a playoff week.", str(context.exception) + "Year 2000 has a non-playoff week after a playoff week.", + str(context.exception), ) def test_checkPlayoffWeekOrderingInYear_nonChampionshipWeekAfterChampionshipWeek_raisesException( @@ -117,7 +132,9 @@ def test_checkAtLeastTwoTeamsInYear_yearHasLessThanTwoTeams_raisesException(self ) self.assertEqual("Year 2000 needs at least 2 teams.", str(context.exception)) - def test_checkGivenYearHasValidYearNumber_yearNumberIsntInValidRange_raisesException(self): + def test_checkGivenYearHasValidYearNumber_yearNumberIsntInValidRange_raisesException( + self, + ): week1 = Week(weekNumber=1, matchups=list()) team1 = Team(ownerId="1", name="1") team2 = Team(ownerId="2", name="2") @@ -143,7 +160,9 @@ def test_checkTeamOwnerIdsInYear_teamsHaveDuplicateOwnerIds_raisesException(self yearValidation.checkTeamOwnerIdsInYear( Year(yearNumber=2000, teams=[team1, team2], weeks=[week1]) ) - self.assertEqual("Year 2000 has teams with the same owner IDs.", str(context.exception)) + self.assertEqual( + "Year 2000 has teams with the same owner IDs.", str(context.exception) + ) def test_checkTeamNamesInYear_teamsInAYearHaveDuplicateNames_raisesException(self): owner1 = Owner(name="1") @@ -156,7 +175,9 @@ def test_checkTeamNamesInYear_teamsInAYearHaveDuplicateNames_raisesException(sel yearValidation.checkTeamNamesInYear( Year(yearNumber=2000, teams=[team1, team2], weeks=list()) ) - self.assertEqual("Year 2000 has teams with duplicate names.", str(context.exception)) + self.assertEqual( + "Year 2000 has teams with duplicate names.", str(context.exception) + ) def test_checkTeamNamesInYear_teamsInAYearHaveSimilarNames_raisesException(self): # SPACE DIFFERENCE @@ -170,7 +191,9 @@ def test_checkTeamNamesInYear_teamsInAYearHaveSimilarNames_raisesException(self) yearValidation.checkTeamNamesInYear( Year(yearNumber=2000, teams=[team1, team2], weeks=list()) ) - self.assertEqual("Year 2000 has teams with very similar names.", str(context.exception)) + self.assertEqual( + "Year 2000 has teams with very similar names.", str(context.exception) + ) # TAB DIFFERENCE team1 = Team(ownerId=owner1.id, name="1\t") # has a tab in name @@ -180,7 +203,9 @@ def test_checkTeamNamesInYear_teamsInAYearHaveSimilarNames_raisesException(self) yearValidation.checkTeamNamesInYear( Year(yearNumber=2000, teams=[team1, team2], weeks=list()) ) - self.assertEqual("Year 2000 has teams with very similar names.", str(context.exception)) + self.assertEqual( + "Year 2000 has teams with very similar names.", str(context.exception) + ) # NEWLINE DIFFERENCE team1 = Team(ownerId=owner1.id, name="1\n") # has a newline in name @@ -190,7 +215,9 @@ def test_checkTeamNamesInYear_teamsInAYearHaveSimilarNames_raisesException(self) yearValidation.checkTeamNamesInYear( Year(yearNumber=2000, teams=[team1, team2], weeks=list()) ) - self.assertEqual("Year 2000 has teams with very similar names.", str(context.exception)) + self.assertEqual( + "Year 2000 has teams with very similar names.", str(context.exception) + ) # CASE DIFFERENCE team1 = Team(ownerId=owner1.id, name="A") @@ -200,28 +227,48 @@ def test_checkTeamNamesInYear_teamsInAYearHaveSimilarNames_raisesException(self) yearValidation.checkTeamNamesInYear( Year(yearNumber=2000, teams=[team1, team2], weeks=list()) ) - self.assertEqual("Year 2000 has teams with very similar names.", str(context.exception)) + self.assertEqual( + "Year 2000 has teams with very similar names.", str(context.exception) + ) - def test_checkDivisionNamesInYear_divisionsInAYearHaveDuplicateNames_raisesException(self): + def test_checkDivisionNamesInYear_divisionsInAYearHaveDuplicateNames_raisesException( + self, + ): division1 = Division(name="div") division2 = Division(name="div") with self.assertRaises(InvalidYearFormatException) as context: yearValidation.checkDivisionNamesInYear( - Year(yearNumber=2000, teams=list(), weeks=list(), divisions=[division1, division2]) + Year( + yearNumber=2000, + teams=list(), + weeks=list(), + divisions=[division1, division2], + ) ) - self.assertEqual("Year 2000 has divisions with duplicate names.", str(context.exception)) + self.assertEqual( + "Year 2000 has divisions with duplicate names.", str(context.exception) + ) - def test_checkDivisionNamesInYear_divisionsInAYearHaveSimilarNames_raisesException(self): + def test_checkDivisionNamesInYear_divisionsInAYearHaveSimilarNames_raisesException( + self, + ): # SPACE DIFFERENCE division1 = Division(name="div ") # has a space in name division2 = Division(name="div") with self.assertRaises(InvalidYearFormatException) as context: yearValidation.checkDivisionNamesInYear( - Year(yearNumber=2000, teams=list(), weeks=list(), divisions=[division1, division2]) + Year( + yearNumber=2000, + teams=list(), + weeks=list(), + divisions=[division1, division2], + ) ) - self.assertEqual("Year 2000 has divisions with very similar names.", str(context.exception)) + self.assertEqual( + "Year 2000 has divisions with very similar names.", str(context.exception) + ) # TAB DIFFERENCE division1 = Division(name="div\t") # has a tab in name @@ -229,9 +276,16 @@ def test_checkDivisionNamesInYear_divisionsInAYearHaveSimilarNames_raisesExcepti with self.assertRaises(InvalidYearFormatException) as context: yearValidation.checkDivisionNamesInYear( - Year(yearNumber=2000, teams=list(), weeks=list(), divisions=[division1, division2]) + Year( + yearNumber=2000, + teams=list(), + weeks=list(), + divisions=[division1, division2], + ) ) - self.assertEqual("Year 2000 has divisions with very similar names.", str(context.exception)) + self.assertEqual( + "Year 2000 has divisions with very similar names.", str(context.exception) + ) # NEWLINE DIFFERENCE division1 = Division(name="div\t") # has a newline in name @@ -239,9 +293,16 @@ def test_checkDivisionNamesInYear_divisionsInAYearHaveSimilarNames_raisesExcepti with self.assertRaises(InvalidYearFormatException) as context: yearValidation.checkDivisionNamesInYear( - Year(yearNumber=2000, teams=list(), weeks=list(), divisions=[division1, division2]) + Year( + yearNumber=2000, + teams=list(), + weeks=list(), + divisions=[division1, division2], + ) ) - self.assertEqual("Year 2000 has divisions with very similar names.", str(context.exception)) + self.assertEqual( + "Year 2000 has divisions with very similar names.", str(context.exception) + ) # CASE DIFFERENCE division1 = Division(name="DIV") @@ -249,9 +310,16 @@ def test_checkDivisionNamesInYear_divisionsInAYearHaveSimilarNames_raisesExcepti with self.assertRaises(InvalidYearFormatException) as context: yearValidation.checkDivisionNamesInYear( - Year(yearNumber=2000, teams=list(), weeks=list(), divisions=[division1, division2]) + Year( + yearNumber=2000, + teams=list(), + weeks=list(), + divisions=[division1, division2], + ) ) - self.assertEqual("Year 2000 has divisions with very similar names.", str(context.exception)) + self.assertEqual( + "Year 2000 has divisions with very similar names.", str(context.exception) + ) def test_checkForDuplicateTeams_duplicateTeams_raisesException(self): _, teams = getNDefaultOwnersAndTeams(1) @@ -273,13 +341,24 @@ def test_checkForDuplicateDivisions_duplicateDivisions_raisesException(self): division = Division(name="div") with self.assertRaises(InvalidYearFormatException) as context: yearValidation.checkForDuplicateDivisions( - Year(yearNumber=2000, teams=list(), weeks=list(), divisions=[division, division]) + Year( + yearNumber=2000, + teams=list(), + weeks=list(), + divisions=[division, division], + ) ) - self.assertEqual("Divisions must all be unique instances.", str(context.exception)) + self.assertEqual( + "Divisions must all be unique instances.", str(context.exception) + ) - def test_checkEveryTeamInYearIsInAMatchup_teamNotInAnyMatchups_raisesException(self): + def test_checkEveryTeamInYearIsInAMatchup_teamNotInAnyMatchups_raisesException( + self, + ): _, teams = getNDefaultOwnersAndTeams(3) - matchup = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week = Week(weekNumber=1, matchups=[matchup]) with self.assertRaises(InvalidYearFormatException) as context: yearValidation.checkEveryTeamInYearIsInAMatchup( @@ -302,7 +381,9 @@ def test_checkMultiWeekMatchupsAreInConsecutiveWeeks_multiWeekMatchupIdUsedInNon multiWeekMatchupId="1", ) week1 = Week(weekNumber=1, matchups=[matchup1]) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week2 = Week(weekNumber=2, matchups=[matchup2]) matchup3 = Matchup( teamAId=teams[0].id, @@ -369,9 +450,13 @@ def test_checkMultiWeekMatchupsAreInMoreThanOneWeekOrAreNotTheMostRecentWeek_mul multiWeekMatchupId="1", ) week1 = Week(weekNumber=1, matchups=[matchup1]) - matchup2 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup2 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week2 = Week(weekNumber=2, matchups=[matchup2]) - matchup3 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup3 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week3 = Week(weekNumber=3, matchups=[matchup3]) with self.assertRaises(InvalidYearFormatException) as context: yearValidation.checkMultiWeekMatchupsAreInMoreThanOneWeekOrAreNotTheMostRecentWeek( @@ -386,7 +471,9 @@ def test_checkMultiWeekMatchupsAreInMoreThanOneWeekOrAreNotTheMostRecentWeek_mul self, ): _, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) week1 = Week(weekNumber=1, matchups=[matchup1]) matchup2 = Matchup( teamAId=teams[0].id, @@ -404,7 +491,9 @@ def test_checkMultiWeekMatchupsAreInMoreThanOneWeekOrAreNotTheMostRecentWeek_mul self, ): _, teams = getNDefaultOwnersAndTeams(3) - matchup1 = Matchup(teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2) + matchup1 = Matchup( + teamAId=teams[0].id, teamBId=teams[1].id, teamAScore=1, teamBScore=2 + ) matchup2 = Matchup( teamAId=teams[0].id, teamBId=teams[1].id, @@ -640,7 +729,9 @@ def test_checkEitherAllTeamsAreInADivisionOrNoTeamsAreInADivision(self): year = Year(yearNumber=2000, teams=[team1, team2], weeks=list()) with self.assertRaises(InvalidYearFormatException) as context: - yearValidation.checkEitherAllTeamsAreInADivisionOrNoTeamsAreInADivision(year) + yearValidation.checkEitherAllTeamsAreInADivisionOrNoTeamsAreInADivision( + year + ) self.assertEqual( f"Only some teams in Year 2000 have a Division ID.", str(context.exception) ) @@ -653,7 +744,10 @@ def test_checkDivisionIdsMatchTeamDivisionIds(self): team2 = Team(ownerId="", name="", divisionId=division2.id) year = Year( - yearNumber=2000, teams=[team1, team2], weeks=list(), divisions=[division1, division2] + yearNumber=2000, + teams=[team1, team2], + weeks=list(), + divisions=[division1, division2], ) yearValidation.checkDivisionIdsMatchTeamDivisionIds(year) @@ -665,7 +759,10 @@ def test_checkDivisionIdsMatchTeamDivisionIds(self): team2 = Team(ownerId="", name="", divisionId=division1.id) year = Year( - yearNumber=2000, teams=[team1, team2], weeks=list(), divisions=[division1, division2] + yearNumber=2000, + teams=[team1, team2], + weeks=list(), + divisions=[division1, division2], ) with self.assertRaises(InvalidYearFormatException) as context: @@ -680,7 +777,9 @@ def test_checkDivisionIdsMatchTeamDivisionIds(self): team1 = Team(ownerId="", name="", divisionId=division1.id) team2 = Team(ownerId="", name="", divisionId="d2") - year = Year(yearNumber=2000, teams=[team1, team2], weeks=list(), divisions=[division1]) + year = Year( + yearNumber=2000, teams=[team1, team2], weeks=list(), divisions=[division1] + ) with self.assertRaises(InvalidYearFormatException) as context: yearValidation.checkDivisionIdsMatchTeamDivisionIds(year) @@ -696,7 +795,10 @@ def test_checkDivisionIdsMatchTeamDivisionIds(self): team2 = Team(ownerId="", name="") year = Year( - yearNumber=2000, teams=[team1, team2], weeks=list(), divisions=[division1, division2] + yearNumber=2000, + teams=[team1, team2], + weeks=list(), + divisions=[division1, division2], ) with self.assertRaises(InvalidYearFormatException) as context: @@ -710,7 +812,9 @@ def test_checkDivisionIdsMatchTeamDivisionIds(self): team1 = Team(ownerId="", name="", divisionId="a") team2 = Team(ownerId="", name="", divisionId="b") - year = Year(yearNumber=2000, teams=[team1, team2], weeks=list(), divisions=list()) + year = Year( + yearNumber=2000, teams=[team1, team2], weeks=list(), divisions=list() + ) with self.assertRaises(InvalidYearFormatException) as context: yearValidation.checkDivisionIdsMatchTeamDivisionIds(year) @@ -726,7 +830,10 @@ def test_checkDivisionIdsMatchTeamDivisionIds(self): team2 = Team(ownerId="", name="", divisionId="d4") year = Year( - yearNumber=2000, teams=[team1, team2], weeks=list(), divisions=[division1, division2] + yearNumber=2000, + teams=[team1, team2], + weeks=list(), + divisions=[division1, division2], ) with self.assertRaises(InvalidYearFormatException) as context: @@ -744,7 +851,10 @@ def test_checkDivisionsHaveNoDuplicateIds(self): team2 = Team(ownerId="", name="", divisionId=division2.id) year = Year( - yearNumber=2000, teams=[team1, team2], weeks=list(), divisions=[division1, division2] + yearNumber=2000, + teams=[team1, team2], + weeks=list(), + divisions=[division1, division2], ) yearValidation.checkDivisionsHaveNoDuplicateIds(year) @@ -767,7 +877,9 @@ def test_checkDivisionsHaveNoDuplicateIds(self): with self.assertRaises(InvalidYearFormatException) as context: yearValidation.checkDivisionsHaveNoDuplicateIds(year) - self.assertEqual(f"Year 2000 has duplicate division IDs.", str(context.exception)) + self.assertEqual( + f"Year 2000 has duplicate division IDs.", str(context.exception) + ) """ TYPE CHECK TESTS @@ -775,29 +887,39 @@ def test_checkDivisionsHaveNoDuplicateIds(self): def test_checkAllTypes_yearNumberIsntTypeInt_raisesException(self): with self.assertRaises(InvalidYearFormatException) as context: - yearValidation.checkAllTypes(Year(yearNumber=None, teams=list(), weeks=list())) + yearValidation.checkAllTypes( + Year(yearNumber=None, teams=list(), weeks=list()) + ) self.assertEqual("yearNumber must be type 'int'.", str(context.exception)) def test_checkAllTypes_yearTeamsIsntTypeList_raisesException(self): # not given a list with self.assertRaises(InvalidYearFormatException) as context: - yearValidation.checkAllTypes(Year(yearNumber=2000, teams=None, weeks=list())) + yearValidation.checkAllTypes( + Year(yearNumber=2000, teams=None, weeks=list()) + ) self.assertEqual("teams must be type 'list[Team]'.", str(context.exception)) # given a list of non Team with self.assertRaises(InvalidYearFormatException) as context: - yearValidation.checkAllTypes(Year(yearNumber=2000, teams=["foo"], weeks=list())) + yearValidation.checkAllTypes( + Year(yearNumber=2000, teams=["foo"], weeks=list()) + ) self.assertEqual("teams must be type 'list[Team]'.", str(context.exception)) def test_checkAllTypes_yearWeeksIsntTypeList_raisesException(self): # not given a list with self.assertRaises(InvalidYearFormatException) as context: - yearValidation.checkAllTypes(Year(yearNumber=2000, teams=list(), weeks=None)) + yearValidation.checkAllTypes( + Year(yearNumber=2000, teams=list(), weeks=None) + ) self.assertEqual("weeks must be type 'list[Week]'.", str(context.exception)) # given a list of non Week with self.assertRaises(InvalidYearFormatException) as context: - yearValidation.checkAllTypes(Year(yearNumber=2000, teams=list(), weeks=["foo"])) + yearValidation.checkAllTypes( + Year(yearNumber=2000, teams=list(), weeks=["foo"]) + ) self.assertEqual("weeks must be type 'list[Week]'.", str(context.exception)) def test_checkAllTypes_divisionsIsntTypeList_raisesException(self): @@ -806,18 +928,24 @@ def test_checkAllTypes_divisionsIsntTypeList_raisesException(self): yearValidation.checkAllTypes( Year(yearNumber=2000, teams=list(), weeks=list(), divisions="") ) - self.assertEqual("divisions must be type 'list[Division]'.", str(context.exception)) + self.assertEqual( + "divisions must be type 'list[Division]'.", str(context.exception) + ) # given a list of non Division with self.assertRaises(InvalidYearFormatException) as context: yearValidation.checkAllTypes( Year(yearNumber=2000, teams=list(), weeks=list(), divisions=["foo"]) ) - self.assertEqual("divisions must be type 'list[Division]'.", str(context.exception)) + self.assertEqual( + "divisions must be type 'list[Division]'.", str(context.exception) + ) def test_checkAllTypes_yearSettingsIsntTypeYearSettings_raisesException(self): with self.assertRaises(InvalidYearFormatException) as context: year = Year(yearNumber=2000, teams=list(), weeks=list()) year.yearSettings = None yearValidation.checkAllTypes(year) - self.assertEqual("yearSettings must be type 'YearSettings'.", str(context.exception)) + self.assertEqual( + "yearSettings must be type 'YearSettings'.", str(context.exception) + )