Skip to content

Commit

Permalink
Make available_markets optional (#323)
Browse files Browse the repository at this point in the history
  • Loading branch information
felix-hilden committed Apr 17, 2024
1 parent 40ba9eb commit 98d4048
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
8 changes: 8 additions & 0 deletions docs/src/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@

Release notes
=============
Unreleased
-----------
Fixed
*****
- Make ``available_markets`` of :class:`Show <model.Show>`,
:class:`LocalAlbum <model.LocalAlbum>` and
:class:`LocalTrack <model.LocalTrack>` optional (:issue:`323`)

5.4.0 (2024-02-27)
------------------
Fixed
Expand Down
6 changes: 4 additions & 2 deletions src/tekore/_model/local.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from typing import List, Literal, Union

from pydantic import Field

from .serialise import Model


Expand All @@ -18,7 +20,7 @@ class LocalAlbum(LocalItem):

album_type: None
artists: List[None]
available_markets: List[None]
available_markets: List[None] = Field(default_factory=list)
external_urls: dict
images: List[None]
release_date: None
Expand All @@ -42,7 +44,7 @@ class LocalTrack(LocalItem):

album: LocalAlbum
artists: List[LocalArtist]
available_markets: List[None]
available_markets: List[None] = Field(default_factory=list)
disc_number: int
duration_ms: Union[int, dict]
explicit: bool
Expand Down
4 changes: 3 additions & 1 deletion src/tekore/_model/show/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from typing import List, Optional, Union

from pydantic import Field

from ..base import Item
from ..member import Copyright, Image

Expand All @@ -11,7 +13,7 @@ class Show(Item):
:attr:`publisher` being an object is undocumented.
"""

available_markets: List[str]
available_markets: List[str] = Field(default_factory=list)
copyrights: List[Copyright]
description: str
explicit: bool
Expand Down
8 changes: 4 additions & 4 deletions tests/client/playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ async def test_async_playlist_items_fields_returns_object(self, app_aclient):

def test_playlist_podcast_no_market_returns_none(self, app_client):
playlist = app_client.playlist(playlist_special)
assert playlist.tracks.items[0].track is None
assert playlist.tracks.items[0].track.episode is True

def test_playlist_podcast_with_market_returned(self, app_client):
playlist = app_client.playlist(playlist_special, market="FI")
assert playlist.tracks.items[0].track.episode is True

def test_playlist_with_podcast_as_tracks_no_market_returns_object(self, app_client):
playlist = app_client.playlist(playlist_special, as_tracks=True)
assert playlist["tracks"]["items"][0]["track"] is None
assert playlist["tracks"]["items"][0]["track"]["track"] is True

def test_playlist_with_podcast_as_tracks_with_market_returns_object(
self, app_client
Expand All @@ -100,7 +100,7 @@ def test_playlist_as_tracks_takes_iterable(self, app_client):

def test_playlist_items_podcast_no_market_returns_none(self, app_client):
items = app_client.playlist_items(playlist_special)
assert items.items[0].track is None
assert items.items[0].track.episode is True

def test_playlist_items_podcast_with_market_returned(self, app_client):
items = app_client.playlist_items(playlist_special, market="FI")
Expand All @@ -110,7 +110,7 @@ def test_playlist_items_with_podcast_as_tracks_no_market_returns_object(
self, app_client
):
items = app_client.playlist_items(playlist_special, as_tracks=True)
assert items["items"][0]["track"] is None
assert items["items"][0]["track"]["track"] is True

def test_playlist_items_with_podcast_as_tracks_with_market_returns_object(
self, app_client
Expand Down

0 comments on commit 98d4048

Please sign in to comment.