Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_position_converter():
positions = ["Goalkeeper", "Defender", "Midfielder", "Forward"]
converted = [position_converter(position) for position in range(1, 5)]
assert positions == converted
def get_starters(players, position):
"""Helper function that returns starting players in a given position."""
starters = [player for player in players if position_converter(
player.element_type) == position]
return starters
"forward": {
"H": [1, ..., 2],
"A": [6, ..., 1]
}
},
...
}
:rtype: dict
"""
players = await self.get_players(
include_summary=True, return_json=True)
points_against = {}
for player in players:
position = position_converter(player["element_type"]).lower()
for fixture in player["history"]:
if fixture["minutes"] == 0:
continue
points = fixture["total_points"]
opponent = team_converter(fixture["opponent_team"])
location = "H" if fixture["was_home"] else "A"
points_against.setdefault(
opponent,
{
"all": {"H": [], "A": []},
"goalkeeper": {"H": [], "A": []},
"defender": {"H": [], "A": []},
"midfielder": {"H": [], "A": []},