Adapt to Axis library file structure changes (#114181)

* Adapt to axis library file structure changes

* Bump axis to v59
pull/114188/head
Robert Svensson 2024-03-25 17:16:41 +01:00 committed by GitHub
parent b71cbeff51
commit c1e1db9863
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 35 additions and 27 deletions

View File

@ -6,11 +6,11 @@ from collections.abc import Callable
from dataclasses import dataclass
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.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 (
BinarySensorDeviceClass,

View File

@ -5,7 +5,7 @@ from types import MappingProxyType
from typing import Any
import axis
from axis.configuration import Configuration
from axis.models.configuration import Configuration
from homeassistant.const import (
CONF_HOST,

View File

@ -6,9 +6,9 @@ from typing import Any
import axis
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.vapix.interfaces.mqtt import mqtt_json_to_event
from axis.vapix.models.mqtt import ClientState
from homeassistant.components import mqtt
from homeassistant.components.mqtt import DOMAIN as MQTT_DOMAIN

View File

@ -26,7 +26,7 @@
"iot_class": "local_push",
"loggers": ["axis"],
"quality_scale": "platinum",
"requirements": ["axis==58"],
"requirements": ["axis==59"],
"ssdp": [
{
"manufacturer": "AXIS"

View File

@ -514,7 +514,7 @@ aurorapy==0.2.7
# avion==0.10
# homeassistant.components.axis
axis==58
axis==59
# homeassistant.components.azure_event_hub
azure-eventhub==5.11.1

View File

@ -454,7 +454,7 @@ auroranoaa==0.0.3
aurorapy==0.2.7
# homeassistant.components.axis
axis==58
axis==59
# homeassistant.components.azure_event_hub
azure-eventhub==5.11.1

View File

@ -1,6 +1,6 @@
"""Constants for Axis integration tests."""
from axis.vapix.models.api import CONTEXT
from axis.models.api import CONTEXT
MAC = "00408C123456"
FORMATTED_MAC = "00:40:8c:12:34:56"

View File

@ -19,7 +19,7 @@
}),
]),
'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')",
}),
'camera_sources': dict({

View File

@ -224,7 +224,7 @@ async def test_shutdown(config_entry_data) -> None:
async def test_get_device_fails(hass: HomeAssistant, config_entry_data) -> None:
"""Device unauthorized yields authentication required error."""
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):
await axis.hub.get_axis_api(hass, config_entry_data)
@ -234,7 +234,7 @@ async def test_get_device_device_unavailable(
) -> None:
"""Device unavailable yields cannot connect error."""
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):
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:
"""Device yield unknown error."""
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):
await axis.hub.get_axis_api(hass, config_entry_data)

View File

@ -4,7 +4,7 @@ from collections.abc import Callable
from typing import Any
from unittest.mock import patch
from axis.vapix.models.api import CONTEXT
from axis.models.api import CONTEXT
import pytest
import respx
@ -149,8 +149,10 @@ async def test_lights(
assert light_0.name == f"{NAME} IR Light 0"
# Turn on, set brightness, light already on
with patch("axis.vapix.vapix.LightHandler.activate_light") as mock_activate, patch(
"axis.vapix.vapix.LightHandler.set_manual_intensity"
with patch(
"axis.interfaces.vapix.LightHandler.activate_light"
) as mock_activate, patch(
"axis.interfaces.vapix.LightHandler.set_manual_intensity"
) as mock_set_intensity:
await hass.services.async_call(
LIGHT_DOMAIN,
@ -162,7 +164,9 @@ async def test_lights(
mock_set_intensity.assert_called_once_with("led0", 29)
# 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(
LIGHT_DOMAIN,
SERVICE_TURN_OFF,
@ -185,8 +189,10 @@ async def test_lights(
assert light_0.state == STATE_OFF
# Turn on, set brightness
with patch("axis.vapix.vapix.LightHandler.activate_light") as mock_activate, patch(
"axis.vapix.vapix.LightHandler.set_manual_intensity"
with patch(
"axis.interfaces.vapix.LightHandler.activate_light"
) as mock_activate, patch(
"axis.interfaces.vapix.LightHandler.set_manual_intensity"
) as mock_set_intensity:
await hass.services.async_call(
LIGHT_DOMAIN,
@ -198,7 +204,9 @@ async def test_lights(
mock_set_intensity.assert_not_called()
# 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(
LIGHT_DOMAIN,
SERVICE_TURN_OFF,

View File

@ -3,7 +3,7 @@
from collections.abc import Callable
from unittest.mock import patch
from axis.vapix.models.api import CONTEXT
from axis.models.api import CONTEXT
import pytest
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.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(
SWITCH_DOMAIN,
SERVICE_TURN_ON,
@ -74,7 +74,7 @@ async def test_switches_with_port_cgi(
)
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(
SWITCH_DOMAIN,
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
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(
SWITCH_DOMAIN,
SERVICE_TURN_ON,
@ -172,7 +172,7 @@ async def test_switches_with_port_management(
)
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(
SWITCH_DOMAIN,
SERVICE_TURN_OFF,