Skip to content
Merged
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
6 changes: 1 addition & 5 deletions homeassistant/components/jellyfin/media_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from .const import (
COLLECTION_TYPE_MOVIES,
COLLECTION_TYPE_MUSIC,
COLLECTION_TYPE_TVSHOWS,
DOMAIN,
ITEM_KEY_COLLECTION_TYPE,
ITEM_KEY_ID,
Expand Down Expand Up @@ -155,10 +154,7 @@ async def _build_library(
return await self._build_music_library(library, include_children)
if collection_type == COLLECTION_TYPE_MOVIES:
return await self._build_movie_library(library, include_children)
if collection_type == COLLECTION_TYPE_TVSHOWS:
Comment thread
ctalkington marked this conversation as resolved.
Outdated
return await self._build_tv_library(library, include_children)

raise BrowseError(f"Unsupported collection type {collection_type}")
return await self._build_tv_library(library, include_children)

async def _build_music_library(
self, library: dict[str, Any], include_children: bool
Expand Down
16 changes: 15 additions & 1 deletion tests/components/jellyfin/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def mock_api() -> MagicMock:
jf_api.sessions.return_value = load_json_fixture("sessions.json")

jf_api.artwork.side_effect = api_artwork_side_effect
jf_api.audio_url.side_effect = api_audio_url_side_effect
jf_api.video_url.side_effect = api_video_url_side_effect
jf_api.user_items.side_effect = api_user_items_side_effect
jf_api.get_item.side_effect = api_get_item_side_effect
jf_api.get_media_folders.return_value = load_json_fixture("get-media-folders.json")
Expand All @@ -86,7 +88,7 @@ def mock_api() -> MagicMock:
def mock_config() -> MagicMock:
"""Return a mocked JellyfinClient."""
jf_config = create_autospec(Config)
jf_config.data = {}
jf_config.data = {"auth.server": "http://localhost"}

return jf_config

Expand Down Expand Up @@ -138,6 +140,18 @@ def api_artwork_side_effect(*args, **kwargs):
return f"http://localhost/Items/{item_id}/Images/{art}.{ext}"


def api_audio_url_side_effect(*args, **kwargs):
"""Handle variable responses for audio_url method."""
item_id = args[0]
return f"http://localhost/Audio/{item_id}/universal?UserId=test-username,DeviceId=TEST-UUID,MaxStreamingBitrate=140000000"


def api_video_url_side_effect(*args, **kwargs):
"""Handle variable responses for video_url method."""
item_id = args[0]
return f"http://localhost/Videos/{item_id}/stream?static=true,DeviceId=TEST-UUID,api_key=TEST-API-KEY"


def api_get_item_side_effect(*args):
"""Handle variable responses for get_item method."""
return load_json_fixture("get-item-collection.json")
Expand Down
12 changes: 12 additions & 0 deletions tests/components/jellyfin/fixtures/album.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"AlbumArtist": "ARTIST",
"AlbumArtists": [{ "Id": "ARTIST-UUID", "Name": "ARTIST" }],
"Artists": ["ARTIST"],
"Id": "ALBUM-UUID",
"ImageTags": {},
"IsFolder": true,
"Name": "ALBUM",
"PrimaryImageAspectRatio": 1,
"ServerId": "ServerId",
"Type": "MusicAlbum"
}
16 changes: 16 additions & 0 deletions tests/components/jellyfin/fixtures/albums.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"Items": [
{
"AlbumArtist": "ARTIST",
"AlbumArtists": [{ "Id": "ARTIST-UUID", "Name": "ARTIST" }],
"Artists": ["ARTIST"],
"Id": "ALBUM-UUID",
"ImageTags": {},
"IsFolder": true,
"Name": "ALBUM",
"PrimaryImageAspectRatio": 1,
"ServerId": "ServerId",
"Type": "MusicAlbum"
}
]
}
15 changes: 15 additions & 0 deletions tests/components/jellyfin/fixtures/artist.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"AlbumCount": 1,
"Id": "ARTIST-UUID",
"ImageTags": {
"Logo": "string",
"Primary": "string"
},
"IsFolder": true,
"Name": "ARTIST",
"ParentId": "MUSIC-COLLECTION-FOLDER-UUID",
"Path": "/media/music/artist",
"PrimaryImageAspectRatio": 1,
"ServerId": "string",
"Type": "MusicArtist"
}
19 changes: 19 additions & 0 deletions tests/components/jellyfin/fixtures/artists.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"Items": [
{
"AlbumCount": 1,
"Id": "ARTIST-UUID",
"ImageTags": {
"Logo": "string",
"Primary": "string"
},
"IsFolder": true,
"Name": "ARTIST",
"ParentId": "MUSIC-COLLECTION-FOLDER-UUID",
"Path": "/media/music/artist",
"PrimaryImageAspectRatio": 1,
"ServerId": "string",
"Type": "MusicArtist"
}
]
}
Loading