Skip to content

Commit

Permalink
Fix missing application properties (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kane610 authored Mar 11, 2024
1 parent 6ba7e6e commit 14f350f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
4 changes: 2 additions & 2 deletions axis/vapix/interfaces/applications/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ def listed_in_parameters(self) -> bool:

async def _api_request(self) -> dict[str, Application]:
"""Get default data of API discovery."""
return await self.get_api_list()
return await self.list_applications()

async def get_api_list(self) -> dict[str, Application]:
async def list_applications(self) -> dict[str, Application]:
"""List all APIs registered on API Discovery service."""
bytes_data = await self.vapix.api_request(ListApplicationsRequest())
response = ListApplicationsResponse.decode(bytes_data)
Expand Down
8 changes: 4 additions & 4 deletions axis/vapix/models/applications/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ class ApplicationStatus(enum.StrEnum):
class Application(ApiItem):
"""Representation of an Application instance."""

application_id: str
application_id: str | None
"""Id of application."""

configuration_page: str
configuration_page: str | None
"""Relative URL to application configuration page."""

license_name: str
Expand Down Expand Up @@ -130,8 +130,8 @@ def decode(cls, data: ApplicationObjectT) -> Self:
"""Decode dict to class object."""
return cls(
id=data["Name"],
application_id=data["ApplicationID"],
configuration_page=data["ConfigurationPage"],
application_id=data.get("ApplicationID"),
configuration_page=data.get("ConfigurationPage"),
license_name=data.get("LicenseName", ""),
license_status=ApplicationLicense(data["License"]),
license_expiration_date=data.get("LicenseExpirationDate", ""),
Expand Down
21 changes: 21 additions & 0 deletions tests/applications/test_applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ async def test_update_multiple_applications(
assert app.version == "2.2-6"


async def test_app_2(respx_mock, applications: ApplicationsHandler):
"""Test update applicatios call."""
respx_mock.post("/axis-cgi/applications/list.cgi").respond(
text=Q1615_MKII_9_80_LIST_APPLICATIONS_RESPONSE,
headers={"Content-Type": "text/xml"},
)
await applications.update()


LIST_APPLICATION_EMPTY_RESPONSE = """<reply result="ok">
</reply>"""

Expand All @@ -182,3 +191,15 @@ async def test_update_multiple_applications(
<application Name="loiteringguard" NiceName="AXIS Loitering Guard" Vendor="Axis Communications" Version="2.2-6" ApplicationID="46775" License="None" Status="Running" ConfigurationPage="local/loiteringguard/config.html" VendorHomePage="http://www.axis.com" LicenseName="Proprietary" />
<application Name="motionguard" NiceName="AXIS Motion Guard" Vendor="Axis Communications" Version="2.2-6" ApplicationID="48170" License="None" Status="Running" ConfigurationPage="local/motionguard/config.html" VendorHomePage="http://www.axis.com" LicenseName="Proprietary" />
</reply>"""

Q1615_MKII_9_80_LIST_APPLICATIONS_RESPONSE = """<reply result="ok">
<application Name="AxisConnectDeploymentAgentAcap" NiceName="AXIS Connect Deployment Agent" Vendor="Axis Communications" Version="1.3-438" ApplicationID="412994" License="None" Status="Running" LicenseName="AXIS" />
<application Name="TrafficWiz" NiceName="AXIS Traffic Wizard" Vendor="Axis Communications" Version="1.4-3" License="None" Status="Stopped" ConfigurationPage="local/TrafficWiz/index.html" />
<application Name="deviceDiagnostics" NiceName="AXIS Device Diagnostics" Vendor="Axis Communications" Version="4.228-0" ApplicationID="328106" License="None" Status="Running" ConfigurationPage="local/deviceDiagnostics/info.html" LicenseName="Proprietary" />
<application Name="fenceguard" NiceName="AXIS Fence Guard" Vendor="Axis Communications" Version="2.2-4" ApplicationID="47775" License="None" Status="Running" ConfigurationPage="local/fenceguard/config.html" VendorHomePage="http://www.axis.com" LicenseName="Proprietary" />
<application Name="loiteringguard" NiceName="AXIS Loitering Guard" Vendor="Axis Communications" Version="2.2-4" ApplicationID="46775" License="None" Status="Stopped" ConfigurationPage="local/loiteringguard/config.html" VendorHomePage="http://www.axis.com" LicenseName="Proprietary" />
<application Name="motionguard" NiceName="AXIS Motion Guard" Vendor="Axis Communications" Version="2.2-4" ApplicationID="48170" License="None" Status="Running" ConfigurationPage="local/motionguard/config.html" VendorHomePage="http://www.axis.com" LicenseName="Proprietary" />
<application Name="vmd" NiceName="AXIS Video Motion Detection" Vendor="Axis Communications" Version="4.5-2" ApplicationID="143440" License="None" Status="Running" ConfigurationPage="local/vmd/config.html" VendorHomePage="http://www.axis.com" LicenseName="Proprietary" />
<application Name="webrtc" NiceName="AXIS WebRTC" Vendor="Axis Communications" Version="4.15-2" ApplicationID="413622" License="None" Status="Running" ConfigurationPage="local/webrtc/webrtc.html" LicenseName="Available" />
</reply>
"""

0 comments on commit 14f350f

Please sign in to comment.