Bump plexapi to 4.15.3 (#101088)
* Bump plexapi to 4.15.3 * Update tests for updated account endpoint * Update tests for updated resources endpoint * Switch to non-web client fixture * Set __qualname__ attribute for new library behaviorpull/101148/head
parent
facdc5e862
commit
a1d632c5d1
|
@ -8,7 +8,7 @@
|
|||
"iot_class": "local_push",
|
||||
"loggers": ["plexapi", "plexwebsocket"],
|
||||
"requirements": [
|
||||
"PlexAPI==4.13.2",
|
||||
"PlexAPI==4.15.3",
|
||||
"plexauth==0.0.6",
|
||||
"plexwebsocket==0.0.13"
|
||||
],
|
||||
|
|
|
@ -46,7 +46,7 @@ Mastodon.py==1.5.1
|
|||
Pillow==10.0.0
|
||||
|
||||
# homeassistant.components.plex
|
||||
PlexAPI==4.13.2
|
||||
PlexAPI==4.15.3
|
||||
|
||||
# homeassistant.components.progettihwsw
|
||||
ProgettiHWSW==0.1.3
|
||||
|
|
|
@ -42,7 +42,7 @@ HATasmota==0.7.3
|
|||
Pillow==10.0.0
|
||||
|
||||
# homeassistant.components.plex
|
||||
PlexAPI==4.13.2
|
||||
PlexAPI==4.15.3
|
||||
|
||||
# homeassistant.components.progettihwsw
|
||||
ProgettiHWSW==0.1.3
|
||||
|
|
|
@ -232,6 +232,12 @@ def player_plexweb_resources_fixture():
|
|||
return load_fixture("plex/player_plexweb_resources.xml")
|
||||
|
||||
|
||||
@pytest.fixture(name="player_plexhtpc_resources", scope="session")
|
||||
def player_plexhtpc_resources_fixture():
|
||||
"""Load resources payload for a Plex HTPC player and return it."""
|
||||
return load_fixture("plex/player_plexhtpc_resources.xml")
|
||||
|
||||
|
||||
@pytest.fixture(name="playlists", scope="session")
|
||||
def playlists_fixture():
|
||||
"""Load payload for all playlists and return it."""
|
||||
|
@ -450,8 +456,8 @@ def mock_plex_calls(
|
|||
"""Mock Plex API calls."""
|
||||
requests_mock.get("https://plex.tv/api/users/", text=plextv_shared_users)
|
||||
requests_mock.get("https://plex.tv/api/invites/requested", text=empty_payload)
|
||||
requests_mock.get("https://plex.tv/users/account", text=plextv_account)
|
||||
requests_mock.get("https://plex.tv/api/resources", text=plextv_resources)
|
||||
requests_mock.get("https://plex.tv/api/v2/user", text=plextv_account)
|
||||
requests_mock.get("https://plex.tv/api/v2/resources", text=plextv_resources)
|
||||
|
||||
url = plex_server_url(entry)
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<MediaContainer size="1">
|
||||
<Player machineIdentifier="plex_htpc" deviceClass="pc" platform="osx" platformVersion="13.5" product="Plex HTPC for Mac" protocol="plex" protocolCapabilities="timeline,playback,navigation,playqueues" protocolVersion="3" title="Plex HTPC" version="1.33.2.3525-140e01eb" />
|
||||
</MediaContainer>
|
|
@ -1,15 +1,18 @@
|
|||
<user email="myplexusername@email.com" id="12345" uuid="1234567890" mailing_list_status="active" thumb="https://plex.tv/users/1234567890abcdef/avatar?c=11111" username="User 1" title="User 1" cloudSyncDevice="" locale="" authenticationToken="faketoken" authToken="faketoken" scrobbleTypes="" restricted="0" home="1" guest="0" queueEmail="queue+1234567890@save.plex.tv" queueUid="" hasPassword="true" homeSize="2" maxHomeSize="15" secure="1" certificateVersion="2">
|
||||
<subscription active="1" status="Active" plan="lifetime">
|
||||
<feature id="companions_sonos"/>
|
||||
<user id="12345" uuid="1234567890" username="User 1" title="User 1" email="myplexusername@email.com" friendlyName="User 1" locale="" confirmed="1" joinedAt="946730096" emailOnlyAuth="0" hasPassword="1" protected="0" thumb="https://plex.tv/users/1234567890abcdef/avatar?c=12345" authToken="faketoken" mailingListStatus="unsubscribed" mailingListActive="0" scrobbleTypes="" country="CA" subscriptionDescription="" restricted="0" anonymous="" home="1" guest="0" homeSize="2" homeAdmin="1" maxHomeSize="15" rememberExpiresAt="1680893707" adsConsent="" adsConsentSetAt="" adsConsentReminderAt="" experimentalFeatures="0" twoFactorEnabled="1" backupCodesCreated="1">
|
||||
<subscription active="1" subscribedAt="2023-09-19 00:00:00 UTC" status="Active" paymentService="" plan="lifetime">
|
||||
<features>
|
||||
<feature id="companions_sonos"/>
|
||||
</features>
|
||||
</subscription>
|
||||
<profile autoSelectAudio="0" defaultAudioLanguage="en" defaultSubtitleLanguage="en" autoSelectSubtitle="0" defaultSubtitleAccessibility="0" defaultSubtitleForced="0"/>
|
||||
<entitlements>
|
||||
<entitlement id="all"/>
|
||||
</entitlements>
|
||||
<roles>
|
||||
<role id="plexpass"/>
|
||||
</roles>
|
||||
<entitlements all="1"/>
|
||||
<profile_settings default_audio_language="en" default_subtitle_language="en" auto_select_subtitle="1" auto_select_audio="1" default_subtitle_accessibility="0" default_subtitle_forced="0"/>
|
||||
<services/>
|
||||
<username>testuser</username>
|
||||
<email>testuser@email.com</email>
|
||||
<joined-at type="datetime">2000-01-01 12:34:56 UTC</joined-at>
|
||||
<authentication-token>faketoken</authentication-token>
|
||||
<subscriptions>
|
||||
</subscriptions>
|
||||
<services>
|
||||
</services>
|
||||
</user>
|
||||
|
|
|
@ -1,18 +1,22 @@
|
|||
<MediaContainer size="5">
|
||||
<Device name="Plex Server 1" product="Plex Media Server" productVersion="1.20.4.3517-ab5e1197c" platform="Linux" platformVersion="20.04.1 LTS (Focal Fossa)" device="PC" clientIdentifier="unique_id_123" createdAt="1429510140" lastSeenAt="1605500006" provides="server" owned="1" accessToken="faketoken" publicAddress="10.20.30.40" httpsRequired="0" synced="0" relay="0" dnsRebindingProtection="0" natLoopbackSupported="1" publicAddressMatches="1" presence="1">
|
||||
<Connection protocol="https" address="1.2.3.4" port="32400" uri="https://1-2-3-4.123456789001234567890.plex.direct:32400" local="1"/>
|
||||
</Device>
|
||||
<Device name="Chrome" product="Plex Web" productVersion="4.46.2" platform="Chrome" platformVersion="14.0" device="OSX" clientIdentifier="plexweb_id" createdAt="1578086003" lastSeenAt="1605461664" provides="client,player,pubsub-player" owned="1" publicAddress="10.20.30.40" publicAddressMatches="1" presence="1" accessToken="faketoken">
|
||||
<Connection protocol="https" address="1.2.3.5" port="32400" uri="https://1-2-3-5.123456789001234567890.plex.direct:32400" local="1"/>
|
||||
<Connection protocol="https" address="10.20.30.40" port="35872" uri="https://10-20-30-40.123456789001234567890.plex.direct:35872" local="0"/>
|
||||
</Device>
|
||||
<Device name="AppleTV" product="Plex for Apple TV" productVersion="7.9" platform="tvOS" platformVersion="14.2" device="Apple TV" clientIdentifier="A10E4083-BF1A-4586-B884-C638A32D5285" createdAt="1447217545" lastSeenAt="1605495521" provides="client,player,pubsub-player,provider-playback" owned="1" publicAddress="10.20.30.40" publicAddressMatches="1" presence="0">
|
||||
<Connection protocol="http" address="1.2.3.6" port="32500" uri="http://1.2.3.6:32500" local="1"/>
|
||||
</Device>
|
||||
<Device name="jPhone" product="Plex for iOS" productVersion="7.9" platform="iOS" platformVersion="14.2" device="iPhone" clientIdentifier="CDB83941-F8C2-4B56-989E-F3EFD0165BC1" createdAt="1537584529" lastSeenAt="1605501046" provides="client,controller,sync-target,player,pubsub-player,provider-playback" owned="1" publicAddress="10.20.30.40" publicAddressMatches="1" presence="0">
|
||||
<Connection protocol="http" address="1.2.3.7" port="32500" uri="http://1.2.3.7:32500" local="1"/>
|
||||
</Device>
|
||||
<Device name="SHIELD Android TV" product="Plex for Android (TV)" productVersion="8.8.2.21525" platform="Android" platformVersion="9" device="SHIELD Android TV" clientIdentifier="2f2a5ae50a45837c-com-plexapp-android" createdAt="1584850408" lastSeenAt="1605384938" provides="player,pubsub-player,controller" owned="1" publicAddress="10.20.30.40" publicAddressMatches="1" presence="1">
|
||||
<Connection protocol="http" address="1.2.3.11" port="32500" uri="http://1.2.3.11:32500" local="1"/>
|
||||
</Device>
|
||||
</MediaContainer>
|
||||
<resources>
|
||||
<resource name="Plex Server 1" product="Plex Media Server" productVersion="1.32.6.7468-07e0d4a7e" platform="Linux" platformVersion="5.15.0-69-generic" device="Docker Container" clientIdentifier="unique_id_123" createdAt="2013-01-01T12:34:56Z" lastSeenAt="2023-09-20T00:00:00Z" provides="server" ownerId="" sourceTitle="" publicAddress="10.20.30.40" accessToken="faketoken" owned="1" home="0" synced="0" relay="0" presence="1" httpsRequired="0" publicAddressMatches="1" dnsRebindingProtection="0" natLoopbackSupported="0">
|
||||
<connections>
|
||||
<connection protocol="https" address="1.2.3.4" port="32400" uri="https://1-2-3-4.123456789001234567890.plex.direct:32400" local="1" relay="0" IPv6="0"/>
|
||||
</connections>
|
||||
</resource>
|
||||
<resource name="Plex HTPC" product="Plex HTPC for Mac" productVersion="1.33.2.3525-140e01eb" platform="osx" platformVersion="13.5" device="" clientIdentifier="client_id" createdAt="2023-09-01T00:00:00Z" lastSeenAt="2023-09-01T00:00:00Z" provides="client,player" ownerId="" sourceTitle="" publicAddress="10.20.30.40" accessToken="faketoken" owned="1" home="0" synced="0" relay="0" presence="1" httpsRequired="0" publicAddressMatches="1">
|
||||
<connections>
|
||||
<connection protocol="https" address="1.2.3.6" port="32400" uri="https://1-2-3-6.123456789001234567890.plex.direct:32400" local="1" relay="0" IPv6="0"/>
|
||||
</connections>
|
||||
</resource>
|
||||
<resource name="iPhone" product="Plex for iOS" productVersion="8.24" platform="iOS" platformVersion="16.6.1" device="iPhone" clientIdentifier="12345678-0123-0123-0123-012345678901" createdAt="2022-12-31T01:23:45Z" lastSeenAt="2023-09-19T00:00:00Z" provides="client,controller,sync-target,player,pubsub-player,provider-playback" ownerId="" sourceTitle="" publicAddress="10.20.30.40" accessToken="" owned="1" home="0" synced="0" relay="0" presence="0" httpsRequired="0" publicAddressMatches="1">
|
||||
<connections>
|
||||
<connection protocol="http" address="1.2.3.10" port="32500" uri="http://1.2.3.10:32500" local="1" relay="0" IPv6="0"/>
|
||||
</connections>
|
||||
</resource>
|
||||
<resource name="SHIELD Android TV" product="Plex for Android (TV)" productVersion="9.31.0.3817" platform="Android" platformVersion="11" device="SHIELD Android TV" clientIdentifier="1234567890-com-plexapp-android" createdAt="2020-01-01T12:34:56Z" lastSeenAt="2023-09-19T00:00:00Z" provides="player,pubsub-player,controller" ownerId="" sourceTitle="" publicAddress="10.20.30.40" accessToken="" owned="1" home="0" synced="0" relay="0" presence="0" httpsRequired="0" publicAddressMatches="1">
|
||||
<connections>
|
||||
<connection protocol="http" address="1.2.3.11" port="32500" uri="http://1.2.3.11:32500" local="1" relay="0" IPv6="0"/>
|
||||
</connections>
|
||||
</resource>
|
||||
</resources>
|
||||
|
|
|
@ -1,21 +1,27 @@
|
|||
<MediaContainer size="6">
|
||||
<Device name="Plex Server 1" product="Plex Media Server" productVersion="1.20.4.3517-ab5e1197c" platform="Linux" platformVersion="20.04.1 LTS (Focal Fossa)" device="PC" clientIdentifier="unique_id_123" createdAt="1429510140" lastSeenAt="1605500006" provides="server" owned="1" accessToken="faketoken" publicAddress="10.20.30.40" httpsRequired="0" synced="0" relay="0" dnsRebindingProtection="0" natLoopbackSupported="1" publicAddressMatches="1" presence="1">
|
||||
<Connection protocol="https" address="1.2.3.4" port="32400" uri="https://1-2-3-4.123456789001234567890.plex.direct:32400" local="1"/>
|
||||
</Device>
|
||||
<Device name="Plex Server 2" product="Plex Media Server" productVersion="1.20.4.3517-ab5e1197c" platform="Linux" platformVersion="20.04.1 LTS (Focal Fossa)" device="PC" clientIdentifier="unique_id_456" createdAt="1429510140" lastSeenAt="1605500006" provides="server" owned="1" accessToken="faketoken" publicAddress="10.20.30.40" httpsRequired="0" synced="0" relay="0" dnsRebindingProtection="0" natLoopbackSupported="1" publicAddressMatches="1" presence="1">
|
||||
<Connection protocol="https" address="4.3.2.1" port="32400" uri="https://4-3-2-1.123456789001234567890.plex.direct:32400" local="1"/>
|
||||
</Device>
|
||||
<Device name="Chrome" product="Plex Web" productVersion="4.46.2" platform="Chrome" platformVersion="14.0" device="OSX" clientIdentifier="plexweb_id" createdAt="1578086003" lastSeenAt="1605461664" provides="client,player,pubsub-player" owned="1" publicAddress="10.20.30.40" publicAddressMatches="1" presence="1" accessToken="faketoken">
|
||||
<Connection protocol="https" address="1.2.3.5" port="32400" uri="https://1-2-3-5.123456789001234567890.plex.direct:32400" local="1"/>
|
||||
<Connection protocol="https" address="10.20.30.40" port="35872" uri="https://10-20-30-40.123456789001234567890.plex.direct:35872" local="0"/>
|
||||
</Device>
|
||||
<Device name="AppleTV" product="Plex for Apple TV" productVersion="7.9" platform="tvOS" platformVersion="14.2" device="Apple TV" clientIdentifier="A10E4083-BF1A-4586-B884-C638A32D5285" createdAt="1447217545" lastSeenAt="1605495521" provides="client,player,pubsub-player,provider-playback" owned="1" publicAddress="10.20.30.40" publicAddressMatches="1" presence="0">
|
||||
<Connection protocol="http" address="1.2.3.6" port="32500" uri="http://1.2.3.6:32500" local="1"/>
|
||||
</Device>
|
||||
<Device name="jPhone" product="Plex for iOS" productVersion="7.9" platform="iOS" platformVersion="14.2" device="iPhone" clientIdentifier="CDB83941-F8C2-4B56-989E-F3EFD0165BC1" createdAt="1537584529" lastSeenAt="1605501046" provides="client,controller,sync-target,player,pubsub-player,provider-playback" owned="1" publicAddress="10.20.30.40" publicAddressMatches="1" presence="0">
|
||||
<Connection protocol="http" address="1.2.3.7" port="32500" uri="http://1.2.3.7:32500" local="1"/>
|
||||
</Device>
|
||||
<Device name="SHIELD Android TV" product="Plex for Android (TV)" productVersion="8.8.2.21525" platform="Android" platformVersion="9" device="SHIELD Android TV" clientIdentifier="2f2a5ae50a45837c-com-plexapp-android" createdAt="1584850408" lastSeenAt="1605384938" provides="player,pubsub-player,controller" owned="1" publicAddress="10.20.30.40" publicAddressMatches="1" presence="1">
|
||||
<Connection protocol="http" address="1.2.3.11" port="32500" uri="http://1.2.3.11:32500" local="1"/>
|
||||
</Device>
|
||||
</MediaContainer>
|
||||
<resources>
|
||||
<resource name="Plex Server 1" product="Plex Media Server" productVersion="1.32.6.7468-07e0d4a7e" platform="Linux" platformVersion="5.15.0-69-generic" device="Docker Container" clientIdentifier="unique_id_123" createdAt="2013-01-01T12:34:56Z" lastSeenAt="2023-09-20T00:00:00Z" provides="server" ownerId="" sourceTitle="" publicAddress="10.20.30.40" accessToken="faketoken" owned="1" home="0" synced="0" relay="0" presence="1" httpsRequired="0" publicAddressMatches="1" dnsRebindingProtection="0" natLoopbackSupported="0">
|
||||
<connections>
|
||||
<connection protocol="https" address="1.2.3.4" port="32400" uri="https://1-2-3-4.123456789001234567890.plex.direct:32400" local="1" relay="0" IPv6="0"/>
|
||||
</connections>
|
||||
</resource>
|
||||
<resource name="Plex Server 2" product="Plex Media Server" productVersion="1.32.6.7468-07e0d4a7e" platform="Linux" platformVersion="5.15.0-69-generic" device="Docker Container" clientIdentifier="unique_id_456" createdAt="2013-01-01T12:34:56Z" lastSeenAt="2023-09-20T00:00:00Z" provides="server" ownerId="" sourceTitle="" publicAddress="10.20.30.40" accessToken="faketoken" owned="1" home="0" synced="0" relay="0" presence="1" httpsRequired="0" publicAddressMatches="1" dnsRebindingProtection="0" natLoopbackSupported="0">
|
||||
<connections>
|
||||
<connection protocol="https" address="4.3.2.1" port="32400" uri="https://4-3-2-1.123456789001234567890.plex.direct:32400" local="1" relay="0" IPv6="0"/>
|
||||
</connections>
|
||||
</resource>
|
||||
<resource name="Plex HTPC" product="Plex HTPC for Mac" productVersion="1.33.2.3525-140e01eb" platform="osx" platformVersion="13.5" device="" clientIdentifier="client_id" createdAt="2023-09-01T00:00:00Z" lastSeenAt="2023-09-01T00:00:00Z" provides="client,player" ownerId="" sourceTitle="" publicAddress="10.20.30.40" accessToken="faketoken" owned="1" home="0" synced="0" relay="0" presence="1" httpsRequired="0" publicAddressMatches="1">
|
||||
<connections>
|
||||
<connection protocol="https" address="1.2.3.6" port="32400" uri="https://1-2-3-6.123456789001234567890.plex.direct:32400" local="1" relay="0" IPv6="0"/>
|
||||
</connections>
|
||||
</resource>
|
||||
<resource name="iPhone" product="Plex for iOS" productVersion="8.24" platform="iOS" platformVersion="16.6.1" device="iPhone" clientIdentifier="12345678-0123-0123-0123-012345678901" createdAt="2022-12-31T01:23:45Z" lastSeenAt="2023-09-19T00:00:00Z" provides="client,controller,sync-target,player,pubsub-player,provider-playback" ownerId="" sourceTitle="" publicAddress="10.20.30.40" accessToken="" owned="1" home="0" synced="0" relay="0" presence="0" httpsRequired="0" publicAddressMatches="1">
|
||||
<connections>
|
||||
<connection protocol="http" address="1.2.3.10" port="32500" uri="http://1.2.3.10:32500" local="1" relay="0" IPv6="0"/>
|
||||
</connections>
|
||||
</resource>
|
||||
<resource name="SHIELD Android TV" product="Plex for Android (TV)" productVersion="9.31.0.3817" platform="Android" platformVersion="11" device="SHIELD Android TV" clientIdentifier="1234567890-com-plexapp-android" createdAt="2020-01-01T12:34:56Z" lastSeenAt="2023-09-20T00:00:00Z" provides="player,pubsub-player,controller" ownerId="" sourceTitle="" publicAddress="10.20.30.40" accessToken="" owned="1" home="0" synced="0" relay="0" presence="0" httpsRequired="0" publicAddressMatches="1">
|
||||
<connections>
|
||||
<connection protocol="http" address="1.2.3.11" port="32500" uri="http://1.2.3.11:32500" local="1" relay="0" IPv6="0"/>
|
||||
</connections>
|
||||
</resource>
|
||||
</resources>
|
||||
|
|
|
@ -143,7 +143,7 @@ async def test_no_servers_found(
|
|||
current_request_with_host: None,
|
||||
) -> None:
|
||||
"""Test when no servers are on an account."""
|
||||
requests_mock.get("https://plex.tv/api/resources", text=empty_payload)
|
||||
requests_mock.get("https://plex.tv/api/v2/resources", text=empty_payload)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
|
@ -225,7 +225,7 @@ async def test_multiple_servers_with_selection(
|
|||
assert result["step_id"] == "user"
|
||||
|
||||
requests_mock.get(
|
||||
"https://plex.tv/api/resources",
|
||||
"https://plex.tv/api/v2/resources",
|
||||
text=plextv_resources_two_servers,
|
||||
)
|
||||
with patch("plexauth.PlexAuth.initiate_auth"), patch(
|
||||
|
@ -289,7 +289,7 @@ async def test_adding_last_unconfigured_server(
|
|||
assert result["step_id"] == "user"
|
||||
|
||||
requests_mock.get(
|
||||
"https://plex.tv/api/resources",
|
||||
"https://plex.tv/api/v2/resources",
|
||||
text=plextv_resources_two_servers,
|
||||
)
|
||||
|
||||
|
@ -346,9 +346,9 @@ async def test_all_available_servers_configured(
|
|||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
requests_mock.get("https://plex.tv/users/account", text=plextv_account)
|
||||
requests_mock.get("https://plex.tv/api/v2/user", text=plextv_account)
|
||||
requests_mock.get(
|
||||
"https://plex.tv/api/resources",
|
||||
"https://plex.tv/api/v2/resources",
|
||||
text=plextv_resources_two_servers,
|
||||
)
|
||||
|
||||
|
@ -776,7 +776,7 @@ async def test_reauth_multiple_servers_available(
|
|||
) -> None:
|
||||
"""Test setup and reauthorization of a Plex token when multiple servers are available."""
|
||||
requests_mock.get(
|
||||
"https://plex.tv/api/resources",
|
||||
"https://plex.tv/api/v2/resources",
|
||||
text=plextv_resources_two_servers,
|
||||
)
|
||||
|
||||
|
|
|
@ -231,7 +231,7 @@ async def test_setup_when_certificate_changed(
|
|||
|
||||
# Test with account failure
|
||||
requests_mock.get(
|
||||
"https://plex.tv/users/account", status_code=HTTPStatus.UNAUTHORIZED
|
||||
"https://plex.tv/api/v2/user", status_code=HTTPStatus.UNAUTHORIZED
|
||||
)
|
||||
old_entry.add_to_hass(hass)
|
||||
assert await hass.config_entries.async_setup(old_entry.entry_id) is False
|
||||
|
@ -241,8 +241,8 @@ async def test_setup_when_certificate_changed(
|
|||
await hass.config_entries.async_unload(old_entry.entry_id)
|
||||
|
||||
# Test with no servers found
|
||||
requests_mock.get("https://plex.tv/users/account", text=plextv_account)
|
||||
requests_mock.get("https://plex.tv/api/resources", text=empty_payload)
|
||||
requests_mock.get("https://plex.tv/api/v2/user", text=plextv_account)
|
||||
requests_mock.get("https://plex.tv/api/v2/resources", text=empty_payload)
|
||||
|
||||
assert await hass.config_entries.async_setup(old_entry.entry_id) is False
|
||||
await hass.async_block_till_done()
|
||||
|
@ -252,7 +252,7 @@ async def test_setup_when_certificate_changed(
|
|||
|
||||
# Test with success
|
||||
new_url = PLEX_DIRECT_URL
|
||||
requests_mock.get("https://plex.tv/api/resources", text=plextv_resources)
|
||||
requests_mock.get("https://plex.tv/api/v2/resources", text=plextv_resources)
|
||||
for resource_url in [new_url, "http://1.2.3.4:32400"]:
|
||||
requests_mock.get(resource_url, text=plex_server_default)
|
||||
requests_mock.get(f"{new_url}/accounts", text=plex_server_accounts)
|
||||
|
@ -287,7 +287,7 @@ async def test_bad_token_with_tokenless_server(
|
|||
) -> None:
|
||||
"""Test setup with a bad token and a server with token auth disabled."""
|
||||
requests_mock.get(
|
||||
"https://plex.tv/users/account", status_code=HTTPStatus.UNAUTHORIZED
|
||||
"https://plex.tv/api/v2/user", status_code=HTTPStatus.UNAUTHORIZED
|
||||
)
|
||||
|
||||
await setup_plex_server()
|
||||
|
|
|
@ -12,10 +12,10 @@ async def test_plex_tv_clients(
|
|||
entry,
|
||||
setup_plex_server,
|
||||
requests_mock: requests_mock.Mocker,
|
||||
player_plexweb_resources,
|
||||
player_plexhtpc_resources,
|
||||
) -> None:
|
||||
"""Test getting Plex clients from plex.tv."""
|
||||
requests_mock.get("/resources", text=player_plexweb_resources)
|
||||
requests_mock.get("/resources", text=player_plexhtpc_resources)
|
||||
|
||||
with patch("plexapi.myplex.MyPlexResource.connect", side_effect=NotFound):
|
||||
await setup_plex_server()
|
||||
|
|
|
@ -70,7 +70,10 @@ async def test_media_lookups(
|
|||
)
|
||||
assert "Library 'Not a Library' not found in" in str(excinfo.value)
|
||||
|
||||
with patch("plexapi.library.LibrarySection.search") as search:
|
||||
with patch(
|
||||
"plexapi.library.LibrarySection.search",
|
||||
__qualname__="search",
|
||||
) as search:
|
||||
await hass.services.async_call(
|
||||
MEDIA_PLAYER_DOMAIN,
|
||||
SERVICE_PLAY_MEDIA,
|
||||
|
@ -261,7 +264,11 @@ async def test_media_lookups(
|
|||
|
||||
with pytest.raises(MediaNotFound) as excinfo:
|
||||
payload = '{"library_name": "Movies", "title": "Not a Movie"}'
|
||||
with patch("plexapi.library.LibrarySection.search", side_effect=BadRequest):
|
||||
with patch(
|
||||
"plexapi.library.LibrarySection.search",
|
||||
side_effect=BadRequest,
|
||||
__qualname__="search",
|
||||
):
|
||||
await hass.services.async_call(
|
||||
MEDIA_PLAYER_DOMAIN,
|
||||
SERVICE_PLAY_MEDIA,
|
||||
|
|
|
@ -49,14 +49,14 @@ async def test_media_player_playback(
|
|||
setup_plex_server,
|
||||
requests_mock: requests_mock.Mocker,
|
||||
playqueue_created,
|
||||
player_plexweb_resources,
|
||||
player_plexhtpc_resources,
|
||||
) -> None:
|
||||
"""Test playing media on a Plex media_player."""
|
||||
requests_mock.get("http://1.2.3.5:32400/resources", text=player_plexweb_resources)
|
||||
requests_mock.get("http://1.2.3.6:32400/resources", text=player_plexhtpc_resources)
|
||||
|
||||
await setup_plex_server()
|
||||
|
||||
media_player = "media_player.plex_plex_web_chrome"
|
||||
media_player = "media_player.plex_plex_htpc_for_mac_plex_htpc"
|
||||
requests_mock.post("/playqueues", text=playqueue_created)
|
||||
playmedia_mock = requests_mock.get(
|
||||
"/player/playback/playMedia", status_code=HTTPStatus.OK
|
||||
|
@ -65,7 +65,9 @@ async def test_media_player_playback(
|
|||
# Test media lookup failure
|
||||
payload = '{"library_name": "Movies", "title": "Movie 1" }'
|
||||
with patch(
|
||||
"plexapi.library.LibrarySection.search", return_value=None
|
||||
"plexapi.library.LibrarySection.search",
|
||||
return_value=None,
|
||||
__qualname__="search",
|
||||
), pytest.raises(HomeAssistantError) as excinfo:
|
||||
await hass.services.async_call(
|
||||
MP_DOMAIN,
|
||||
|
@ -86,7 +88,11 @@ async def test_media_player_playback(
|
|||
|
||||
# Test movie success
|
||||
movies = [movie1]
|
||||
with patch("plexapi.library.LibrarySection.search", return_value=movies):
|
||||
with patch(
|
||||
"plexapi.library.LibrarySection.search",
|
||||
return_value=movies,
|
||||
__qualname__="search",
|
||||
):
|
||||
await hass.services.async_call(
|
||||
MP_DOMAIN,
|
||||
SERVICE_PLAY_MEDIA,
|
||||
|
@ -101,7 +107,11 @@ async def test_media_player_playback(
|
|||
|
||||
# Test movie success with resume
|
||||
playmedia_mock.reset()
|
||||
with patch("plexapi.library.LibrarySection.search", return_value=movies):
|
||||
with patch(
|
||||
"plexapi.library.LibrarySection.search",
|
||||
return_value=movies,
|
||||
__qualname__="search",
|
||||
):
|
||||
await hass.services.async_call(
|
||||
MP_DOMAIN,
|
||||
SERVICE_PLAY_MEDIA,
|
||||
|
@ -163,7 +173,11 @@ async def test_media_player_playback(
|
|||
# Test multiple choices with exact match
|
||||
playmedia_mock.reset()
|
||||
movies = [movie1, movie2]
|
||||
with patch("plexapi.library.LibrarySection.search", return_value=movies):
|
||||
with patch(
|
||||
"plexapi.library.LibrarySection.search",
|
||||
return_value=movies,
|
||||
__qualname__="search",
|
||||
):
|
||||
await hass.services.async_call(
|
||||
MP_DOMAIN,
|
||||
SERVICE_PLAY_MEDIA,
|
||||
|
@ -181,7 +195,11 @@ async def test_media_player_playback(
|
|||
movies = [movie2, movie3]
|
||||
with pytest.raises(HomeAssistantError) as excinfo:
|
||||
payload = '{"library_name": "Movies", "title": "Movie" }'
|
||||
with patch("plexapi.library.LibrarySection.search", return_value=movies):
|
||||
with patch(
|
||||
"plexapi.library.LibrarySection.search",
|
||||
return_value=movies,
|
||||
__qualname__="search",
|
||||
):
|
||||
await hass.services.async_call(
|
||||
MP_DOMAIN,
|
||||
SERVICE_PLAY_MEDIA,
|
||||
|
@ -197,7 +215,11 @@ async def test_media_player_playback(
|
|||
|
||||
# Test multiple choices with allow_multiple
|
||||
movies = [movie1, movie2, movie3]
|
||||
with patch("plexapi.library.LibrarySection.search", return_value=movies), patch(
|
||||
with patch(
|
||||
"plexapi.library.LibrarySection.search",
|
||||
return_value=movies,
|
||||
__qualname__="search",
|
||||
), patch(
|
||||
"homeassistant.components.plex.server.PlexServer.create_playqueue"
|
||||
) as mock_create_playqueue:
|
||||
await hass.services.async_call(
|
||||
|
|
|
@ -129,7 +129,11 @@ async def test_library_sensor_values(
|
|||
)
|
||||
|
||||
media = [MockPlexTVEpisode()]
|
||||
with patch("plexapi.library.LibrarySection.recentlyAdded", return_value=media):
|
||||
with patch(
|
||||
"plexapi.library.LibrarySection.recentlyAdded",
|
||||
return_value=media,
|
||||
__qualname__="recentlyAdded",
|
||||
):
|
||||
await hass.async_block_till_done()
|
||||
|
||||
library_tv_sensor = hass.states.get("sensor.plex_server_1_library_tv_shows")
|
||||
|
@ -165,7 +169,11 @@ async def test_library_sensor_values(
|
|||
trigger_plex_update(
|
||||
mock_websocket, msgtype="status", payload=LIBRARY_UPDATE_PAYLOAD
|
||||
)
|
||||
with patch("plexapi.library.LibrarySection.recentlyAdded", return_value=media):
|
||||
with patch(
|
||||
"plexapi.library.LibrarySection.recentlyAdded",
|
||||
return_value=media,
|
||||
__qualname__="recentlyAdded",
|
||||
):
|
||||
await hass.async_block_till_done()
|
||||
|
||||
library_tv_sensor = hass.states.get("sensor.plex_server_1_library_tv_shows")
|
||||
|
@ -200,7 +208,11 @@ async def test_library_sensor_values(
|
|||
)
|
||||
|
||||
media = [MockPlexMovie()]
|
||||
with patch("plexapi.library.LibrarySection.recentlyAdded", return_value=media):
|
||||
with patch(
|
||||
"plexapi.library.LibrarySection.recentlyAdded",
|
||||
return_value=media,
|
||||
__qualname__="recentlyAdded",
|
||||
):
|
||||
await hass.async_block_till_done()
|
||||
|
||||
library_movies_sensor = hass.states.get("sensor.plex_server_1_library_movies")
|
||||
|
@ -210,7 +222,11 @@ async def test_library_sensor_values(
|
|||
|
||||
# Test with clip
|
||||
media = [MockPlexClip()]
|
||||
with patch("plexapi.library.LibrarySection.recentlyAdded", return_value=media):
|
||||
with patch(
|
||||
"plexapi.library.LibrarySection.recentlyAdded",
|
||||
return_value=media,
|
||||
__qualname__="recentlyAdded",
|
||||
):
|
||||
async_dispatcher_send(
|
||||
hass, PLEX_UPDATE_LIBRARY_SIGNAL.format(mock_plex_server.machine_identifier)
|
||||
)
|
||||
|
@ -236,7 +252,11 @@ async def test_library_sensor_values(
|
|||
)
|
||||
|
||||
media = [MockPlexMusic()]
|
||||
with patch("plexapi.library.LibrarySection.recentlyAdded", return_value=media):
|
||||
with patch(
|
||||
"plexapi.library.LibrarySection.recentlyAdded",
|
||||
return_value=media,
|
||||
__qualname__="recentlyAdded",
|
||||
):
|
||||
await hass.async_block_till_done()
|
||||
|
||||
library_music_sensor = hass.states.get("sensor.plex_server_1_library_music")
|
||||
|
|
|
@ -190,7 +190,11 @@ async def test_lookup_media_for_other_integrations(
|
|||
assert result.shuffle
|
||||
|
||||
# Test with media not found
|
||||
with patch("plexapi.library.LibrarySection.search", return_value=None):
|
||||
with patch(
|
||||
"plexapi.library.LibrarySection.search",
|
||||
return_value=None,
|
||||
__qualname__="search",
|
||||
):
|
||||
with pytest.raises(HomeAssistantError) as excinfo:
|
||||
process_plex_payload(hass, MediaType.MUSIC, CONTENT_ID_BAD_MEDIA)
|
||||
assert f"No {MediaType.MUSIC} results in 'Music' for" in str(excinfo.value)
|
||||
|
|
Loading…
Reference in New Issue