1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Improve tests based on Martins feedback from Axis improve tests (#30442)

This commit is contained in:
Robert Svensson
2020-01-03 19:23:17 +01:00
committed by Andrew Sayre
parent e7af759330
commit 2b26af89df
4 changed files with 70 additions and 213 deletions

View File

@@ -17,7 +17,7 @@ from homeassistant.helpers import entity_registry
from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util
from .test_controller import ENTRY_CONFIG, SITES, setup_unifi_integration
from .test_controller import ENTRY_CONFIG, setup_unifi_integration
CLIENT_1 = {
"essid": "ssid",
@@ -95,15 +95,7 @@ async def test_platform_manually_configured(hass):
async def test_no_clients(hass):
"""Test the update_clients function when no clients are found."""
await setup_unifi_integration(
hass,
ENTRY_CONFIG,
options={},
sites=SITES,
clients_response=[],
devices_response=[],
clients_all_response=[],
)
await setup_unifi_integration(hass)
assert len(hass.states.async_all()) == 2
@@ -115,12 +107,9 @@ async def test_tracked_devices(hass):
controller = await setup_unifi_integration(
hass,
ENTRY_CONFIG,
options={CONF_SSID_FILTER: ["ssid"]},
sites=SITES,
clients_response=[CLIENT_1, CLIENT_2, CLIENT_3, client_4_copy],
devices_response=[DEVICE_1, DEVICE_2],
clients_all_response={},
known_wireless_clients=(CLIENT_4["mac"],),
)
assert len(hass.states.async_all()) == 6
@@ -196,15 +185,7 @@ async def test_wireless_client_go_wired_issue(hass):
client_1_client = copy(CLIENT_1)
client_1_client["last_seen"] = dt_util.as_timestamp(dt_util.utcnow())
controller = await setup_unifi_integration(
hass,
ENTRY_CONFIG,
options={},
sites=SITES,
clients_response=[client_1_client],
devices_response=[],
clients_all_response=[],
)
controller = await setup_unifi_integration(hass, clients_response=[client_1_client])
assert len(hass.states.async_all()) == 3
client_1 = hass.states.get("device_tracker.client_1")
@@ -277,11 +258,8 @@ async def test_restoring_client(hass):
await setup_unifi_integration(
hass,
ENTRY_CONFIG,
options={unifi.CONF_BLOCK_CLIENT: True},
sites=SITES,
clients_response=[CLIENT_2],
devices_response=[],
clients_all_response=[CLIENT_1],
)
assert len(hass.states.async_all()) == 4
@@ -294,12 +272,9 @@ async def test_dont_track_clients(hass):
"""Test dont track clients config works."""
await setup_unifi_integration(
hass,
ENTRY_CONFIG,
options={unifi.controller.CONF_TRACK_CLIENTS: False},
sites=SITES,
clients_response=[CLIENT_1],
devices_response=[DEVICE_1],
clients_all_response=[],
)
assert len(hass.states.async_all()) == 3
@@ -315,12 +290,9 @@ async def test_dont_track_devices(hass):
"""Test dont track devices config works."""
await setup_unifi_integration(
hass,
ENTRY_CONFIG,
options={unifi.controller.CONF_TRACK_DEVICES: False},
sites=SITES,
clients_response=[CLIENT_1],
devices_response=[DEVICE_1],
clients_all_response=[],
)
assert len(hass.states.async_all()) == 3
@@ -336,12 +308,8 @@ async def test_dont_track_wired_clients(hass):
"""Test dont track wired clients config works."""
await setup_unifi_integration(
hass,
ENTRY_CONFIG,
options={unifi.controller.CONF_TRACK_WIRED_CLIENTS: False},
sites=SITES,
clients_response=[CLIENT_1, CLIENT_2],
devices_response=[],
clients_all_response=[],
)
assert len(hass.states.async_all()) == 3