diff --git a/mlbstatsapi/models/awards/attributes.py b/mlbstatsapi/models/awards/attributes.py index 2e38fdad..02cd9611 100644 --- a/mlbstatsapi/models/awards/attributes.py +++ b/mlbstatsapi/models/awards/attributes.py @@ -18,8 +18,9 @@ class Award(MLBBaseModel): Date of when award was given. season : str Season award is for/from. - team : Team - Team award was to / Player is from. + team : Team, optional + Team award was to / Player is from. None when MLB sends no + team, e.g. Hall of Fame executives and pioneers. player : Person Person award is for. votes : int @@ -31,7 +32,7 @@ class Award(MLBBaseModel): name: str date: str season: str - team: Team + team: Optional[Team] = None player: Person votes: Optional[int] = None notes: Optional[str] = None diff --git a/tests/parsers/test_awards_parser.py b/tests/parsers/test_awards_parser.py index 0a3da9c4..0e0a8b34 100644 --- a/tests/parsers/test_awards_parser.py +++ b/tests/parsers/test_awards_parser.py @@ -21,3 +21,20 @@ def test_parse_awards(): assert awards == [Award(**AWARD_PAYLOAD)] assert awards[0].player.full_name == "Aaron Judge" + + +def test_parse_awards_without_team(): + """Recipients such as Hall of Fame executives come back without a team.""" + payload = { + "id": "MLBHOF", + "name": "Hall Of Fame", + "date": "2021-12-05", + "season": "2021", + "player": {"id": 650067, "link": "/api/v1/people/650067", "nameFirstLast": "Buck O'Neil"}, + } + + awards = parse_awards({"awards": [AWARD_PAYLOAD, payload]}) + + assert len(awards) == 2 + assert awards[1].team is None + assert awards[1].player.id == 650067