mirror of
https://github.com/home-assistant/core.git
synced 2025-08-02 12:15:08 +02:00
Requested changes
This commit is contained in:
@@ -27,8 +27,8 @@ class PlaystationNetworkConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
npsso = PlaystationNetwork.parse_npsso_token(user_input[CONF_NPSSO])
|
npsso = PlaystationNetwork.parse_npsso_token(user_input[CONF_NPSSO])
|
||||||
|
psn = PlaystationNetwork(npsso)
|
||||||
try:
|
try:
|
||||||
psn = PlaystationNetwork(npsso)
|
|
||||||
user: User = await self.hass.async_add_executor_job(psn.get_user)
|
user: User = await self.hass.async_add_executor_job(psn.get_user)
|
||||||
except PSNAWPAuthenticationError:
|
except PSNAWPAuthenticationError:
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
|
@@ -142,11 +142,3 @@ class PsnMediaPlayerEntity(
|
|||||||
if title.get("format", "") == PlatformType.PS4:
|
if title.get("format", "") == PlatformType.PS4:
|
||||||
return title.get("npTitleIconUrl")
|
return title.get("npTitleIconUrl")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
|
||||||
def is_on(self) -> bool:
|
|
||||||
"""Is user available on the Playstation Network."""
|
|
||||||
return (
|
|
||||||
self.coordinator.data.available is True
|
|
||||||
and self.key == self.coordinator.data.platform.get("platform", "")
|
|
||||||
)
|
|
||||||
|
@@ -24,10 +24,9 @@ rules:
|
|||||||
runtime-data: done
|
runtime-data: done
|
||||||
test-before-configure: done
|
test-before-configure: done
|
||||||
test-before-setup: done
|
test-before-setup: done
|
||||||
unique-config-entry:
|
unique-config-entry: done
|
||||||
done
|
|
||||||
|
|
||||||
# Silver
|
# Silver
|
||||||
action-exceptions:
|
action-exceptions:
|
||||||
status: exempt
|
status: exempt
|
||||||
comment: Integration has no actions
|
comment: Integration has no actions
|
||||||
@@ -49,9 +48,7 @@ rules:
|
|||||||
discovery-update-info:
|
discovery-update-info:
|
||||||
status: exempt
|
status: exempt
|
||||||
comment: Discovery flow is not applicable for this integration
|
comment: Discovery flow is not applicable for this integration
|
||||||
discovery:
|
discovery: todo
|
||||||
status: exempt
|
|
||||||
comment: Discovery flow is not applicable for this integration
|
|
||||||
docs-data-update: done
|
docs-data-update: done
|
||||||
docs-examples: todo
|
docs-examples: todo
|
||||||
docs-known-limitations: done
|
docs-known-limitations: done
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
"npsso": "NPSSO token"
|
"npsso": "NPSSO token"
|
||||||
},
|
},
|
||||||
"data_description": {
|
"data_description": {
|
||||||
"npsso": "Please supply the NPSSO token generated during successful login of your PlayStation Network account"
|
"npsso": "The NPSSO token is generated during successful login of your PlayStation Network account and is used to authenticate your requests from with Home Assistant."
|
||||||
},
|
},
|
||||||
"description": "To obtain your NPSSO token, log in to your [PlayStation account]({psn_link}) first. Then [click here]({npsso_link}) to retrieve the token."
|
"description": "To obtain your NPSSO token, log in to your [PlayStation account]({psn_link}) first. Then [click here]({npsso_link}) to retrieve the token."
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
"unknown": "[%key:common::config_flow::error::unknown%]"
|
"unknown": "[%key:common::config_flow::error::unknown%]"
|
||||||
},
|
},
|
||||||
"abort": {
|
"abort": {
|
||||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
|
"already_configured": "[%key:common::config_flow::abort::already_configured_account%]"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"exceptions": {
|
"exceptions": {
|
||||||
|
@@ -35,12 +35,12 @@ class mockUser:
|
|||||||
('{"npsso": "TEST_NPSSO_TOKEN"}'),
|
('{"npsso": "TEST_NPSSO_TOKEN"}'),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_form_success(hass: HomeAssistant, npsso) -> None:
|
async def test_manual_config(hass: HomeAssistant, npsso) -> None:
|
||||||
"""Test we get the form."""
|
"""Test creating via manual configuration."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
@@ -51,9 +51,9 @@ async def test_form_success(hass: HomeAssistant, npsso) -> None:
|
|||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
{CONF_NPSSO: npsso},
|
{CONF_NPSSO: npsso},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||||
|
assert result["result"].unique_id == "my-psn-id"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
CONF_NPSSO: "TEST_NPSSO_TOKEN",
|
CONF_NPSSO: "TEST_NPSSO_TOKEN",
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,6 @@ async def test_form_already_configured(
|
|||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
{CONF_NPSSO: NPSSO_TOKEN},
|
{CONF_NPSSO: NPSSO_TOKEN},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
@@ -116,7 +115,6 @@ async def test_form_failures(hass: HomeAssistant, raise_error, text_error) -> No
|
|||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
data={CONF_NPSSO: NPSSO_TOKEN},
|
data={CONF_NPSSO: NPSSO_TOKEN},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
assert result["errors"] == {"base": text_error}
|
assert result["errors"] == {"base": text_error}
|
||||||
|
|
||||||
@@ -134,7 +132,6 @@ async def test_form_failures(hass: HomeAssistant, raise_error, text_error) -> No
|
|||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
{CONF_NPSSO: NPSSO_TOKEN},
|
{CONF_NPSSO: NPSSO_TOKEN},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
|
Reference in New Issue
Block a user