mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 18:28:14 +02:00
Requested changes
This commit is contained in:
@ -27,8 +27,8 @@ class PlaystationNetworkConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
errors: dict[str, str] = {}
|
||||
if user_input is not None:
|
||||
npsso = PlaystationNetwork.parse_npsso_token(user_input[CONF_NPSSO])
|
||||
psn = PlaystationNetwork(npsso)
|
||||
try:
|
||||
psn = PlaystationNetwork(npsso)
|
||||
user: User = await self.hass.async_add_executor_job(psn.get_user)
|
||||
except PSNAWPAuthenticationError:
|
||||
errors["base"] = "invalid_auth"
|
||||
|
@ -142,11 +142,3 @@ class PsnMediaPlayerEntity(
|
||||
if title.get("format", "") == PlatformType.PS4:
|
||||
return title.get("npTitleIconUrl")
|
||||
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
|
||||
test-before-configure: done
|
||||
test-before-setup: done
|
||||
unique-config-entry:
|
||||
done
|
||||
unique-config-entry: done
|
||||
|
||||
# Silver
|
||||
# Silver
|
||||
action-exceptions:
|
||||
status: exempt
|
||||
comment: Integration has no actions
|
||||
@ -49,9 +48,7 @@ rules:
|
||||
discovery-update-info:
|
||||
status: exempt
|
||||
comment: Discovery flow is not applicable for this integration
|
||||
discovery:
|
||||
status: exempt
|
||||
comment: Discovery flow is not applicable for this integration
|
||||
discovery: todo
|
||||
docs-data-update: done
|
||||
docs-examples: todo
|
||||
docs-known-limitations: done
|
||||
|
@ -6,7 +6,7 @@
|
||||
"npsso": "NPSSO token"
|
||||
},
|
||||
"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."
|
||||
}
|
||||
@ -18,7 +18,7 @@
|
||||
"unknown": "[%key:common::config_flow::error::unknown%]"
|
||||
},
|
||||
"abort": {
|
||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
|
||||
"already_configured": "[%key:common::config_flow::abort::already_configured_account%]"
|
||||
}
|
||||
},
|
||||
"exceptions": {
|
||||
|
@ -35,12 +35,12 @@ class mockUser:
|
||||
('{"npsso": "TEST_NPSSO_TOKEN"}'),
|
||||
],
|
||||
)
|
||||
async def test_form_success(hass: HomeAssistant, npsso) -> None:
|
||||
"""Test we get the form."""
|
||||
async def test_manual_config(hass: HomeAssistant, npsso) -> None:
|
||||
"""Test creating via manual configuration."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with patch(
|
||||
@ -51,9 +51,9 @@ async def test_form_success(hass: HomeAssistant, npsso) -> None:
|
||||
result["flow_id"],
|
||||
{CONF_NPSSO: npsso},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["result"].unique_id == "my-psn-id"
|
||||
assert result["data"] == {
|
||||
CONF_NPSSO: "TEST_NPSSO_TOKEN",
|
||||
}
|
||||
@ -82,7 +82,6 @@ async def test_form_already_configured(
|
||||
result["flow_id"],
|
||||
{CONF_NPSSO: NPSSO_TOKEN},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
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},
|
||||
data={CONF_NPSSO: NPSSO_TOKEN},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
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"],
|
||||
{CONF_NPSSO: NPSSO_TOKEN},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["data"] == {
|
||||
|
Reference in New Issue
Block a user