|
4 | 4 | from datetime import datetime |
5 | 5 |
|
6 | 6 | from homeassistant_api import Client |
| 7 | +from homeassistant_api.errors import RequestError |
7 | 8 | from homeassistant_api.models import ConfigEntryDisabler |
8 | 9 | from homeassistant_api.models.events import Event |
9 | 10 | from homeassistant_api.models.states import State |
@@ -200,6 +201,7 @@ def test_websocket_get_domain(websocket_client: WebsocketClient) -> None: |
200 | 201 |
|
201 | 202 | def test_get_nonuser_flows_in_progress(websocket_client: WebsocketClient) -> None: |
202 | 203 | """Tests the `"type": "config_entries/flow/progress"` websocket command.""" |
| 204 | + # No flows in progress |
203 | 205 | flows = websocket_client.get_nonuser_flows_in_progress() |
204 | 206 | assert not flows |
205 | 207 |
|
@@ -227,18 +229,65 @@ def test_disable_enable_config_entry(websocket_client: WebsocketClient) -> None: |
227 | 229 |
|
228 | 230 | def test_ignore_config_flow(websocket_client: WebsocketClient) -> None: |
229 | 231 | """Tests the `"type": "config_entries/ignore_flow"` websocket command.""" |
| 232 | + # Currently not able to test as no flows are in progress. Send invalid parameters and handle that error |
| 233 | + try: |
| 234 | + websocket_client.ignore_config_flow("", "") |
| 235 | + except RequestError as error: |
| 236 | + assert ( |
| 237 | + error.__str__() |
| 238 | + == "An error occurred while making the request to 'Config entry not found' with data: 'not_found'" |
| 239 | + ) |
230 | 240 |
|
231 | 241 |
|
232 | 242 | def test_get_config_entries(websocket_client: WebsocketClient) -> None: |
233 | 243 | """Tests the `"type": "config_entries/get"` websocket command.""" |
| 244 | + # Check number of entries |
| 245 | + entries = websocket_client.get_config_entries() |
| 246 | + assert len(entries) == 11 |
| 247 | + |
| 248 | + # Check that entries have expected values |
| 249 | + sun = entries[0] |
| 250 | + assert sun.created_at |
| 251 | + assert sun.entry_id |
| 252 | + assert sun.domain == "sun" |
| 253 | + assert sun.modified_at |
| 254 | + assert sun.title == "Sun" |
| 255 | + assert sun.source == "import" |
| 256 | + assert sun.supports_options is False |
| 257 | + assert sun.supports_remove_device is False |
| 258 | + assert sun.supports_unload is True |
| 259 | + assert sun.supports_reconfigure is False |
| 260 | + assert sun.supported_subentry_types == {} |
| 261 | + assert sun.pref_disable_new_entities is False |
| 262 | + assert sun.pref_disable_polling is False |
| 263 | + assert sun.disabled_by is None |
| 264 | + assert sun.reason is None |
| 265 | + assert sun.error_reason_translation_key is None |
| 266 | + assert sun.error_reason_translation_placeholders is None |
| 267 | + assert sun.num_subentries == 0 |
234 | 268 |
|
235 | 269 |
|
236 | 270 | def test_get_entry_subentries(websocket_client: WebsocketClient) -> None: |
237 | 271 | """Tests the `"type": "config_entries/subentries/list"` websocket command.""" |
| 272 | + # Currently not able to test as no entries with subentries available |
| 273 | + # Get the sun entry |
| 274 | + sun = websocket_client.get_config_entries()[0] |
| 275 | + assert sun |
| 276 | + |
| 277 | + # Get subentries for sun (empty tuple) |
| 278 | + assert not websocket_client.get_entry_subentries(sun.entry_id) |
238 | 279 |
|
239 | 280 |
|
240 | 281 | def test_delete_entry_subentry(websocket_client: WebsocketClient) -> None: |
241 | 282 | """Tests the `"type": "config_entries/subentries/delete"` websocket command.""" |
| 283 | + # Currently not able to test as no entries with subentries available. Send invalid parameters and handle that error |
| 284 | + try: |
| 285 | + websocket_client.delete_entry_subentry("", "") |
| 286 | + except RequestError as error: |
| 287 | + assert ( |
| 288 | + error.__str__() |
| 289 | + == "An error occurred while making the request to 'Config entry not found' with data: 'not_found'" |
| 290 | + ) |
242 | 291 |
|
243 | 292 |
|
244 | 293 | def test_trigger_service(cached_client: Client) -> None: |
|
0 commit comments