def test_league_added_to_user(): commissioner = get_commissioner() user_repo = get_user_repo() league_repo = get_league_repo() user_league_repo = get_user_league_repo() league_roster_repo = get_league_roster_repo() league_config_repo = get_league_config_repo() publisher = VirtualPubSubPublisher("test_project") command_executor = CreateLeagueCommandExecutor(user_repo, league_repo, user_league_repo, league_roster_repo, league_config_repo, publisher) command = CreateLeagueCommand(commissioner_id=commissioner.id, name="Test League", private=False) result = command_executor.execute(command) user_league = user_league_repo.get(commissioner.id, result.league.id) expected = result.league.id actual = user_league.id are_equal(expected, actual)
def test_league_preview_has_matchup(): commissioner = get_commissioner() user_repo = get_user_repo() league_repo = get_league_repo() user_league_repo = get_user_league_repo() league_roster_repo = get_league_roster_repo() league_config_repo = get_league_config_repo() publisher = VirtualPubSubPublisher("test_project") command_executor = CreateLeagueCommandExecutor(user_repo, league_repo, user_league_repo, league_roster_repo, league_config_repo, publisher) command = CreateLeagueCommand(commissioner_id=commissioner.id, name="Test League", private=False) result = command_executor.execute(command) user_league = user_league_repo.get(commissioner.id, result.league.id) user_roster = league_roster_repo.get(result.league.id, commissioner.id) expected = user_roster.name actual = user_league.matchup.home.name assert expected is not None are_equal(expected, actual)
async def create_league( request: Request, command: CreateLeagueCommand, command_executor: CreateLeagueCommandExecutor = Depends( create_league_command_executor)): uid = request.state.uid command.commissioner_id = uid return command_executor.execute(command)
def test_positions_config_initialized(): commissioner = get_commissioner() user_repo = get_user_repo() league_repo = get_league_repo() user_league_repo = get_user_league_repo() league_roster_repo = get_league_roster_repo() league_config_repo = get_league_config_repo() publisher = VirtualPubSubPublisher("test_project") command_executor = CreateLeagueCommandExecutor(user_repo, league_repo, user_league_repo, league_roster_repo, league_config_repo, publisher) command = CreateLeagueCommand(commissioner_id=commissioner.id, name="Test League", private=False) result = command_executor.execute(command) config = league_config_repo.get_positions_config(result.league.id) assert config is not None