Skip to content

Commit

Permalink
Fixed issue with career page with players without avatar (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin Porchet authored Feb 13, 2023
1 parent 1f4b101 commit cc11a84
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions overfastapi/models/players.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ class HeroesStats(BaseModel):

class PlayerSummary(BaseModel):
username: str = Field(..., description="Username of the player", example="TeKrop")
avatar: HttpUrl = Field(
...,
description="URL of the player's avatar",
avatar: HttpUrl | None = Field(
None,
description="URL of the player's avatar. Can be null if couldn't retrieve any",
example="https://d15f34w2p8l1cc.cloudfront.net/overwatch/daeddd96e58a2150afa6ffc3c5503ae7f96afc2e22899210d444f45dee508c6c.png",
)
title: str = Field(None, description="Title of the player if any")
Expand Down
2 changes: 1 addition & 1 deletion overfastapi/parsers/player_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def __get_summary(self) -> dict:
"avatar": (
summary_div.find(
"img", class_="Profile-player--portrait", recursive=False
)["src"]
).get("src")
),
"title": (
profile_div.find(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "overfast-api"
version = "2.7.0"
version = "2.7.1"
description = "Overwatch API giving data about heroes, maps, and players statistics."
authors = ["TeKrop <tekrop@gmail.com>"]
license = "MIT"
Expand Down
6 changes: 3 additions & 3 deletions tests/parsers/test_player_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def test_player_parser_parsing_error_attribute_error(player_html_data: str):
def test_player_parser_parsing_error_key_error(player_html_data: str):
with pytest.raises(ParserParsingError) as error:
player_key_error = re.sub(
'class="Profile-player--portrait" src="[^"]*"',
'class="Profile-player--portrait"',
'class="Profile-playerSummary--endorsement" src="[^"]*"',
'class="Profile-playerSummary--endorsement"',
player_html_data,
)
parser = PlayerParser(player_id="TeKrop-2217")
Expand All @@ -88,7 +88,7 @@ def test_player_parser_parsing_error_key_error(player_html_data: str):
def test_player_parser_parsing_error_type_error(player_html_data: str):
with pytest.raises(ParserParsingError) as error:
player_type_error = player_html_data.replace(
'class="Profile-player--portrait"', ""
'class="Profile-playerSummary--endorsement"', ""
)
parser = PlayerParser(player_id="TeKrop-2217")
with patch(
Expand Down

0 comments on commit cc11a84

Please sign in to comment.