1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Add latest added media as Plex library sensor attribute (#56235)

This commit is contained in:
jjlawren
2021-09-29 19:11:53 -05:00
committed by GitHub
parent a967a1d1df
commit 2ff1fc83bc
12 changed files with 779 additions and 4 deletions

View File

@@ -78,18 +78,54 @@ def library_movies_all_fixture():
return load_fixture("plex/library_movies_all.xml")
@pytest.fixture(name="library_movies_metadata", scope="session")
def library_movies_metadata_fixture():
"""Load payload for metadata in the movies library and return it."""
return load_fixture("plex/library_movies_metadata.xml")
@pytest.fixture(name="library_movies_collections", scope="session")
def library_movies_collections_fixture():
"""Load payload for collections in the movies library and return it."""
return load_fixture("plex/library_movies_collections.xml")
@pytest.fixture(name="library_tvshows_all", scope="session")
def library_tvshows_all_fixture():
"""Load payload for all items in the tvshows library and return it."""
return load_fixture("plex/library_tvshows_all.xml")
@pytest.fixture(name="library_tvshows_metadata", scope="session")
def library_tvshows_metadata_fixture():
"""Load payload for metadata in the TV shows library and return it."""
return load_fixture("plex/library_tvshows_metadata.xml")
@pytest.fixture(name="library_tvshows_collections", scope="session")
def library_tvshows_collections_fixture():
"""Load payload for collections in the TV shows library and return it."""
return load_fixture("plex/library_tvshows_collections.xml")
@pytest.fixture(name="library_music_all", scope="session")
def library_music_all_fixture():
"""Load payload for all items in the music library and return it."""
return load_fixture("plex/library_music_all.xml")
@pytest.fixture(name="library_music_metadata", scope="session")
def library_music_metadata_fixture():
"""Load payload for metadata in the music library and return it."""
return load_fixture("plex/library_music_metadata.xml")
@pytest.fixture(name="library_music_collections", scope="session")
def library_music_collections_fixture():
"""Load payload for collections in the music library and return it."""
return load_fixture("plex/library_music_collections.xml")
@pytest.fixture(name="library_movies_sort", scope="session")
def library_movies_sort_fixture():
"""Load sorting payload for movie library and return it."""
@@ -120,6 +156,18 @@ def library_fixture():
return load_fixture("plex/library.xml")
@pytest.fixture(name="library_movies_size", scope="session")
def library_movies_size_fixture():
"""Load movie library size payload and return it."""
return load_fixture("plex/library_movies_size.xml")
@pytest.fixture(name="library_music_size", scope="session")
def library_music_size_fixture():
"""Load music library size payload and return it."""
return load_fixture("plex/library_music_size.xml")
@pytest.fixture(name="library_tvshows_size", scope="session")
def library_tvshows_size_fixture():
"""Load tvshow library size payload and return it."""
@@ -352,10 +400,16 @@ def mock_plex_calls(
library,
library_sections,
library_movies_all,
library_movies_collections,
library_movies_metadata,
library_movies_sort,
library_music_all,
library_music_collections,
library_music_metadata,
library_music_sort,
library_tvshows_all,
library_tvshows_collections,
library_tvshows_metadata,
library_tvshows_sort,
media_1,
media_30,
@@ -396,6 +450,32 @@ def mock_plex_calls(
requests_mock.get(f"{url}/library/sections/2/all", text=library_tvshows_all)
requests_mock.get(f"{url}/library/sections/3/all", text=library_music_all)
requests_mock.get(
f"{url}/library/sections/1/all?includeMeta=1&includeAdvanced=1&X-Plex-Container-Start=0&X-Plex-Container-Size=0",
text=library_movies_metadata,
)
requests_mock.get(
f"{url}/library/sections/2/all?includeMeta=1&includeAdvanced=1&X-Plex-Container-Start=0&X-Plex-Container-Size=0",
text=library_tvshows_metadata,
)
requests_mock.get(
f"{url}/library/sections/3/all?includeMeta=1&includeAdvanced=1&X-Plex-Container-Start=0&X-Plex-Container-Size=0",
text=library_music_metadata,
)
requests_mock.get(
f"{url}/library/sections/1/collections?includeMeta=1&includeAdvanced=1&X-Plex-Container-Start=0&X-Plex-Container-Size=0",
text=library_movies_collections,
)
requests_mock.get(
f"{url}/library/sections/2/collections?includeMeta=1&includeAdvanced=1&X-Plex-Container-Start=0&X-Plex-Container-Size=0",
text=library_tvshows_collections,
)
requests_mock.get(
f"{url}/library/sections/3/collections?includeMeta=1&includeAdvanced=1&X-Plex-Container-Start=0&X-Plex-Container-Size=0",
text=library_music_collections,
)
requests_mock.get(f"{url}/library/metadata/200/children", text=children_200)
requests_mock.get(f"{url}/library/metadata/300/children", text=children_300)
requests_mock.get(f"{url}/library/metadata/300/allLeaves", text=grandchildren_300)