Adapt Axis integration to async HTTPx calls (#42095)
This commit is contained in:
1 parent
fcdb54d878
commit
1303d20064
9 files changed
+41
-40
No files matched your search
@@ -38,7 +38,7 @@ from homeassistant.const import (
|
||||
CONF_USERNAME,
|
||||
)
|
||||
|
||||
from tests.async_mock import Mock, patch
|
||||
from tests.async_mock import AsyncMock, Mock, patch
|
||||
from tests.common import MockConfigEntry, async_fire_mqtt_message
|
||||
|
||||
MAC = "00408C12345"
|
||||
@@ -196,7 +196,7 @@ root.StreamProfile.S1.Parameters=videocodec=h265
|
||||
"""
|
||||
|
||||
|
||||
def vapix_request(self, session, url, **kwargs):
|
||||
async def vapix_request(self, session, url, **kwargs):
|
||||
"""Return data based on url."""
|
||||
if API_DISCOVERY_URL in url:
|
||||
return API_DISCOVERY_RESPONSE
|
||||
@@ -384,10 +384,12 @@ async def test_shutdown():
|
||||
|
||||
axis_device = axis.device.AxisNetworkDevice(hass, entry)
|
||||
axis_device.api = Mock()
|
||||
axis_device.api.vapix.close = AsyncMock()
|
||||
|
||||
axis_device.shutdown(None)
|
||||
await axis_device.shutdown(None)
|
||||
|
||||
assert len(axis_device.api.stream.stop.mock_calls) == 1
|
||||
assert len(axis_device.api.vapix.close.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_get_device_fails(hass):
|
||||
|
||||
@@ -91,7 +91,7 @@ async def test_lights(hass):
|
||||
{"entity_id": f"light.{NAME}_ir_light_0", ATTR_BRIGHTNESS: 50},
|
||||
blocking=True,
|
||||
)
|
||||
mock_activate.not_called()
|
||||
mock_activate.assert_not_awaited()
|
||||
mock_set_intensity.assert_called_once_with("led0", 29)
|
||||
|
||||
# Turn off
|
||||
|
||||
@@ -13,7 +13,7 @@ from .test_device import (
|
||||
setup_axis_integration,
|
||||
)
|
||||
|
||||
from tests.async_mock import Mock, patch
|
||||
from tests.async_mock import AsyncMock, patch
|
||||
|
||||
EVENTS = [
|
||||
{
|
||||
@@ -55,8 +55,10 @@ async def test_switches_with_port_cgi(hass):
|
||||
"""Test that switches are loaded properly using port.cgi."""
|
||||
device = await setup_axis_integration(hass)
|
||||
|
||||
device.api.vapix.ports = {"0": Mock(), "1": Mock()}
|
||||
device.api.vapix.ports = {"0": AsyncMock(), "1": AsyncMock()}
|
||||
device.api.vapix.ports["0"].name = "Doorbell"
|
||||
device.api.vapix.ports["0"].open = AsyncMock()
|
||||
device.api.vapix.ports["0"].close = AsyncMock()
|
||||
device.api.vapix.ports["1"].name = ""
|
||||
|
||||
for event in EVENTS:
|
||||
@@ -98,8 +100,10 @@ async def test_switches_with_port_management(hass):
|
||||
with patch.dict(API_DISCOVERY_RESPONSE, api_discovery):
|
||||
device = await setup_axis_integration(hass)
|
||||
|
||||
device.api.vapix.ports = {"0": Mock(), "1": Mock()}
|
||||
device.api.vapix.ports = {"0": AsyncMock(), "1": AsyncMock()}
|
||||
device.api.vapix.ports["0"].name = "Doorbell"
|
||||
device.api.vapix.ports["0"].open = AsyncMock()
|
||||
device.api.vapix.ports["0"].close = AsyncMock()
|
||||
device.api.vapix.ports["1"].name = ""
|
||||
|
||||
for event in EVENTS:
|
||||
|
||||
Reference in new issue
Block a user