Skip to content

Commit

Permalink
Add tests for the new update_stats
Browse files Browse the repository at this point in the history
  • Loading branch information
kimdv committed May 7, 2024
1 parent 289364f commit 78a7140
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,3 +1135,23 @@ async def test_led_status_request_exception(
)
with pytest.raises(AttributeError):
DeviceSetLedStatus.create(device, **data)


@pytest.mark.parametrize(("device_payload"), [[PDU_PRO]])
@pytest.mark.usefixtures("_mock_endpoints")
async def test_update_stats(unifi_controller: Controller) -> None:
"""Test device class uptime stats."""
await unifi_controller.devices.update()
device = next(iter(unifi_controller.devices.values()))

assert device.uptime_stats is not None
assert len(device.uptime_stats["WAN"].get("monitors")) == 3
assert len(device.uptime_stats["WAN2"].get("monitors")) == 3

assert device.uptime_stats["WAN"].get("monitors")[0].get("availability") == 100.0
assert device.uptime_stats["WAN"].get("monitors")[0].get("latency_average") == 5
assert (
device.uptime_stats["WAN"].get("monitors")[0].get("target")
== "www.microsoft.com"
)
assert device.uptime_stats["WAN"].get("monitors")[0].get("type") == "icmp"

0 comments on commit 78a7140

Please sign in to comment.