Axis lib migrates to httpx (#42054)
* Clean up some parameter naming * Bump lib * Bump to v39
This commit is contained in:
parent
d01a96d1ce
commit
de98168211
5 changed files with 22 additions and 27 deletions
|
@ -3,7 +3,7 @@
|
|||
"name": "Axis",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/axis",
|
||||
"requirements": ["axis==37"],
|
||||
"requirements": ["axis==39"],
|
||||
"zeroconf": [
|
||||
{ "type": "_axis-video._tcp.local.", "macaddress": "00408C*" },
|
||||
{ "type": "_axis-video._tcp.local.", "macaddress": "ACCC8E*" },
|
||||
|
|
|
@ -309,7 +309,7 @@ av==8.0.2
|
|||
avri-api==0.1.7
|
||||
|
||||
# homeassistant.components.axis
|
||||
axis==37
|
||||
axis==39
|
||||
|
||||
# homeassistant.components.azure_event_hub
|
||||
azure-eventhub==5.1.0
|
||||
|
|
|
@ -180,7 +180,7 @@ av==8.0.2
|
|||
avri-api==0.1.7
|
||||
|
||||
# homeassistant.components.axis
|
||||
axis==37
|
||||
axis==39
|
||||
|
||||
# homeassistant.components.azure_event_hub
|
||||
azure-eventhub==5.1.0
|
||||
|
|
|
@ -17,7 +17,7 @@ from homeassistant.const import (
|
|||
CONF_USERNAME,
|
||||
)
|
||||
|
||||
from .test_device import MAC, MODEL, NAME, setup_axis_integration, vapix_session_request
|
||||
from .test_device import MAC, MODEL, NAME, setup_axis_integration, vapix_request
|
||||
|
||||
from tests.async_mock import patch
|
||||
from tests.common import MockConfigEntry
|
||||
|
@ -32,7 +32,7 @@ async def test_flow_manual_configuration(hass):
|
|||
assert result["type"] == "form"
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
with patch("axis.vapix.session_request", new=vapix_session_request):
|
||||
with patch("axis.vapix.Vapix.request", new=vapix_request):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
|
@ -70,9 +70,7 @@ async def test_manual_configuration_update_configuration(hass):
|
|||
with patch(
|
||||
"homeassistant.components.axis.async_setup_entry",
|
||||
return_value=True,
|
||||
) as mock_setup_entry, patch(
|
||||
"axis.vapix.session_request", new=vapix_session_request
|
||||
):
|
||||
) as mock_setup_entry, patch("axis.vapix.Vapix.request", new=vapix_request):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
|
@ -101,7 +99,7 @@ async def test_flow_fails_already_configured(hass):
|
|||
assert result["type"] == "form"
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
with patch("axis.vapix.session_request", new=vapix_session_request):
|
||||
with patch("axis.vapix.Vapix.request", new=vapix_request):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
|
@ -188,7 +186,7 @@ async def test_flow_create_entry_multiple_existing_entries_of_same_model(hass):
|
|||
assert result["type"] == "form"
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
with patch("axis.vapix.session_request", new=vapix_session_request):
|
||||
with patch("axis.vapix.Vapix.request", new=vapix_request):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
|
@ -230,7 +228,7 @@ async def test_zeroconf_flow(hass):
|
|||
assert result["type"] == "form"
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
with patch("axis.vapix.session_request", new=vapix_session_request):
|
||||
with patch("axis.vapix.Vapix.request", new=vapix_request):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
|
@ -294,9 +292,7 @@ async def test_zeroconf_flow_updated_configuration(hass):
|
|||
with patch(
|
||||
"homeassistant.components.axis.async_setup_entry",
|
||||
return_value=True,
|
||||
) as mock_setup_entry, patch(
|
||||
"axis.vapix.session_request", new=vapix_session_request
|
||||
):
|
||||
) as mock_setup_entry, patch("axis.vapix.Vapix.request", new=vapix_request):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
AXIS_DOMAIN,
|
||||
data={
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
"""Test Axis device."""
|
||||
from copy import deepcopy
|
||||
import json
|
||||
from unittest import mock
|
||||
|
||||
import axis as axislib
|
||||
|
@ -197,22 +196,22 @@ root.StreamProfile.S1.Parameters=videocodec=h265
|
|||
"""
|
||||
|
||||
|
||||
def vapix_session_request(session, url, **kwargs):
|
||||
def vapix_request(self, session, url, **kwargs):
|
||||
"""Return data based on url."""
|
||||
if API_DISCOVERY_URL in url:
|
||||
return json.dumps(API_DISCOVERY_RESPONSE)
|
||||
return API_DISCOVERY_RESPONSE
|
||||
if APPLICATIONS_URL in url:
|
||||
return APPLICATIONS_LIST_RESPONSE
|
||||
if BASIC_DEVICE_INFO_URL in url:
|
||||
return json.dumps(BASIC_DEVICE_INFO_RESPONSE)
|
||||
return BASIC_DEVICE_INFO_RESPONSE
|
||||
if LIGHT_CONTROL_URL in url:
|
||||
return json.dumps(LIGHT_CONTROL_RESPONSE)
|
||||
return LIGHT_CONTROL_RESPONSE
|
||||
if MQTT_CLIENT_URL in url:
|
||||
return json.dumps(MQTT_CLIENT_RESPONSE)
|
||||
return MQTT_CLIENT_RESPONSE
|
||||
if PORT_MANAGEMENT_URL in url:
|
||||
return json.dumps(PORT_MANAGEMENT_RESPONSE)
|
||||
return PORT_MANAGEMENT_RESPONSE
|
||||
if VMD4_URL in url:
|
||||
return json.dumps(VMD4_RESPONSE)
|
||||
return VMD4_RESPONSE
|
||||
if BRAND_URL in url:
|
||||
return BRAND_RESPONSE
|
||||
if IOPORT_URL in url or INPUT_URL in url or OUTPUT_URL in url:
|
||||
|
@ -235,7 +234,7 @@ async def setup_axis_integration(hass, config=ENTRY_CONFIG, options=ENTRY_OPTION
|
|||
)
|
||||
config_entry.add_to_hass(hass)
|
||||
|
||||
with patch("axis.vapix.session_request", new=vapix_session_request), patch(
|
||||
with patch("axis.vapix.Vapix.request", new=vapix_request), patch(
|
||||
"axis.rtsp.RTSPClient.start",
|
||||
return_value=True,
|
||||
):
|
||||
|
@ -314,7 +313,7 @@ async def test_update_address(hass):
|
|||
device = await setup_axis_integration(hass)
|
||||
assert device.api.config.host == "1.2.3.4"
|
||||
|
||||
with patch("axis.vapix.session_request", new=vapix_session_request), patch(
|
||||
with patch("axis.vapix.Vapix.request", new=vapix_request), patch(
|
||||
"homeassistant.components.axis.async_setup_entry",
|
||||
return_value=True,
|
||||
) as mock_setup_entry:
|
||||
|
@ -394,7 +393,7 @@ async def test_shutdown():
|
|||
async def test_get_device_fails(hass):
|
||||
"""Device unauthorized yields authentication required error."""
|
||||
with patch(
|
||||
"axis.vapix.session_request", side_effect=axislib.Unauthorized
|
||||
"axis.vapix.Vapix.request", side_effect=axislib.Unauthorized
|
||||
), pytest.raises(axis.errors.AuthenticationRequired):
|
||||
await axis.device.get_device(hass, host="", port="", username="", password="")
|
||||
|
||||
|
@ -402,7 +401,7 @@ async def test_get_device_fails(hass):
|
|||
async def test_get_device_device_unavailable(hass):
|
||||
"""Device unavailable yields cannot connect error."""
|
||||
with patch(
|
||||
"axis.vapix.session_request", side_effect=axislib.RequestError
|
||||
"axis.vapix.Vapix.request", side_effect=axislib.RequestError
|
||||
), pytest.raises(axis.errors.CannotConnect):
|
||||
await axis.device.get_device(hass, host="", port="", username="", password="")
|
||||
|
||||
|
@ -410,6 +409,6 @@ async def test_get_device_device_unavailable(hass):
|
|||
async def test_get_device_unknown_error(hass):
|
||||
"""Device yield unknown error."""
|
||||
with patch(
|
||||
"axis.vapix.session_request", side_effect=axislib.AxisException
|
||||
"axis.vapix.Vapix.request", side_effect=axislib.AxisException
|
||||
), pytest.raises(axis.errors.AuthenticationRequired):
|
||||
await axis.device.get_device(hass, host="", port="", username="", password="")
|
||||
|
|
Loading…
Add table
Reference in a new issue