Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/spotifyaio/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ class ProductType(StrEnum):
class BaseUserProfile(DataClassORJSONMixin):
"""Base user profile model."""

display_name: str
display_name: str | None
user_id: str = field(metadata=field_options(alias="id"))
images: list[Image]
object_type: str = field(metadata=field_options(alias="type"))
Expand Down
16 changes: 16 additions & 0 deletions tests/test_spotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,22 @@ async def test_get_current_user(
)


async def test_get_current_user_without_display_name(
responses: aiointercept,
authenticated_client: SpotifyClient,
) -> None:
"""Test retrieving current user without a display name."""
body = json.loads(load_fixture("current_user.json"))
body["display_name"] = None
responses.get(
f"{SPOTIFY_URL}/v1/me",
status=200,
body=json.dumps(body),
)
response = await authenticated_client.get_current_user()
assert response.display_name is None


async def test_get_current_user_without_deprecated_fields(
responses: aiointercept,
authenticated_client: SpotifyClient,
Expand Down
Loading