From 98ae247a8a5e54f245ddac46b3e4897a5ec2897c Mon Sep 17 00:00:00 2001 From: Robert Svensson Date: Sun, 31 Mar 2024 16:40:43 +0200 Subject: [PATCH] Support missing property EmbeddedDevelopment (#428) --- axis/models/parameters/properties.py | 5 +-- tests/parameters/test_properties.py | 48 ++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/axis/models/parameters/properties.py b/axis/models/parameters/properties.py index 6916d771..965c7db9 100644 --- a/axis/models/parameters/properties.py +++ b/axis/models/parameters/properties.py @@ -188,8 +188,9 @@ def decode(cls, data: PropertyParamT) -> Self: .get("PTZ", {}) .get("Presets", {}) .get("Version", False), - embedded_development=data["EmbeddedDevelopment"]["Version"], - # embedded_development=data.get("EmbeddedDevelopment_Version", "0.0"), + embedded_development=data.get("EmbeddedDevelopment", {}).get( + "Version", "0.0" + ), firmware_build_date=data["Firmware"]["BuildDate"], firmware_build_number=data["Firmware"]["BuildNumber"], firmware_version=data["Firmware"]["Version"], diff --git a/tests/parameters/test_properties.py b/tests/parameters/test_properties.py index 45ff7d61..a06c727c 100644 --- a/tests/parameters/test_properties.py +++ b/tests/parameters/test_properties.py @@ -107,6 +107,39 @@ root.Properties.ZipStream.ZipStream=yes""" +PROPERTY_5_20_M7001_RESPONSE = """root.Properties.API.HTTP.Version=3 +root.Properties.API.HTTP.AdminPath=/operator/basic.shtml +root.Properties.API.Metadata.Metadata=no +root.Properties.API.Metadata.Version=1.0 +root.Properties.API.RTSP.Version=2.01 +root.Properties.API.RTSP.RTSPAuth=yes +root.Properties.API.WebService.WebService=yes +root.Properties.API.WebService.ONVIF.ONVIF=yes +root.Properties.API.WebService.ONVIF.Version=1.01 +root.Properties.Firmware.BuildNumber=1 +root.Properties.Firmware.BuildDate=Jun 13 2017 14:38 +root.Properties.Firmware.Version=5.20.5 +root.Properties.GuardTour.GuardTour=yes +root.Properties.HTTPS.HTTPS=yes +root.Properties.Image.Rotation=0,90,180,270 +root.Properties.Image.Resolution=D1,4CIF,2CIF,CIF,QCIF +root.Properties.Image.Format=jpeg,mjpeg,h264,bitmap +root.Properties.Image.NbrOfViews=1 +root.Properties.Motion.Motion=yes +root.Properties.Motion.MaxNbrOfWindows=10 +root.Properties.PTZ.PTZ=yes +root.Properties.PTZ.DigitalPTZ=no +root.Properties.PTZ.DriverManagement=yes +root.Properties.RemoteService.RemoteService=yes +root.Properties.RTC.RTC=no +root.Properties.Serial.Serial=yes +root.Properties.System.Language=English +root.Properties.System.HardwareID=163 +root.Properties.System.SerialNumber=ACCC8E1A909D +root.Properties.System.Architecture=crisv32 +""" + + @pytest.fixture def property_handler(axis_device: AxisDevice) -> PropertyParameterHandler: """Return the param cgi mock object.""" @@ -170,3 +203,18 @@ async def test_property_handler(respx_mock, property_handler: PropertyParameterH assert properties.ptz is True # assert params[f"{PROPERTIES}.Sensor.PIR"] == "yes" assert properties.system_serial_number == "ACCC12345678" + + +@pytest.mark.parametrize(("property_response"), [PROPERTY_5_20_M7001_RESPONSE]) +async def test_mixed_properties( + respx_mock, property_handler: PropertyParameterHandler, property_response +): + """Verify that update ptz works. + + No embedded development provided. + """ + respx_mock.post( + "/axis-cgi/param.cgi", data={"action": "list", "group": "root.Properties"} + ).respond(text=property_response, headers={"Content-Type": "text/plain"}) + + await property_handler.update()