mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Adapt to Axis library file structure changes (#114181)
* Adapt to axis library file structure changes * Bump axis to v59
This commit is contained in:
parent
b71cbeff51
commit
c1e1db9863
@ -6,11 +6,11 @@ from collections.abc import Callable
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
from axis.interfaces.applications.fence_guard import FenceGuardHandler
|
||||||
|
from axis.interfaces.applications.loitering_guard import LoiteringGuardHandler
|
||||||
|
from axis.interfaces.applications.motion_guard import MotionGuardHandler
|
||||||
|
from axis.interfaces.applications.vmd4 import Vmd4Handler
|
||||||
from axis.models.event import Event, EventTopic
|
from axis.models.event import Event, EventTopic
|
||||||
from axis.vapix.interfaces.applications.fence_guard import FenceGuardHandler
|
|
||||||
from axis.vapix.interfaces.applications.loitering_guard import LoiteringGuardHandler
|
|
||||||
from axis.vapix.interfaces.applications.motion_guard import MotionGuardHandler
|
|
||||||
from axis.vapix.interfaces.applications.vmd4 import Vmd4Handler
|
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import (
|
from homeassistant.components.binary_sensor import (
|
||||||
BinarySensorDeviceClass,
|
BinarySensorDeviceClass,
|
||||||
|
@ -5,7 +5,7 @@ from types import MappingProxyType
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import axis
|
import axis
|
||||||
from axis.configuration import Configuration
|
from axis.models.configuration import Configuration
|
||||||
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
|
@ -6,9 +6,9 @@ from typing import Any
|
|||||||
|
|
||||||
import axis
|
import axis
|
||||||
from axis.errors import Unauthorized
|
from axis.errors import Unauthorized
|
||||||
|
from axis.interfaces.mqtt import mqtt_json_to_event
|
||||||
|
from axis.models.mqtt import ClientState
|
||||||
from axis.stream_manager import Signal, State
|
from axis.stream_manager import Signal, State
|
||||||
from axis.vapix.interfaces.mqtt import mqtt_json_to_event
|
|
||||||
from axis.vapix.models.mqtt import ClientState
|
|
||||||
|
|
||||||
from homeassistant.components import mqtt
|
from homeassistant.components import mqtt
|
||||||
from homeassistant.components.mqtt import DOMAIN as MQTT_DOMAIN
|
from homeassistant.components.mqtt import DOMAIN as MQTT_DOMAIN
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
"iot_class": "local_push",
|
"iot_class": "local_push",
|
||||||
"loggers": ["axis"],
|
"loggers": ["axis"],
|
||||||
"quality_scale": "platinum",
|
"quality_scale": "platinum",
|
||||||
"requirements": ["axis==58"],
|
"requirements": ["axis==59"],
|
||||||
"ssdp": [
|
"ssdp": [
|
||||||
{
|
{
|
||||||
"manufacturer": "AXIS"
|
"manufacturer": "AXIS"
|
||||||
|
@ -514,7 +514,7 @@ aurorapy==0.2.7
|
|||||||
# avion==0.10
|
# avion==0.10
|
||||||
|
|
||||||
# homeassistant.components.axis
|
# homeassistant.components.axis
|
||||||
axis==58
|
axis==59
|
||||||
|
|
||||||
# homeassistant.components.azure_event_hub
|
# homeassistant.components.azure_event_hub
|
||||||
azure-eventhub==5.11.1
|
azure-eventhub==5.11.1
|
||||||
|
@ -454,7 +454,7 @@ auroranoaa==0.0.3
|
|||||||
aurorapy==0.2.7
|
aurorapy==0.2.7
|
||||||
|
|
||||||
# homeassistant.components.axis
|
# homeassistant.components.axis
|
||||||
axis==58
|
axis==59
|
||||||
|
|
||||||
# homeassistant.components.azure_event_hub
|
# homeassistant.components.azure_event_hub
|
||||||
azure-eventhub==5.11.1
|
azure-eventhub==5.11.1
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
"""Constants for Axis integration tests."""
|
"""Constants for Axis integration tests."""
|
||||||
|
|
||||||
from axis.vapix.models.api import CONTEXT
|
from axis.models.api import CONTEXT
|
||||||
|
|
||||||
MAC = "00408C123456"
|
MAC = "00408C123456"
|
||||||
FORMATTED_MAC = "00:40:8c:12:34:56"
|
FORMATTED_MAC = "00:40:8c:12:34:56"
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
}),
|
}),
|
||||||
]),
|
]),
|
||||||
'basic_device_info': dict({
|
'basic_device_info': dict({
|
||||||
'__type': "<class 'axis.vapix.models.basic_device_info.DeviceInformation'>",
|
'__type': "<class 'axis.models.basic_device_info.DeviceInformation'>",
|
||||||
'repr': "DeviceInformation(id='0', architecture='str', brand='str', build_date='str', firmware_version='9.80.1', hardware_id='str', product_full_name='str', product_number='M1065-LW', product_short_name='str', product_type='Network Camera', product_variant='str', serial_number='00408C123456', soc='str', soc_serial_number='str', web_url='str')",
|
'repr': "DeviceInformation(id='0', architecture='str', brand='str', build_date='str', firmware_version='9.80.1', hardware_id='str', product_full_name='str', product_number='M1065-LW', product_short_name='str', product_type='Network Camera', product_variant='str', serial_number='00408C123456', soc='str', soc_serial_number='str', web_url='str')",
|
||||||
}),
|
}),
|
||||||
'camera_sources': dict({
|
'camera_sources': dict({
|
||||||
|
@ -224,7 +224,7 @@ async def test_shutdown(config_entry_data) -> None:
|
|||||||
async def test_get_device_fails(hass: HomeAssistant, config_entry_data) -> None:
|
async def test_get_device_fails(hass: HomeAssistant, config_entry_data) -> None:
|
||||||
"""Device unauthorized yields authentication required error."""
|
"""Device unauthorized yields authentication required error."""
|
||||||
with patch(
|
with patch(
|
||||||
"axis.vapix.vapix.Vapix.initialize", side_effect=axislib.Unauthorized
|
"axis.interfaces.vapix.Vapix.initialize", side_effect=axislib.Unauthorized
|
||||||
), pytest.raises(axis.errors.AuthenticationRequired):
|
), pytest.raises(axis.errors.AuthenticationRequired):
|
||||||
await axis.hub.get_axis_api(hass, config_entry_data)
|
await axis.hub.get_axis_api(hass, config_entry_data)
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ async def test_get_device_device_unavailable(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Device unavailable yields cannot connect error."""
|
"""Device unavailable yields cannot connect error."""
|
||||||
with patch(
|
with patch(
|
||||||
"axis.vapix.vapix.Vapix.request", side_effect=axislib.RequestError
|
"axis.interfaces.vapix.Vapix.request", side_effect=axislib.RequestError
|
||||||
), pytest.raises(axis.errors.CannotConnect):
|
), pytest.raises(axis.errors.CannotConnect):
|
||||||
await axis.hub.get_axis_api(hass, config_entry_data)
|
await axis.hub.get_axis_api(hass, config_entry_data)
|
||||||
|
|
||||||
@ -242,6 +242,6 @@ async def test_get_device_device_unavailable(
|
|||||||
async def test_get_device_unknown_error(hass: HomeAssistant, config_entry_data) -> None:
|
async def test_get_device_unknown_error(hass: HomeAssistant, config_entry_data) -> None:
|
||||||
"""Device yield unknown error."""
|
"""Device yield unknown error."""
|
||||||
with patch(
|
with patch(
|
||||||
"axis.vapix.vapix.Vapix.request", side_effect=axislib.AxisException
|
"axis.interfaces.vapix.Vapix.request", side_effect=axislib.AxisException
|
||||||
), pytest.raises(axis.errors.AuthenticationRequired):
|
), pytest.raises(axis.errors.AuthenticationRequired):
|
||||||
await axis.hub.get_axis_api(hass, config_entry_data)
|
await axis.hub.get_axis_api(hass, config_entry_data)
|
||||||
|
@ -4,7 +4,7 @@ from collections.abc import Callable
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from axis.vapix.models.api import CONTEXT
|
from axis.models.api import CONTEXT
|
||||||
import pytest
|
import pytest
|
||||||
import respx
|
import respx
|
||||||
|
|
||||||
@ -149,8 +149,10 @@ async def test_lights(
|
|||||||
assert light_0.name == f"{NAME} IR Light 0"
|
assert light_0.name == f"{NAME} IR Light 0"
|
||||||
|
|
||||||
# Turn on, set brightness, light already on
|
# Turn on, set brightness, light already on
|
||||||
with patch("axis.vapix.vapix.LightHandler.activate_light") as mock_activate, patch(
|
with patch(
|
||||||
"axis.vapix.vapix.LightHandler.set_manual_intensity"
|
"axis.interfaces.vapix.LightHandler.activate_light"
|
||||||
|
) as mock_activate, patch(
|
||||||
|
"axis.interfaces.vapix.LightHandler.set_manual_intensity"
|
||||||
) as mock_set_intensity:
|
) as mock_set_intensity:
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
LIGHT_DOMAIN,
|
LIGHT_DOMAIN,
|
||||||
@ -162,7 +164,9 @@ async def test_lights(
|
|||||||
mock_set_intensity.assert_called_once_with("led0", 29)
|
mock_set_intensity.assert_called_once_with("led0", 29)
|
||||||
|
|
||||||
# Turn off
|
# Turn off
|
||||||
with patch("axis.vapix.vapix.LightHandler.deactivate_light") as mock_deactivate:
|
with patch(
|
||||||
|
"axis.interfaces.vapix.LightHandler.deactivate_light"
|
||||||
|
) as mock_deactivate:
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
LIGHT_DOMAIN,
|
LIGHT_DOMAIN,
|
||||||
SERVICE_TURN_OFF,
|
SERVICE_TURN_OFF,
|
||||||
@ -185,8 +189,10 @@ async def test_lights(
|
|||||||
assert light_0.state == STATE_OFF
|
assert light_0.state == STATE_OFF
|
||||||
|
|
||||||
# Turn on, set brightness
|
# Turn on, set brightness
|
||||||
with patch("axis.vapix.vapix.LightHandler.activate_light") as mock_activate, patch(
|
with patch(
|
||||||
"axis.vapix.vapix.LightHandler.set_manual_intensity"
|
"axis.interfaces.vapix.LightHandler.activate_light"
|
||||||
|
) as mock_activate, patch(
|
||||||
|
"axis.interfaces.vapix.LightHandler.set_manual_intensity"
|
||||||
) as mock_set_intensity:
|
) as mock_set_intensity:
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
LIGHT_DOMAIN,
|
LIGHT_DOMAIN,
|
||||||
@ -198,7 +204,9 @@ async def test_lights(
|
|||||||
mock_set_intensity.assert_not_called()
|
mock_set_intensity.assert_not_called()
|
||||||
|
|
||||||
# Turn off, light already off
|
# Turn off, light already off
|
||||||
with patch("axis.vapix.vapix.LightHandler.deactivate_light") as mock_deactivate:
|
with patch(
|
||||||
|
"axis.interfaces.vapix.LightHandler.deactivate_light"
|
||||||
|
) as mock_deactivate:
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
LIGHT_DOMAIN,
|
LIGHT_DOMAIN,
|
||||||
SERVICE_TURN_OFF,
|
SERVICE_TURN_OFF,
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from axis.vapix.models.api import CONTEXT
|
from axis.models.api import CONTEXT
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
||||||
@ -65,7 +65,7 @@ async def test_switches_with_port_cgi(
|
|||||||
assert relay_0.state == STATE_OFF
|
assert relay_0.state == STATE_OFF
|
||||||
assert relay_0.name == f"{NAME} Doorbell"
|
assert relay_0.name == f"{NAME} Doorbell"
|
||||||
|
|
||||||
with patch("axis.vapix.vapix.Ports.close") as mock_turn_on:
|
with patch("axis.interfaces.vapix.Ports.close") as mock_turn_on:
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
SWITCH_DOMAIN,
|
SWITCH_DOMAIN,
|
||||||
SERVICE_TURN_ON,
|
SERVICE_TURN_ON,
|
||||||
@ -74,7 +74,7 @@ async def test_switches_with_port_cgi(
|
|||||||
)
|
)
|
||||||
mock_turn_on.assert_called_once_with("0")
|
mock_turn_on.assert_called_once_with("0")
|
||||||
|
|
||||||
with patch("axis.vapix.vapix.Ports.open") as mock_turn_off:
|
with patch("axis.interfaces.vapix.Ports.open") as mock_turn_off:
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
SWITCH_DOMAIN,
|
SWITCH_DOMAIN,
|
||||||
SERVICE_TURN_OFF,
|
SERVICE_TURN_OFF,
|
||||||
@ -163,7 +163,7 @@ async def test_switches_with_port_management(
|
|||||||
|
|
||||||
assert hass.states.get(f"{SWITCH_DOMAIN}.{NAME}_relay_1").state == STATE_ON
|
assert hass.states.get(f"{SWITCH_DOMAIN}.{NAME}_relay_1").state == STATE_ON
|
||||||
|
|
||||||
with patch("axis.vapix.vapix.IoPortManagement.close") as mock_turn_on:
|
with patch("axis.interfaces.vapix.IoPortManagement.close") as mock_turn_on:
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
SWITCH_DOMAIN,
|
SWITCH_DOMAIN,
|
||||||
SERVICE_TURN_ON,
|
SERVICE_TURN_ON,
|
||||||
@ -172,7 +172,7 @@ async def test_switches_with_port_management(
|
|||||||
)
|
)
|
||||||
mock_turn_on.assert_called_once_with("0")
|
mock_turn_on.assert_called_once_with("0")
|
||||||
|
|
||||||
with patch("axis.vapix.vapix.IoPortManagement.open") as mock_turn_off:
|
with patch("axis.interfaces.vapix.IoPortManagement.open") as mock_turn_off:
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
SWITCH_DOMAIN,
|
SWITCH_DOMAIN,
|
||||||
SERVICE_TURN_OFF,
|
SERVICE_TURN_OFF,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user