Skip to content

Commit

Permalink
Add test case for uncovered
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsayre committed Jan 3, 2025
1 parent ba26d59 commit 83eb9f2
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 22 deletions.
46 changes: 32 additions & 14 deletions tests/fixtures/player.get_now_playing_media.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,37 @@
{
"heos": {
"command": "player/get_now_playing_media",
"result": "success",
"message": "pid={player_id}"
"command": "player/get_now_playing_media",
"result": "success",
"message": "pid={player_id}"
},
"payload": {
"type": "song",
"song": "Disney Hits",
"album": "",
"artist": "",
"image_url": "",
"album_id": "",
"mid": "catalog/playlists/genres",
"qid": 1,
"sid": 13
"type": "station",
"song": "Disney (Children's) Radio",
"station": "Disney (Children's) Radio",
"album": "Album",
"artist": "Artist",
"image_url": "http://cont-5.p-cdn.us/images/public/int/6/1/1/9/050087149116_500W_500H.jpg",
"album_id": "123456",
"mid": "4256592506324148495",
"qid": 1,
"sid": 13
},
"options": []
}
"options": [
{
"play": [
{
"id": 11,
"name": "Thumbs Up"
},
{
"id": 12,
"name": "Thumbs Down"
},
{
"id": 19,
"name": "Add to HEOS Favorites"
}
]
}
]
}
40 changes: 32 additions & 8 deletions tests/test_heos.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,16 +405,19 @@ async def test_player_now_playing_changed_event(
await heos.get_players()
player = heos.players[1]
now_playing = player.now_playing_media
assert now_playing.album == ""
assert now_playing.type == "song"
assert now_playing.album_id == ""
assert now_playing.artist == ""
assert now_playing.image_url == ""
assert now_playing.media_id == "catalog/playlists/genres"
assert now_playing.type == "station"
assert now_playing.song == "Disney (Children's) Radio"
assert now_playing.station == "Disney (Children's) Radio"
assert now_playing.album == "Album"
assert now_playing.artist == "Artist"
assert (
now_playing.image_url
== "http://cont-5.p-cdn.us/images/public/int/6/1/1/9/050087149116_500W_500H.jpg"
)
assert now_playing.album_id == "123456"
assert now_playing.media_id == "4256592506324148495"
assert now_playing.queue_id == 1
assert now_playing.source_id == 13
assert now_playing.song == "Disney Hits"
assert now_playing.station is None
assert now_playing.supported_controls == const.CONTROLS_ALL

# Attach dispatch handler
Expand Down Expand Up @@ -1173,3 +1176,24 @@ async def test_remove_group(heos: Heos) -> None:
async def test_update_group(heos: Heos) -> None:
"""Test removing a group."""
await heos.update_group(1, [2])


@calls_command("player.get_now_playing_media", {const.ATTR_PLAYER_ID: 1})
async def test_get_now_playing_media(heos: Heos) -> None:
"""Test removing a group."""
media = await heos.get_now_playing_media(1)

assert media.type == "station"
assert media.song == "Disney (Children's) Radio"
assert media.station == "Disney (Children's) Radio"
assert media.album == "Album"
assert media.artist == "Artist"
assert (
media.image_url
== "http://cont-5.p-cdn.us/images/public/int/6/1/1/9/050087149116_500W_500H.jpg"
)
assert media.album_id == "123456"
assert media.media_id == "4256592506324148495"
assert media.queue_id == 1
assert media.source_id == 13
assert media.supported_controls == const.CONTROLS_ALL

0 comments on commit 83eb9f2

Please sign in to comment.