Files
core/tests/components/snmp/test_init.py
Niccolò Maggioni 9f3d890e91 Bump pysnmp to v7 and brother to v5 (#129761)
Co-authored-by: Maciej Bieniek <bieniu@users.noreply.github.com>
2025-07-14 10:46:13 +02:00

23 lines
777 B
Python

"""SNMP tests."""
from unittest.mock import patch
from pysnmp.hlapi.v3arch.asyncio import SnmpEngine
from pysnmp.hlapi.v3arch.asyncio.cmdgen import LCD
from homeassistant.components import snmp
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
from homeassistant.core import HomeAssistant
async def test_async_get_snmp_engine(hass: HomeAssistant) -> None:
"""Test async_get_snmp_engine."""
engine = await snmp.async_get_snmp_engine(hass)
assert isinstance(engine, SnmpEngine)
engine2 = await snmp.async_get_snmp_engine(hass)
assert engine is engine2
with patch.object(LCD, "unconfigure") as mock_unconfigure:
hass.bus.async_fire(EVENT_HOMEASSISTANT_STOP)
await hass.async_block_till_done()
assert mock_unconfigure.called