Skip to content

Commit

Permalink
Support missing property EmbeddedDevelopment (#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kane610 authored Mar 31, 2024
1 parent de2740b commit 98ae247
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
5 changes: 3 additions & 2 deletions axis/models/parameters/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
48 changes: 48 additions & 0 deletions tests/parameters/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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()

0 comments on commit 98ae247

Please sign in to comment.