diff --git a/homeassistant/components/roborock/manifest.json b/homeassistant/components/roborock/manifest.json index 444232b5843..d89a34d26d6 100644 --- a/homeassistant/components/roborock/manifest.json +++ b/homeassistant/components/roborock/manifest.json @@ -19,7 +19,7 @@ "loggers": ["roborock"], "quality_scale": "silver", "requirements": [ - "python-roborock==2.18.2", + "python-roborock==2.44.1", "vacuum-map-parser-roborock==0.1.4" ] } diff --git a/requirements_all.txt b/requirements_all.txt index 8ff70220aae..74b5dd94242 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2522,7 +2522,7 @@ python-rabbitair==0.0.8 python-ripple-api==0.0.3 # homeassistant.components.roborock -python-roborock==2.18.2 +python-roborock==2.44.1 # homeassistant.components.smarttub python-smarttub==0.0.44 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 74ab50a72a6..327d7d461f9 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -2095,7 +2095,7 @@ python-pooldose==0.5.0 python-rabbitair==0.0.8 # homeassistant.components.roborock -python-roborock==2.18.2 +python-roborock==2.44.1 # homeassistant.components.smarttub python-smarttub==0.0.44 diff --git a/tests/components/roborock/conftest.py b/tests/components/roborock/conftest.py index f95e4795d1d..09f5ac333f4 100644 --- a/tests/components/roborock/conftest.py +++ b/tests/components/roborock/conftest.py @@ -87,7 +87,7 @@ def bypass_api_client_fixture() -> None: @pytest.fixture(name="bypass_api_fixture") -def bypass_api_fixture(bypass_api_client_fixture: Any) -> None: +def bypass_api_fixture(bypass_api_client_fixture: Any, mock_send_message: Mock) -> None: """Skip calls to the API.""" with ( patch("homeassistant.components.roborock.RoborockMqttClientV1.async_connect"), @@ -116,7 +116,7 @@ def bypass_api_fixture(bypass_api_client_fixture: Any) -> None: return_value=MAP_DATA, ), patch( - "homeassistant.components.roborock.coordinator.RoborockLocalClientV1.send_message" + "homeassistant.components.roborock.coordinator.RoborockLocalClientV1._send_message" ), patch("homeassistant.components.roborock.RoborockMqttClientV1._wait_response"), patch( diff --git a/tests/components/roborock/snapshots/test_diagnostics.ambr b/tests/components/roborock/snapshots/test_diagnostics.ambr index 26ecb729312..ed1c37f6fa2 100644 --- a/tests/components/roborock/snapshots/test_diagnostics.ambr +++ b/tests/components/roborock/snapshots/test_diagnostics.ambr @@ -32,8 +32,6 @@ 'coordinators': dict({ '**REDACTED-0**': dict({ 'api': dict({ - 'misc_info': dict({ - }), }), 'roborock_device_info': dict({ 'device': dict({ @@ -319,8 +317,6 @@ }), '**REDACTED-1**': dict({ 'api': dict({ - 'misc_info': dict({ - }), }), 'roborock_device_info': dict({ 'device': dict({ @@ -606,8 +602,6 @@ }), '**REDACTED-2**': dict({ 'api': dict({ - 'misc_info': dict({ - }), }), 'roborock_device_info': dict({ 'device': dict({ @@ -969,8 +963,6 @@ }), '**REDACTED-3**': dict({ 'api': dict({ - 'misc_info': dict({ - }), }), 'roborock_device_info': dict({ 'device': dict({ diff --git a/tests/components/roborock/test_button.py b/tests/components/roborock/test_button.py index 77c5d4d7cb0..7dc15c02bc4 100644 --- a/tests/components/roborock/test_button.py +++ b/tests/components/roborock/test_button.py @@ -1,10 +1,10 @@ """Test Roborock Button platform.""" -from unittest.mock import ANY, patch +from unittest.mock import ANY, Mock, patch import pytest -import roborock from roborock import RoborockException +from roborock.exceptions import RoborockTimeout from homeassistant.components.button import SERVICE_PRESS from homeassistant.const import Platform @@ -48,19 +48,17 @@ async def test_update_success( bypass_api_fixture, setup_entry: MockConfigEntry, entity_id: str, + mock_send_message: Mock, ) -> None: """Test pressing the button entities.""" # Ensure that the entity exist, as these test can pass even if there is no entity. assert hass.states.get(entity_id).state == "unknown" - with patch( - "homeassistant.components.roborock.coordinator.RoborockLocalClientV1.send_message" - ) as mock_send_message: - await hass.services.async_call( - "button", - SERVICE_PRESS, - blocking=True, - target={"entity_id": entity_id}, - ) + await hass.services.async_call( + "button", + SERVICE_PRESS, + blocking=True, + target={"entity_id": entity_id}, + ) assert mock_send_message.assert_called_once assert hass.states.get(entity_id).state == "2023-10-30T08:50:00+00:00" @@ -73,21 +71,19 @@ async def test_update_success( ) @pytest.mark.freeze_time("2023-10-30 08:50:00") @pytest.mark.usefixtures("entity_registry_enabled_by_default") +@pytest.mark.parametrize("send_message_side_effect", [RoborockTimeout]) async def test_update_failure( hass: HomeAssistant, bypass_api_fixture, setup_entry: MockConfigEntry, entity_id: str, + mock_send_message: Mock, ) -> None: """Test failure while pressing the button entity.""" # Ensure that the entity exist, as these test can pass even if there is no entity. assert hass.states.get(entity_id).state == "unknown" - with ( - patch( - "homeassistant.components.roborock.coordinator.RoborockLocalClientV1.send_message", - side_effect=roborock.exceptions.RoborockTimeout, - ) as mock_send_message, - pytest.raises(HomeAssistantError, match="Error while calling RESET_CONSUMABLE"), + with pytest.raises( + HomeAssistantError, match="Error while calling RESET_CONSUMABLE" ): await hass.services.async_call( "button", diff --git a/tests/components/roborock/test_number.py b/tests/components/roborock/test_number.py index bfd8cc6da2b..c4809a71b6e 100644 --- a/tests/components/roborock/test_number.py +++ b/tests/components/roborock/test_number.py @@ -1,9 +1,9 @@ """Test Roborock Number platform.""" -from unittest.mock import patch +from unittest.mock import Mock import pytest -import roborock +from roborock.exceptions import RoborockTimeout from homeassistant.components.number import ATTR_VALUE, SERVICE_SET_VALUE from homeassistant.const import Platform @@ -31,20 +31,18 @@ async def test_update_success( setup_entry: MockConfigEntry, entity_id: str, value: float, + mock_send_message: Mock, ) -> None: """Test allowed changing values for number entities.""" # Ensure that the entity exist, as these test can pass even if there is no entity. assert hass.states.get(entity_id) is not None - with patch( - "homeassistant.components.roborock.coordinator.RoborockLocalClientV1.send_message" - ) as mock_send_message: - await hass.services.async_call( - "number", - SERVICE_SET_VALUE, - service_data={ATTR_VALUE: value}, - blocking=True, - target={"entity_id": entity_id}, - ) + await hass.services.async_call( + "number", + SERVICE_SET_VALUE, + service_data={ATTR_VALUE: value}, + blocking=True, + target={"entity_id": entity_id}, + ) assert mock_send_message.assert_called_once @@ -54,23 +52,19 @@ async def test_update_success( ("number.roborock_s7_maxv_volume", 3.0), ], ) +@pytest.mark.parametrize("send_message_side_effect", [RoborockTimeout]) async def test_update_failed( hass: HomeAssistant, bypass_api_fixture, setup_entry: MockConfigEntry, entity_id: str, value: float, + mock_send_message: Mock, ) -> None: """Test allowed changing values for number entities.""" # Ensure that the entity exist, as these test can pass even if there is no entity. assert hass.states.get(entity_id) is not None - with ( - patch( - "homeassistant.components.roborock.coordinator.RoborockLocalClientV1.send_message", - side_effect=roborock.exceptions.RoborockTimeout, - ) as mock_send_message, - pytest.raises(HomeAssistantError, match="Failed to update Roborock options"), - ): + with pytest.raises(HomeAssistantError, match="Failed to update Roborock options"): await hass.services.async_call( "number", SERVICE_SET_VALUE, diff --git a/tests/components/roborock/test_select.py b/tests/components/roborock/test_select.py index 7f25141306b..04b3be99575 100644 --- a/tests/components/roborock/test_select.py +++ b/tests/components/roborock/test_select.py @@ -1,7 +1,7 @@ """Test Roborock Select platform.""" import copy -from unittest.mock import patch +from unittest.mock import Mock, patch import pytest from roborock.exceptions import RoborockException @@ -37,36 +37,30 @@ async def test_update_success( setup_entry: MockConfigEntry, entity_id: str, value: str, + mock_send_message: Mock, ) -> None: """Test allowed changing values for select entities.""" # Ensure that the entity exist, as these test can pass even if there is no entity. assert hass.states.get(entity_id) is not None - with patch( - "homeassistant.components.roborock.coordinator.RoborockLocalClientV1.send_message" - ) as mock_send_message: - await hass.services.async_call( - "select", - SERVICE_SELECT_OPTION, - service_data={"option": value}, - blocking=True, - target={"entity_id": entity_id}, - ) + await hass.services.async_call( + "select", + SERVICE_SELECT_OPTION, + service_data={"option": value}, + blocking=True, + target={"entity_id": entity_id}, + ) assert mock_send_message.assert_called_once +@pytest.mark.parametrize("send_message_side_effect", [RoborockException]) async def test_update_failure( hass: HomeAssistant, bypass_api_fixture, setup_entry: MockConfigEntry, + mock_send_message: Mock, ) -> None: """Test that changing a value will raise a homeassistanterror when it fails.""" - with ( - patch( - "homeassistant.components.roborock.coordinator.RoborockLocalClientV1.send_message", - side_effect=RoborockException(), - ), - pytest.raises(HomeAssistantError, match="Error while calling SET_MOP_MOD"), - ): + with pytest.raises(HomeAssistantError, match="Error while calling SET_MOP_MOD"): await hass.services.async_call( "select", SERVICE_SELECT_OPTION,