From c22a2b93fac1a5274fddca63dcc3923d267b8ff3 Mon Sep 17 00:00:00 2001 From: Manu <4445816+tr4nt0r@users.noreply.github.com> Date: Sat, 1 Nov 2025 06:23:32 +0100 Subject: [PATCH] Bump PSNAWP to 3.0.1 (#155579) --- .../playstation_network/coordinator.py | 7 +------ .../components/playstation_network/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- .../playstation_network/test_config_flow.py | 16 ++++++++-------- .../components/playstation_network/test_init.py | 16 ++++++++-------- .../playstation_network/test_notify.py | 7 ++++++- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/homeassistant/components/playstation_network/coordinator.py b/homeassistant/components/playstation_network/coordinator.py index 2dced4b64ad..5d8b1ab2696 100644 --- a/homeassistant/components/playstation_network/coordinator.py +++ b/homeassistant/components/playstation_network/coordinator.py @@ -5,7 +5,6 @@ from __future__ import annotations from abc import abstractmethod from dataclasses import dataclass from datetime import timedelta -import json import logging from typing import TYPE_CHECKING, Any @@ -175,10 +174,6 @@ class PlaystationNetworkGroupsUpdateCoordinator( } ) except PSNAWPForbiddenError as e: - try: - error = json.loads(e.args[0]) - except json.JSONDecodeError as err: - raise PSNAWPServerError from err ir.async_create_issue( self.hass, DOMAIN, @@ -189,7 +184,7 @@ class PlaystationNetworkGroupsUpdateCoordinator( translation_key="group_chat_forbidden", translation_placeholders={ CONF_NAME: self.config_entry.title, - "error_message": error["error"]["message"], + "error_message": e.message or "", }, ) await self.async_shutdown() diff --git a/homeassistant/components/playstation_network/manifest.json b/homeassistant/components/playstation_network/manifest.json index 559d91b82fb..ed5b670bdde 100644 --- a/homeassistant/components/playstation_network/manifest.json +++ b/homeassistant/components/playstation_network/manifest.json @@ -81,5 +81,5 @@ "integration_type": "service", "iot_class": "cloud_polling", "quality_scale": "bronze", - "requirements": ["PSNAWP==3.0.0", "pyrate-limiter==3.9.0"] + "requirements": ["PSNAWP==3.0.1", "pyrate-limiter==3.9.0"] } diff --git a/requirements_all.txt b/requirements_all.txt index e141d211af4..e92ddf6f9c3 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -25,7 +25,7 @@ HATasmota==0.10.1 Mastodon.py==2.1.2 # homeassistant.components.playstation_network -PSNAWP==3.0.0 +PSNAWP==3.0.1 # homeassistant.components.doods # homeassistant.components.generic diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 9882afbd7d1..48a7e1b51dc 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -25,7 +25,7 @@ HATasmota==0.10.1 Mastodon.py==2.1.2 # homeassistant.components.playstation_network -PSNAWP==3.0.0 +PSNAWP==3.0.1 # homeassistant.components.doods # homeassistant.components.generic diff --git a/tests/components/playstation_network/test_config_flow.py b/tests/components/playstation_network/test_config_flow.py index f8caac72ccd..ef96a9bee57 100644 --- a/tests/components/playstation_network/test_config_flow.py +++ b/tests/components/playstation_network/test_config_flow.py @@ -119,9 +119,9 @@ async def test_form_already_configured_as_subentry(hass: HomeAssistant) -> None: @pytest.mark.parametrize( ("raise_error", "text_error"), [ - (PSNAWPNotFoundError(), "invalid_account"), - (PSNAWPAuthenticationError(), "invalid_auth"), - (PSNAWPError(), "cannot_connect"), + (PSNAWPNotFoundError("error msg"), "invalid_account"), + (PSNAWPAuthenticationError("error msg"), "invalid_auth"), + (PSNAWPError("error msg"), "cannot_connect"), (Exception(), "unknown"), ], ) @@ -169,7 +169,7 @@ async def test_parse_npsso_token_failures( mock_psnawp_npsso: MagicMock, ) -> None: """Test parse_npsso_token raises the correct exceptions during config flow.""" - mock_psnawp_npsso.side_effect = PSNAWPInvalidTokenError + mock_psnawp_npsso.side_effect = PSNAWPInvalidTokenError("error msg") result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, @@ -221,9 +221,9 @@ async def test_flow_reauth( @pytest.mark.parametrize( ("raise_error", "text_error"), [ - (PSNAWPNotFoundError(), "invalid_account"), - (PSNAWPAuthenticationError(), "invalid_auth"), - (PSNAWPError(), "cannot_connect"), + (PSNAWPNotFoundError("error msg"), "invalid_account"), + (PSNAWPAuthenticationError("error msg"), "invalid_auth"), + (PSNAWPError("error msg"), "cannot_connect"), (Exception(), "unknown"), ], ) @@ -287,7 +287,7 @@ async def test_flow_reauth_token_error( assert config_entry.state is ConfigEntryState.LOADED - mock_psnawp_npsso.side_effect = PSNAWPInvalidTokenError + mock_psnawp_npsso.side_effect = PSNAWPInvalidTokenError("error msg") result = await config_entry.start_reauth_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reauth_confirm" diff --git a/tests/components/playstation_network/test_init.py b/tests/components/playstation_network/test_init.py index 8afea992ce7..7a3e9c66409 100644 --- a/tests/components/playstation_network/test_init.py +++ b/tests/components/playstation_network/test_init.py @@ -49,7 +49,7 @@ async def test_config_entry_auth_failed( ) -> None: """Test config entry auth failed setup error.""" - mock_psnawpapi.user.side_effect = PSNAWPAuthenticationError + mock_psnawpapi.user.side_effect = PSNAWPAuthenticationError("error msg") config_entry.add_to_hass(hass) await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() @@ -95,7 +95,7 @@ async def test_coordinator_update_auth_failed( """Test coordinator update auth failed setup error.""" mock_psnawpapi.user.return_value.get_presence.side_effect = ( - PSNAWPAuthenticationError + PSNAWPAuthenticationError("error msg") ) config_entry.add_to_hass(hass) await hass.config_entries.async_setup(config_entry.entry_id) @@ -152,7 +152,7 @@ async def test_trophy_title_coordinator_auth_failed( assert config_entry.state is ConfigEntryState.LOADED mock_psnawpapi.user.return_value.trophy_titles.side_effect = ( - PSNAWPAuthenticationError + PSNAWPAuthenticationError("error msg") ) freezer.tick(timedelta(days=1)) @@ -300,10 +300,10 @@ async def test_friends_coordinator_update_data_failed( @pytest.mark.parametrize( ("exception", "state"), [ - (PSNAWPNotFoundError, ConfigEntryState.SETUP_ERROR), - (PSNAWPAuthenticationError, ConfigEntryState.SETUP_ERROR), - (PSNAWPServerError, ConfigEntryState.SETUP_RETRY), - (PSNAWPClientError, ConfigEntryState.SETUP_RETRY), + (PSNAWPNotFoundError("error msg"), ConfigEntryState.SETUP_ERROR), + (PSNAWPAuthenticationError("error msg"), ConfigEntryState.SETUP_ERROR), + (PSNAWPServerError("error msg"), ConfigEntryState.SETUP_RETRY), + (PSNAWPClientError("error msg"), ConfigEntryState.SETUP_RETRY), ], ) async def test_friends_coordinator_setup_failed( @@ -332,7 +332,7 @@ async def test_friends_coordinator_auth_failed( """Test friends coordinator starts reauth on authentication error.""" mock = mock_psnawpapi.user.return_value.friends_list.return_value[0] - mock.profile.side_effect = PSNAWPAuthenticationError + mock.profile.side_effect = PSNAWPAuthenticationError("error msg") config_entry.add_to_hass(hass) await hass.config_entries.async_setup(config_entry.entry_id) diff --git a/tests/components/playstation_network/test_notify.py b/tests/components/playstation_network/test_notify.py index a4ef6584a6e..f883ee77f9e 100644 --- a/tests/components/playstation_network/test_notify.py +++ b/tests/components/playstation_network/test_notify.py @@ -101,7 +101,12 @@ async def test_send_message( @pytest.mark.parametrize( "exception", - [PSNAWPClientError, PSNAWPForbiddenError, PSNAWPNotFoundError, PSNAWPServerError], + [ + PSNAWPClientError("error msg"), + PSNAWPForbiddenError("error msg"), + PSNAWPNotFoundError("error msg"), + PSNAWPServerError("error msg"), + ], ) async def test_send_message_exceptions( hass: HomeAssistant,