Skip to content

Commit c22a2b9

Browse files
authored
Bump PSNAWP to 3.0.1 (home-assistant#155579)
1 parent 7f84363 commit c22a2b9

File tree

7 files changed

+26
-26
lines changed

7 files changed

+26
-26
lines changed

homeassistant/components/playstation_network/coordinator.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from abc import abstractmethod
66
from dataclasses import dataclass
77
from datetime import timedelta
8-
import json
98
import logging
109
from typing import TYPE_CHECKING, Any
1110

@@ -175,10 +174,6 @@ async def update_data(self) -> dict[str, GroupDetails]:
175174
}
176175
)
177176
except PSNAWPForbiddenError as e:
178-
try:
179-
error = json.loads(e.args[0])
180-
except json.JSONDecodeError as err:
181-
raise PSNAWPServerError from err
182177
ir.async_create_issue(
183178
self.hass,
184179
DOMAIN,
@@ -189,7 +184,7 @@ async def update_data(self) -> dict[str, GroupDetails]:
189184
translation_key="group_chat_forbidden",
190185
translation_placeholders={
191186
CONF_NAME: self.config_entry.title,
192-
"error_message": error["error"]["message"],
187+
"error_message": e.message or "",
193188
},
194189
)
195190
await self.async_shutdown()

homeassistant/components/playstation_network/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,5 @@
8181
"integration_type": "service",
8282
"iot_class": "cloud_polling",
8383
"quality_scale": "bronze",
84-
"requirements": ["PSNAWP==3.0.0", "pyrate-limiter==3.9.0"]
84+
"requirements": ["PSNAWP==3.0.1", "pyrate-limiter==3.9.0"]
8585
}

requirements_all.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

requirements_test_all.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/components/playstation_network/test_config_flow.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ async def test_form_already_configured_as_subentry(hass: HomeAssistant) -> None:
119119
@pytest.mark.parametrize(
120120
("raise_error", "text_error"),
121121
[
122-
(PSNAWPNotFoundError(), "invalid_account"),
123-
(PSNAWPAuthenticationError(), "invalid_auth"),
124-
(PSNAWPError(), "cannot_connect"),
122+
(PSNAWPNotFoundError("error msg"), "invalid_account"),
123+
(PSNAWPAuthenticationError("error msg"), "invalid_auth"),
124+
(PSNAWPError("error msg"), "cannot_connect"),
125125
(Exception(), "unknown"),
126126
],
127127
)
@@ -169,7 +169,7 @@ async def test_parse_npsso_token_failures(
169169
mock_psnawp_npsso: MagicMock,
170170
) -> None:
171171
"""Test parse_npsso_token raises the correct exceptions during config flow."""
172-
mock_psnawp_npsso.side_effect = PSNAWPInvalidTokenError
172+
mock_psnawp_npsso.side_effect = PSNAWPInvalidTokenError("error msg")
173173
result = await hass.config_entries.flow.async_init(
174174
DOMAIN,
175175
context={"source": SOURCE_USER},
@@ -221,9 +221,9 @@ async def test_flow_reauth(
221221
@pytest.mark.parametrize(
222222
("raise_error", "text_error"),
223223
[
224-
(PSNAWPNotFoundError(), "invalid_account"),
225-
(PSNAWPAuthenticationError(), "invalid_auth"),
226-
(PSNAWPError(), "cannot_connect"),
224+
(PSNAWPNotFoundError("error msg"), "invalid_account"),
225+
(PSNAWPAuthenticationError("error msg"), "invalid_auth"),
226+
(PSNAWPError("error msg"), "cannot_connect"),
227227
(Exception(), "unknown"),
228228
],
229229
)
@@ -287,7 +287,7 @@ async def test_flow_reauth_token_error(
287287

288288
assert config_entry.state is ConfigEntryState.LOADED
289289

290-
mock_psnawp_npsso.side_effect = PSNAWPInvalidTokenError
290+
mock_psnawp_npsso.side_effect = PSNAWPInvalidTokenError("error msg")
291291
result = await config_entry.start_reauth_flow(hass)
292292
assert result["type"] is FlowResultType.FORM
293293
assert result["step_id"] == "reauth_confirm"

tests/components/playstation_network/test_init.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async def test_config_entry_auth_failed(
4949
) -> None:
5050
"""Test config entry auth failed setup error."""
5151

52-
mock_psnawpapi.user.side_effect = PSNAWPAuthenticationError
52+
mock_psnawpapi.user.side_effect = PSNAWPAuthenticationError("error msg")
5353
config_entry.add_to_hass(hass)
5454
await hass.config_entries.async_setup(config_entry.entry_id)
5555
await hass.async_block_till_done()
@@ -95,7 +95,7 @@ async def test_coordinator_update_auth_failed(
9595
"""Test coordinator update auth failed setup error."""
9696

9797
mock_psnawpapi.user.return_value.get_presence.side_effect = (
98-
PSNAWPAuthenticationError
98+
PSNAWPAuthenticationError("error msg")
9999
)
100100
config_entry.add_to_hass(hass)
101101
await hass.config_entries.async_setup(config_entry.entry_id)
@@ -152,7 +152,7 @@ async def test_trophy_title_coordinator_auth_failed(
152152
assert config_entry.state is ConfigEntryState.LOADED
153153

154154
mock_psnawpapi.user.return_value.trophy_titles.side_effect = (
155-
PSNAWPAuthenticationError
155+
PSNAWPAuthenticationError("error msg")
156156
)
157157

158158
freezer.tick(timedelta(days=1))
@@ -300,10 +300,10 @@ async def test_friends_coordinator_update_data_failed(
300300
@pytest.mark.parametrize(
301301
("exception", "state"),
302302
[
303-
(PSNAWPNotFoundError, ConfigEntryState.SETUP_ERROR),
304-
(PSNAWPAuthenticationError, ConfigEntryState.SETUP_ERROR),
305-
(PSNAWPServerError, ConfigEntryState.SETUP_RETRY),
306-
(PSNAWPClientError, ConfigEntryState.SETUP_RETRY),
303+
(PSNAWPNotFoundError("error msg"), ConfigEntryState.SETUP_ERROR),
304+
(PSNAWPAuthenticationError("error msg"), ConfigEntryState.SETUP_ERROR),
305+
(PSNAWPServerError("error msg"), ConfigEntryState.SETUP_RETRY),
306+
(PSNAWPClientError("error msg"), ConfigEntryState.SETUP_RETRY),
307307
],
308308
)
309309
async def test_friends_coordinator_setup_failed(
@@ -332,7 +332,7 @@ async def test_friends_coordinator_auth_failed(
332332
"""Test friends coordinator starts reauth on authentication error."""
333333

334334
mock = mock_psnawpapi.user.return_value.friends_list.return_value[0]
335-
mock.profile.side_effect = PSNAWPAuthenticationError
335+
mock.profile.side_effect = PSNAWPAuthenticationError("error msg")
336336

337337
config_entry.add_to_hass(hass)
338338
await hass.config_entries.async_setup(config_entry.entry_id)

tests/components/playstation_network/test_notify.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,12 @@ async def test_send_message(
101101

102102
@pytest.mark.parametrize(
103103
"exception",
104-
[PSNAWPClientError, PSNAWPForbiddenError, PSNAWPNotFoundError, PSNAWPServerError],
104+
[
105+
PSNAWPClientError("error msg"),
106+
PSNAWPForbiddenError("error msg"),
107+
PSNAWPNotFoundError("error msg"),
108+
PSNAWPServerError("error msg"),
109+
],
105110
)
106111
async def test_send_message_exceptions(
107112
hass: HomeAssistant,

0 commit comments

Comments
 (0)