Skip to content

Commit df11af5

Browse files
committed
Further testing
1 parent 7bfc696 commit df11af5

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

tests/test_endpoints.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from datetime import datetime
55

66
from homeassistant_api import Client
7+
from homeassistant_api.errors import RequestError
78
from homeassistant_api.models import ConfigEntryDisabler
89
from homeassistant_api.models.events import Event
910
from homeassistant_api.models.states import State
@@ -200,6 +201,7 @@ def test_websocket_get_domain(websocket_client: WebsocketClient) -> None:
200201

201202
def test_get_nonuser_flows_in_progress(websocket_client: WebsocketClient) -> None:
202203
"""Tests the `"type": "config_entries/flow/progress"` websocket command."""
204+
# No flows in progress
203205
flows = websocket_client.get_nonuser_flows_in_progress()
204206
assert not flows
205207

@@ -227,18 +229,65 @@ def test_disable_enable_config_entry(websocket_client: WebsocketClient) -> None:
227229

228230
def test_ignore_config_flow(websocket_client: WebsocketClient) -> None:
229231
"""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+
)
230240

231241

232242
def test_get_config_entries(websocket_client: WebsocketClient) -> None:
233243
"""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
234268

235269

236270
def test_get_entry_subentries(websocket_client: WebsocketClient) -> None:
237271
"""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)
238279

239280

240281
def test_delete_entry_subentry(websocket_client: WebsocketClient) -> None:
241282
"""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+
)
242291

243292

244293
def test_trigger_service(cached_client: Client) -> None:

0 commit comments

Comments
 (0)