def setUp(self):
        self.player_1 = Player("*****@*****.**", "password1", "John", "Smith", "Hopp Suisse")

        self.player_team_1 = PlayerTeam(self.player_1, "France")
        self.player_team_1.group_info = {
            "played": 1,
            "won": 0,
            "drawn": 1,
            "lost": 0,
            "for": 2,
            "against": 2,
            "difference": 0,
            "points": 1,
            "rank": None
        }
        self.player_team_2 = PlayerTeam(self.player_1, "Germany")
        self.player_team_2.group_info = {
            "played": 1,
            "won": 0,
            "drawn": 1,
            "lost": 0,
            "for": 2,
            "against": 2,
            "difference": 0,
            "points": 1,
            "rank": None
        }
        self.player_team_3 = PlayerTeam(self.player_1, "Hungary")
        self.player_team_3.group_info = {
            "played": 1,
            "won": 0,
            "drawn": 0,
            "lost": 1,
            "for": 1,
            "against": 3,
            "difference": -2,
            "points": 0,
            "rank": None
        }
        self.player_team_4 = PlayerTeam(self.player_1, "Portugal")
        self.player_team_4.group_info = {
            "played": 1,
            "won": 1,
            "drawn": 0,
            "lost": 0,
            "for": 3,
            "against": 1,
            "difference": 2,
            "points": 3,
            "rank": None
        }

        self.group_1 = PlayerGroup(self.player_1, "F")
        self.group_1.player_teams = [self.player_team_1, self.player_team_2, self.player_team_3, self.player_team_4]
Ejemplo n.º 2
0
    def setUp(self):
        self.player_1 = Player("*****@*****.**", "password1", "John", "Smith", "Hopp Suisse")
        self.team_1 = Team("Germany")

        self.player_team_1 = PlayerTeam(self.player_1, self.team_1)

        self.group_info = {
            "played": 0,
            "won": 0,
            "drawn": 0,
            "lost": 0,
            "for": 0,
            "against": 0,
            "difference": 0,
            "points": 0,
            "rank": None
        }
def player_teams(player):
    player_teams = []

    sql = "SELECT * FROM player_teams WHERE player_id = %s"
    values = [player.id]
    results = run_sql(sql, values)

    for row in results:
        team = team_repository.select(row['team_id'])
        group_info = {
            "played": row['matches_played'],
            "won": row['won'],
            "drawn": row['drawn'],
            "lost": row['lost'],
            "for": row['goals_for'],
            "against": row['goals_against'],
            "difference": row['goal_difference'],
            "points": row['points'],
            "rank": row['group_rank']
        }
        player_team = PlayerTeam(player, team, row['id'])
        player_team.group_info = group_info
        player_teams.append(player_team)
    return player_teams
Ejemplo n.º 4
0
def setup_new_player(player):
    add_to_overall_league(player)

    # Player Teams
    for team in team_repository.select_all():
        player_team_repository.save(PlayerTeam(player, team))

    # Player Groups
    for group in group_repository.select_all():
        player_teams = []
        for team in group.teams:
            player_teams.append(
                player_team_repository.select_by_player_and_team(player, team))
        player_group_repository.save(
            PlayerGroup(player, group.name, player_teams))

    # Predictions
    for match in match_repository.select_all():
        home_player_team = player_team_repository.select_by_player_and_team(
            player, match.team_1)
        away_player_team = player_team_repository.select_by_player_and_team(
            player, match.team_2)
        prediction_repository.save(
            Prediction(player, match, home_player_team, away_player_team))
Ejemplo n.º 5
0
def select_by_player_and_team(player, team):
    player_team = None

    sql = "SELECT * FROM player_teams WHERE player_id = %s AND team_id = %s"
    values = [player.id, team.id]
    result = run_sql(sql, values)[0]

    if result is not None:
        player = player_repository.select(result['player_id'])
        team = team_repository.select(result['team_id'])
        group_info = {
            "played": result['matches_played'],
            "won": result['won'],
            "drawn": result['drawn'],
            "lost": result['lost'],
            "for": result['goals_for'],
            "against": result['goals_against'],
            "difference": result['goal_difference'],
            "points": result['points'],
            "rank": result['group_rank']
        }
        player_team = PlayerTeam(player, team, result['id'])
        player_team.group_info = group_info
    return player_team
Ejemplo n.º 6
0
csv_file.close()

# Leagues
league_1 = League("Overall")
league_1.join_code = "0000-0000"
league_repository.save(league_1)

# Player Leagues
player_league_1 = PlayerLeague(league_1, player_1)
player_league_repository.save(player_league_1)
player_league_2 = PlayerLeague(league_1, player_2)
player_league_repository.save(player_league_2)

# Player Teams
for team in team_repository.select_all():
    player_team_repository.save(PlayerTeam(player_1, team))

# Player Groups
for group in group_repository.select_all():
    player_teams = []
    for team in group.teams:
        player_teams.append(
            player_team_repository.select_by_player_and_team(player_1, team))
    player_group_repository.save(
        PlayerGroup(player_1, group.name, player_teams))

# Predictions
for match in match_repository.select_all():
    home_player_team = player_team_repository.select_by_player_and_team(
        player_1, match.team_1)
    away_player_team = player_team_repository.select_by_player_and_team(