Rework UniFi tests to not use runtime data (#119202)
This commit is contained in:
parent
34f20fce36
commit
c9911e4dd4
11 changed files with 196 additions and 180 deletions
|
@ -63,8 +63,8 @@ async def test_wlan_qr_code(
|
|||
entity_registry: er.EntityRegistry,
|
||||
hass_client: ClientSessionGenerator,
|
||||
snapshot: SnapshotAssertion,
|
||||
mock_unifi_websocket,
|
||||
websocket_mock,
|
||||
mock_websocket_message,
|
||||
mock_websocket_state,
|
||||
) -> None:
|
||||
"""Test the update_clients function when no clients are found."""
|
||||
assert len(hass.states.async_entity_ids(IMAGE_DOMAIN)) == 0
|
||||
|
@ -96,7 +96,7 @@ async def test_wlan_qr_code(
|
|||
assert body == snapshot
|
||||
|
||||
# Update state object - same password - no change to state
|
||||
mock_unifi_websocket(message=MessageKey.WLAN_CONF_UPDATED, data=WLAN)
|
||||
mock_websocket_message(message=MessageKey.WLAN_CONF_UPDATED, data=WLAN)
|
||||
await hass.async_block_till_done()
|
||||
image_state_2 = hass.states.get("image.ssid_1_qr_code")
|
||||
assert image_state_1.state == image_state_2.state
|
||||
|
@ -104,7 +104,7 @@ async def test_wlan_qr_code(
|
|||
# Update state object - changed password - new state
|
||||
data = deepcopy(WLAN)
|
||||
data["x_passphrase"] = "new password"
|
||||
mock_unifi_websocket(message=MessageKey.WLAN_CONF_UPDATED, data=data)
|
||||
mock_websocket_message(message=MessageKey.WLAN_CONF_UPDATED, data=data)
|
||||
await hass.async_block_till_done()
|
||||
image_state_3 = hass.states.get("image.ssid_1_qr_code")
|
||||
assert image_state_1.state != image_state_3.state
|
||||
|
@ -119,22 +119,22 @@ async def test_wlan_qr_code(
|
|||
# Availability signalling
|
||||
|
||||
# Controller disconnects
|
||||
await websocket_mock.disconnect()
|
||||
await mock_websocket_state.disconnect()
|
||||
assert hass.states.get("image.ssid_1_qr_code").state == STATE_UNAVAILABLE
|
||||
|
||||
# Controller reconnects
|
||||
await websocket_mock.reconnect()
|
||||
await mock_websocket_state.reconnect()
|
||||
assert hass.states.get("image.ssid_1_qr_code").state != STATE_UNAVAILABLE
|
||||
|
||||
# WLAN gets disabled
|
||||
wlan_1 = deepcopy(WLAN)
|
||||
wlan_1["enabled"] = False
|
||||
mock_unifi_websocket(message=MessageKey.WLAN_CONF_UPDATED, data=wlan_1)
|
||||
mock_websocket_message(message=MessageKey.WLAN_CONF_UPDATED, data=wlan_1)
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get("image.ssid_1_qr_code").state == STATE_UNAVAILABLE
|
||||
|
||||
# WLAN gets re-enabled
|
||||
wlan_1["enabled"] = True
|
||||
mock_unifi_websocket(message=MessageKey.WLAN_CONF_UPDATED, data=wlan_1)
|
||||
mock_websocket_message(message=MessageKey.WLAN_CONF_UPDATED, data=wlan_1)
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get("image.ssid_1_qr_code").state != STATE_UNAVAILABLE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue