Skip to content

Commit

Permalink
Fix BSBLAN climate test for async_set_preset_mode
Browse files Browse the repository at this point in the history
- Update test_async_set_preset_mode to correctly handle ServiceValidationError
- Check for specific translation key instead of full error message
- Ensure consistency between local tests and CI environment
- Import ServiceValidationError explicitly for clarity
  • Loading branch information
liudger committed Sep 5, 2024
1 parent 200ffe6 commit 0dff029
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/components/bsblan/test_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
)
from homeassistant.const import ATTR_TEMPERATURE, Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
import homeassistant.helpers.entity_registry as er

from . import setup_with_selected_platforms
Expand Down Expand Up @@ -142,8 +142,9 @@ async def test_async_set_preset_mode(
mock_hvac_mode.return_value = hvac_mode

if expected_call is None:
with pytest.raises(HomeAssistantError, match="set_preset_mode_error"):
with pytest.raises(ServiceValidationError) as exc_info:
await climate_entity.async_set_preset_mode(preset_mode)
assert exc_info.value.translation_key == "set_preset_mode_error"
else:
with patch.object(climate_entity, "async_set_data") as mock_set_data:
await climate_entity.async_set_preset_mode(preset_mode)
Expand Down

0 comments on commit 0dff029

Please sign in to comment.