PS4 bump to renamed dependency (#27144)

* Change to renamed dependency pyps4-2ndscreen 0.9.0

* Rename / bump to ps4 dependency to 1.0.0

* update requirements

* Rename test req

* Fix import

* Bump 1.0.1

* Fix flaky test leaving files behind
This commit is contained in:
ktnrg45 2019-10-06 05:43:34 -07:00 committed by Fabian Affolter
parent bd6bbcd5af
commit 1ecc883ef4
9 changed files with 56 additions and 66 deletions

View File

@ -3,8 +3,8 @@ import logging
import os import os
import voluptuous as vol import voluptuous as vol
from pyps4_homeassistant.ddp import async_create_ddp_endpoint from pyps4_2ndscreen.ddp import async_create_ddp_endpoint
from pyps4_homeassistant.media_art import COUNTRIES from pyps4_2ndscreen.media_art import COUNTRIES
from homeassistant.components.media_player.const import ( from homeassistant.components.media_player.const import (
ATTR_MEDIA_CONTENT_TYPE, ATTR_MEDIA_CONTENT_TYPE,
@ -172,12 +172,8 @@ def load_games(hass: HomeAssistantType) -> dict:
_LOGGER.error("Games file was not parsed correctly") _LOGGER.error("Games file was not parsed correctly")
games = {} games = {}
# If file does not exist, create empty file. # If file exists
if not os.path.isfile(g_file): if os.path.isfile(g_file):
_LOGGER.info("Creating PS4 Games File")
games = {}
save_games(hass, games)
else:
games = _reformat_data(hass, games) games = _reformat_data(hass, games)
return games return games

View File

@ -2,6 +2,9 @@
from collections import OrderedDict from collections import OrderedDict
import logging import logging
from pyps4_2ndscreen.errors import CredentialTimeout
from pyps4_2ndscreen.helpers import Helper
from pyps4_2ndscreen.media_art import COUNTRIES
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries from homeassistant import config_entries
@ -37,8 +40,6 @@ class PlayStation4FlowHandler(config_entries.ConfigFlow):
def __init__(self): def __init__(self):
"""Initialize the config flow.""" """Initialize the config flow."""
from pyps4_homeassistant import Helper
self.helper = Helper() self.helper = Helper()
self.creds = None self.creds = None
self.name = None self.name = None
@ -61,8 +62,6 @@ class PlayStation4FlowHandler(config_entries.ConfigFlow):
async def async_step_creds(self, user_input=None): async def async_step_creds(self, user_input=None):
"""Return PS4 credentials from 2nd Screen App.""" """Return PS4 credentials from 2nd Screen App."""
from pyps4_homeassistant.errors import CredentialTimeout
errors = {} errors = {}
if user_input is not None: if user_input is not None:
try: try:
@ -103,8 +102,6 @@ class PlayStation4FlowHandler(config_entries.ConfigFlow):
async def async_step_link(self, user_input=None): async def async_step_link(self, user_input=None):
"""Prompt user input. Create or edit entry.""" """Prompt user input. Create or edit entry."""
from pyps4_homeassistant.media_art import COUNTRIES
regions = sorted(COUNTRIES.keys()) regions = sorted(COUNTRIES.keys())
default_region = None default_region = None
errors = {} errors = {}

View File

@ -4,7 +4,7 @@
"config_flow": true, "config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/ps4", "documentation": "https://www.home-assistant.io/integrations/ps4",
"requirements": [ "requirements": [
"pyps4-homeassistant==0.8.7" "pyps4-2ndscreen==1.0.1"
], ],
"dependencies": [], "dependencies": [],
"codeowners": [ "codeowners": [

View File

@ -2,8 +2,8 @@
import logging import logging
import asyncio import asyncio
import pyps4_homeassistant.ps4 as pyps4 import pyps4_2ndscreen.ps4 as pyps4
from pyps4_homeassistant.errors import NotReady from pyps4_2ndscreen.errors import NotReady
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.components.media_player import ENTITY_IMAGE_URL, MediaPlayerDevice from homeassistant.components.media_player import ENTITY_IMAGE_URL, MediaPlayerDevice
@ -254,7 +254,7 @@ class PS4Device(MediaPlayerDevice):
async def async_get_title_data(self, title_id, name): async def async_get_title_data(self, title_id, name):
"""Get PS Store Data.""" """Get PS Store Data."""
from pyps4_homeassistant.errors import PSDataIncomplete from pyps4_2ndscreen.errors import PSDataIncomplete
app_name = None app_name = None
art = None art = None

View File

@ -1396,7 +1396,7 @@ pypjlink2==1.2.0
pypoint==1.1.1 pypoint==1.1.1
# homeassistant.components.ps4 # homeassistant.components.ps4
pyps4-homeassistant==0.8.7 pyps4-2ndscreen==1.0.1
# homeassistant.components.qwikswitch # homeassistant.components.qwikswitch
pyqwikswitch==0.93 pyqwikswitch==0.93

View File

@ -347,7 +347,7 @@ pyotgw==0.5b0
pyotp==2.3.0 pyotp==2.3.0
# homeassistant.components.ps4 # homeassistant.components.ps4
pyps4-homeassistant==0.8.7 pyps4-2ndscreen==1.0.1
# homeassistant.components.qwikswitch # homeassistant.components.qwikswitch
pyqwikswitch==0.93 pyqwikswitch==0.93

View File

@ -141,7 +141,7 @@ TEST_REQUIREMENTS = (
"pyopenuv", "pyopenuv",
"pyotgw", "pyotgw",
"pyotp", "pyotp",
"pyps4-homeassistant", "pyps4-2ndscreen",
"pyqwikswitch", "pyqwikswitch",
"PyRMVtransport", "PyRMVtransport",
"pysma", "pysma",

View File

@ -1,6 +1,8 @@
"""Define tests for the PlayStation 4 config flow.""" """Define tests for the PlayStation 4 config flow."""
from unittest.mock import patch from unittest.mock import patch
from pyps4_2ndscreen.errors import CredentialTimeout
from homeassistant import data_entry_flow from homeassistant import data_entry_flow
from homeassistant.components import ps4 from homeassistant.components import ps4
from homeassistant.components.ps4.const import DEFAULT_NAME, DEFAULT_REGION from homeassistant.components.ps4.const import DEFAULT_NAME, DEFAULT_REGION
@ -73,28 +75,28 @@ async def test_full_flow_implementation(hass):
manager = hass.config_entries manager = hass.config_entries
# User Step Started, results in Step Creds # User Step Started, results in Step Creds
with patch("pyps4_homeassistant.Helper.port_bind", return_value=None): with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
result = await flow.async_step_user() result = await flow.async_step_user()
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "creds" assert result["step_id"] == "creds"
# Step Creds results with form in Step Mode. # Step Creds results with form in Step Mode.
with patch("pyps4_homeassistant.Helper.get_creds", return_value=MOCK_CREDS): with patch("pyps4_2ndscreen.Helper.get_creds", return_value=MOCK_CREDS):
result = await flow.async_step_creds({}) result = await flow.async_step_creds({})
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "mode" assert result["step_id"] == "mode"
# Step Mode with User Input which is not manual, results in Step Link. # Step Mode with User Input which is not manual, results in Step Link.
with patch( with patch(
"pyps4_homeassistant.Helper.has_devices", return_value=[{"host-ip": MOCK_HOST}] "pyps4_2ndscreen.Helper.has_devices", return_value=[{"host-ip": MOCK_HOST}]
): ):
result = await flow.async_step_mode(MOCK_AUTO) result = await flow.async_step_mode(MOCK_AUTO)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "link" assert result["step_id"] == "link"
# User Input results in created entry. # User Input results in created entry.
with patch("pyps4_homeassistant.Helper.link", return_value=(True, True)), patch( with patch("pyps4_2ndscreen.Helper.link", return_value=(True, True)), patch(
"pyps4_homeassistant.Helper.has_devices", return_value=[{"host-ip": MOCK_HOST}] "pyps4_2ndscreen.Helper.has_devices", return_value=[{"host-ip": MOCK_HOST}]
): ):
result = await flow.async_step_link(MOCK_CONFIG) result = await flow.async_step_link(MOCK_CONFIG)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
@ -126,20 +128,20 @@ async def test_multiple_flow_implementation(hass):
manager = hass.config_entries manager = hass.config_entries
# User Step Started, results in Step Creds # User Step Started, results in Step Creds
with patch("pyps4_homeassistant.Helper.port_bind", return_value=None): with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
result = await flow.async_step_user() result = await flow.async_step_user()
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "creds" assert result["step_id"] == "creds"
# Step Creds results with form in Step Mode. # Step Creds results with form in Step Mode.
with patch("pyps4_homeassistant.Helper.get_creds", return_value=MOCK_CREDS): with patch("pyps4_2ndscreen.Helper.get_creds", return_value=MOCK_CREDS):
result = await flow.async_step_creds({}) result = await flow.async_step_creds({})
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "mode" assert result["step_id"] == "mode"
# Step Mode with User Input which is not manual, results in Step Link. # Step Mode with User Input which is not manual, results in Step Link.
with patch( with patch(
"pyps4_homeassistant.Helper.has_devices", "pyps4_2ndscreen.Helper.has_devices",
return_value=[{"host-ip": MOCK_HOST}, {"host-ip": MOCK_HOST_ADDITIONAL}], return_value=[{"host-ip": MOCK_HOST}, {"host-ip": MOCK_HOST_ADDITIONAL}],
): ):
result = await flow.async_step_mode(MOCK_AUTO) result = await flow.async_step_mode(MOCK_AUTO)
@ -147,8 +149,8 @@ async def test_multiple_flow_implementation(hass):
assert result["step_id"] == "link" assert result["step_id"] == "link"
# User Input results in created entry. # User Input results in created entry.
with patch("pyps4_homeassistant.Helper.link", return_value=(True, True)), patch( with patch("pyps4_2ndscreen.Helper.link", return_value=(True, True)), patch(
"pyps4_homeassistant.Helper.has_devices", "pyps4_2ndscreen.Helper.has_devices",
return_value=[{"host-ip": MOCK_HOST}, {"host-ip": MOCK_HOST_ADDITIONAL}], return_value=[{"host-ip": MOCK_HOST}, {"host-ip": MOCK_HOST_ADDITIONAL}],
): ):
result = await flow.async_step_link(MOCK_CONFIG) result = await flow.async_step_link(MOCK_CONFIG)
@ -175,8 +177,8 @@ async def test_multiple_flow_implementation(hass):
# Test additional flow. # Test additional flow.
# User Step Started, results in Step Mode: # User Step Started, results in Step Mode:
with patch("pyps4_homeassistant.Helper.port_bind", return_value=None), patch( with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None), patch(
"pyps4_homeassistant.Helper.has_devices", "pyps4_2ndscreen.Helper.has_devices",
return_value=[{"host-ip": MOCK_HOST}, {"host-ip": MOCK_HOST_ADDITIONAL}], return_value=[{"host-ip": MOCK_HOST}, {"host-ip": MOCK_HOST_ADDITIONAL}],
): ):
result = await flow.async_step_user() result = await flow.async_step_user()
@ -184,14 +186,14 @@ async def test_multiple_flow_implementation(hass):
assert result["step_id"] == "creds" assert result["step_id"] == "creds"
# Step Creds results with form in Step Mode. # Step Creds results with form in Step Mode.
with patch("pyps4_homeassistant.Helper.get_creds", return_value=MOCK_CREDS): with patch("pyps4_2ndscreen.Helper.get_creds", return_value=MOCK_CREDS):
result = await flow.async_step_creds({}) result = await flow.async_step_creds({})
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "mode" assert result["step_id"] == "mode"
# Step Mode with User Input which is not manual, results in Step Link. # Step Mode with User Input which is not manual, results in Step Link.
with patch( with patch(
"pyps4_homeassistant.Helper.has_devices", "pyps4_2ndscreen.Helper.has_devices",
return_value=[{"host-ip": MOCK_HOST}, {"host-ip": MOCK_HOST_ADDITIONAL}], return_value=[{"host-ip": MOCK_HOST}, {"host-ip": MOCK_HOST_ADDITIONAL}],
): ):
result = await flow.async_step_mode(MOCK_AUTO) result = await flow.async_step_mode(MOCK_AUTO)
@ -200,9 +202,9 @@ async def test_multiple_flow_implementation(hass):
# Step Link # Step Link
with patch( with patch(
"pyps4_homeassistant.Helper.has_devices", "pyps4_2ndscreen.Helper.has_devices",
return_value=[{"host-ip": MOCK_HOST}, {"host-ip": MOCK_HOST_ADDITIONAL}], return_value=[{"host-ip": MOCK_HOST}, {"host-ip": MOCK_HOST_ADDITIONAL}],
), patch("pyps4_homeassistant.Helper.link", return_value=(True, True)): ), patch("pyps4_2ndscreen.Helper.link", return_value=(True, True)):
result = await flow.async_step_link(MOCK_CONFIG_ADDITIONAL) result = await flow.async_step_link(MOCK_CONFIG_ADDITIONAL)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["data"][CONF_TOKEN] == MOCK_CREDS assert result["data"][CONF_TOKEN] == MOCK_CREDS
@ -232,13 +234,13 @@ async def test_port_bind_abort(hass):
flow = ps4.PlayStation4FlowHandler() flow = ps4.PlayStation4FlowHandler()
flow.hass = hass flow.hass = hass
with patch("pyps4_homeassistant.Helper.port_bind", return_value=MOCK_UDP_PORT): with patch("pyps4_2ndscreen.Helper.port_bind", return_value=MOCK_UDP_PORT):
reason = "port_987_bind_error" reason = "port_987_bind_error"
result = await flow.async_step_user(user_input=None) result = await flow.async_step_user(user_input=None)
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["reason"] == reason assert result["reason"] == reason
with patch("pyps4_homeassistant.Helper.port_bind", return_value=MOCK_TCP_PORT): with patch("pyps4_2ndscreen.Helper.port_bind", return_value=MOCK_TCP_PORT):
reason = "port_997_bind_error" reason = "port_997_bind_error"
result = await flow.async_step_user(user_input=None) result = await flow.async_step_user(user_input=None)
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
@ -253,7 +255,7 @@ async def test_duplicate_abort(hass):
flow.creds = MOCK_CREDS flow.creds = MOCK_CREDS
with patch( with patch(
"pyps4_homeassistant.Helper.has_devices", return_value=[{"host-ip": MOCK_HOST}] "pyps4_2ndscreen.Helper.has_devices", return_value=[{"host-ip": MOCK_HOST}]
): ):
result = await flow.async_step_link(user_input=None) result = await flow.async_step_link(user_input=None)
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
@ -274,9 +276,9 @@ async def test_additional_device(hass):
assert len(manager.async_entries()) == 1 assert len(manager.async_entries()) == 1
with patch( with patch(
"pyps4_homeassistant.Helper.has_devices", "pyps4_2ndscreen.Helper.has_devices",
return_value=[{"host-ip": MOCK_HOST}, {"host-ip": MOCK_HOST_ADDITIONAL}], return_value=[{"host-ip": MOCK_HOST}, {"host-ip": MOCK_HOST_ADDITIONAL}],
), patch("pyps4_homeassistant.Helper.link", return_value=(True, True)): ), patch("pyps4_2ndscreen.Helper.link", return_value=(True, True)):
result = await flow.async_step_link(MOCK_CONFIG_ADDITIONAL) result = await flow.async_step_link(MOCK_CONFIG_ADDITIONAL)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["data"][CONF_TOKEN] == MOCK_CREDS assert result["data"][CONF_TOKEN] == MOCK_CREDS
@ -296,7 +298,7 @@ async def test_no_devices_found_abort(hass):
flow = ps4.PlayStation4FlowHandler() flow = ps4.PlayStation4FlowHandler()
flow.hass = hass flow.hass = hass
with patch("pyps4_homeassistant.Helper.has_devices", return_value=[]): with patch("pyps4_2ndscreen.Helper.has_devices", return_value=[]):
result = await flow.async_step_link() result = await flow.async_step_link()
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["reason"] == "no_devices_found" assert result["reason"] == "no_devices_found"
@ -310,8 +312,7 @@ async def test_manual_mode(hass):
# Step Mode with User Input: manual, results in Step Link. # Step Mode with User Input: manual, results in Step Link.
with patch( with patch(
"pyps4_homeassistant.Helper.has_devices", "pyps4_2ndscreen.Helper.has_devices", return_value=[{"host-ip": flow.m_device}]
return_value=[{"host-ip": flow.m_device}],
): ):
result = await flow.async_step_mode(MOCK_MANUAL) result = await flow.async_step_mode(MOCK_MANUAL)
assert flow.m_device == MOCK_HOST assert flow.m_device == MOCK_HOST
@ -324,7 +325,7 @@ async def test_credential_abort(hass):
flow = ps4.PlayStation4FlowHandler() flow = ps4.PlayStation4FlowHandler()
flow.hass = hass flow.hass = hass
with patch("pyps4_homeassistant.Helper.get_creds", return_value=None): with patch("pyps4_2ndscreen.Helper.get_creds", return_value=None):
result = await flow.async_step_creds({}) result = await flow.async_step_creds({})
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["reason"] == "credential_error" assert result["reason"] == "credential_error"
@ -332,12 +333,10 @@ async def test_credential_abort(hass):
async def test_credential_timeout(hass): async def test_credential_timeout(hass):
"""Test that Credential Timeout shows error.""" """Test that Credential Timeout shows error."""
from pyps4_homeassistant.errors import CredentialTimeout
flow = ps4.PlayStation4FlowHandler() flow = ps4.PlayStation4FlowHandler()
flow.hass = hass flow.hass = hass
with patch("pyps4_homeassistant.Helper.get_creds", side_effect=CredentialTimeout): with patch("pyps4_2ndscreen.Helper.get_creds", side_effect=CredentialTimeout):
result = await flow.async_step_creds({}) result = await flow.async_step_creds({})
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["errors"] == {"base": "credential_timeout"} assert result["errors"] == {"base": "credential_timeout"}
@ -349,8 +348,8 @@ async def test_wrong_pin_error(hass):
flow.hass = hass flow.hass = hass
flow.location = MOCK_LOCATION flow.location = MOCK_LOCATION
with patch("pyps4_homeassistant.Helper.link", return_value=(True, False)), patch( with patch("pyps4_2ndscreen.Helper.link", return_value=(True, False)), patch(
"pyps4_homeassistant.Helper.has_devices", return_value=[{"host-ip": MOCK_HOST}] "pyps4_2ndscreen.Helper.has_devices", return_value=[{"host-ip": MOCK_HOST}]
): ):
result = await flow.async_step_link(MOCK_CONFIG) result = await flow.async_step_link(MOCK_CONFIG)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
@ -364,8 +363,8 @@ async def test_device_connection_error(hass):
flow.hass = hass flow.hass = hass
flow.location = MOCK_LOCATION flow.location = MOCK_LOCATION
with patch("pyps4_homeassistant.Helper.link", return_value=(False, True)), patch( with patch("pyps4_2ndscreen.Helper.link", return_value=(False, True)), patch(
"pyps4_homeassistant.Helper.has_devices", return_value=[{"host-ip": MOCK_HOST}] "pyps4_2ndscreen.Helper.has_devices", return_value=[{"host-ip": MOCK_HOST}]
): ):
result = await flow.async_step_link(MOCK_CONFIG) result = await flow.async_step_link(MOCK_CONFIG)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["type"] == data_entry_flow.RESULT_TYPE_FORM

View File

@ -1,7 +1,7 @@
"""Tests for the PS4 media player platform.""" """Tests for the PS4 media player platform."""
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
from pyps4_homeassistant.credential import get_ddp_message from pyps4_2ndscreen.credential import get_ddp_message
from homeassistant.components import ps4 from homeassistant.components import ps4
from homeassistant.components.media_player.const import ( from homeassistant.components.media_player.const import (
@ -295,9 +295,7 @@ async def test_media_attributes_are_loaded(hass):
async def test_device_info_is_set_from_status_correctly(hass): async def test_device_info_is_set_from_status_correctly(hass):
"""Test that device info is set correctly from status update.""" """Test that device info is set correctly from status update."""
mock_d_registry = mock_device_registry(hass) mock_d_registry = mock_device_registry(hass)
with patch( with patch("pyps4_2ndscreen.ps4.get_status", return_value=MOCK_STATUS_OFF):
"pyps4_homeassistant.ps4.get_status", return_value=MOCK_STATUS_OFF
), patch(MOCK_SAVE, side_effect=MagicMock()):
mock_entity_id = await setup_mock_component(hass) mock_entity_id = await setup_mock_component(hass)
await hass.async_block_till_done() await hass.async_block_till_done()
@ -447,9 +445,9 @@ async def test_media_stop(hass):
async def test_select_source(hass): async def test_select_source(hass):
"""Test that select source service calls function with title.""" """Test that select source service calls function with title."""
mock_data = {MOCK_TITLE_ID: MOCK_GAMES_DATA} mock_data = {MOCK_TITLE_ID: MOCK_GAMES_DATA}
with patch( with patch("pyps4_2ndscreen.ps4.get_status", return_value=MOCK_STATUS_IDLE), patch(
"pyps4_homeassistant.ps4.get_status", return_value=MOCK_STATUS_IDLE MOCK_LOAD, return_value=mock_data
), patch(MOCK_LOAD, return_value=mock_data): ):
mock_entity_id = await setup_mock_component(hass) mock_entity_id = await setup_mock_component(hass)
mock_func = "{}{}".format( mock_func = "{}{}".format(
@ -473,9 +471,9 @@ async def test_select_source(hass):
async def test_select_source_caps(hass): async def test_select_source_caps(hass):
"""Test that select source service calls function with upper case title.""" """Test that select source service calls function with upper case title."""
mock_data = {MOCK_TITLE_ID: MOCK_GAMES_DATA} mock_data = {MOCK_TITLE_ID: MOCK_GAMES_DATA}
with patch( with patch("pyps4_2ndscreen.ps4.get_status", return_value=MOCK_STATUS_IDLE), patch(
"pyps4_homeassistant.ps4.get_status", return_value=MOCK_STATUS_IDLE MOCK_LOAD, return_value=mock_data
), patch(MOCK_LOAD, return_value=mock_data): ):
mock_entity_id = await setup_mock_component(hass) mock_entity_id = await setup_mock_component(hass)
mock_func = "{}{}".format( mock_func = "{}{}".format(
@ -502,9 +500,9 @@ async def test_select_source_caps(hass):
async def test_select_source_id(hass): async def test_select_source_id(hass):
"""Test that select source service calls function with Title ID.""" """Test that select source service calls function with Title ID."""
mock_data = {MOCK_TITLE_ID: MOCK_GAMES_DATA} mock_data = {MOCK_TITLE_ID: MOCK_GAMES_DATA}
with patch( with patch("pyps4_2ndscreen.ps4.get_status", return_value=MOCK_STATUS_IDLE), patch(
"pyps4_homeassistant.ps4.get_status", return_value=MOCK_STATUS_IDLE MOCK_LOAD, return_value=mock_data
), patch(MOCK_LOAD, return_value=mock_data): ):
mock_entity_id = await setup_mock_component(hass) mock_entity_id = await setup_mock_component(hass)
mock_func = "{}{}".format( mock_func = "{}{}".format(