|
7 | 7 | from wled import WLEDConnectionError, WLEDError |
8 | 8 |
|
9 | 9 | from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS |
| 10 | +from homeassistant.components.wled.const import DOMAIN |
10 | 11 | from homeassistant.const import ATTR_ENTITY_ID, STATE_UNAVAILABLE, STATE_UNKNOWN |
11 | 12 | from homeassistant.core import HomeAssistant |
12 | 13 | from homeassistant.exceptions import HomeAssistantError |
@@ -51,28 +52,33 @@ async def test_button_restart( |
51 | 52 |
|
52 | 53 | # Test with WLED error |
53 | 54 | mock_wled.reset.side_effect = WLEDError |
54 | | - with pytest.raises(HomeAssistantError, match="Invalid response from WLED API"): |
| 55 | + with pytest.raises(HomeAssistantError) as ex: |
55 | 56 | await hass.services.async_call( |
56 | 57 | BUTTON_DOMAIN, |
57 | 58 | SERVICE_PRESS, |
58 | 59 | {ATTR_ENTITY_ID: "button.wled_rgb_light_restart"}, |
59 | 60 | blocking=True, |
60 | 61 | ) |
| 62 | + assert ex.value.translation_domain == DOMAIN |
| 63 | + assert ex.value.translation_key == "invalid_response_wled_error" |
61 | 64 |
|
62 | 65 | # Ensure this didn't made the entity unavailable |
63 | 66 | assert (state := hass.states.get("button.wled_rgb_light_restart")) |
64 | 67 | assert state.state != STATE_UNAVAILABLE |
65 | 68 |
|
66 | 69 | # Test with WLED connection error |
67 | 70 | mock_wled.reset.side_effect = WLEDConnectionError |
68 | | - with pytest.raises(HomeAssistantError, match="Error communicating with WLED API"): |
| 71 | + with pytest.raises(HomeAssistantError) as ex: |
69 | 72 | await hass.services.async_call( |
70 | 73 | BUTTON_DOMAIN, |
71 | 74 | SERVICE_PRESS, |
72 | 75 | {ATTR_ENTITY_ID: "button.wled_rgb_light_restart"}, |
73 | 76 | blocking=True, |
74 | 77 | ) |
75 | 78 |
|
| 79 | + assert ex.value.translation_domain == DOMAIN |
| 80 | + assert ex.value.translation_key == "connection_error" |
| 81 | + |
76 | 82 | # Ensure this made the entity unavailable |
77 | 83 | assert (state := hass.states.get("button.wled_rgb_light_restart")) |
78 | 84 | assert state.state == STATE_UNAVAILABLE |
0 commit comments