Skip to content

Commit

Permalink
Minor improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
Kane610 committed Dec 30, 2023
1 parent fa10e30 commit 7c6d3dd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 25 deletions.
2 changes: 1 addition & 1 deletion axis/vapix/interfaces/parameters/param_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, param_handler: "Params") -> None:

def supported(self) -> bool:
"""Is parameter supported."""
return self.vapix.params.get_param(self.parameter_group) != {}
return self.get_params() != {}

@abstractmethod
def get_params(self) -> dict[str, ApiItemT]:
Expand Down
24 changes: 1 addition & 23 deletions axis/vapix/models/light_control.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Light Control API data model."""

from dataclasses import dataclass, field
from dataclasses import dataclass

import orjson
from typing_extensions import NotRequired, Self, TypedDict
Expand Down Expand Up @@ -240,28 +240,6 @@ def from_list(cls, data: list[RangeT]) -> list["Range"]:
return [Range.from_dict(range) for range in data]


@dataclass
class ApiVersion:
"""Handle API version."""

_default_api_version: str = field(init=False)
api_version: str | None = None

@property
def _api_version(self) -> str:
"""API version or default API version."""
if self.api_version is not None:
return self.api_version
return self._default_api_version


@dataclass
class _ApiVersion(ApiVersion):
"""Light control API version."""

_default_api_version = API_VERSION


@dataclass
class GetLightInformationRequest(ApiRequest):
"""Request object for getting light information."""
Expand Down
8 changes: 7 additions & 1 deletion tests/test_param_cgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,23 @@
import pytest
import respx

from axis.device import AxisDevice
from axis.vapix.interfaces.parameters.param_cgi import Params

from .conftest import HOST


@pytest.fixture
def params(axis_device) -> Params:
def params(axis_device: AxisDevice) -> Params:
"""Return the param cgi mock object."""
return axis_device.vapix.params


async def test_param_api_request(params: Params):
"""Verify that you can list parameters."""
assert await params._api_request() == {}


@respx.mock
async def test_params(params: Params):
"""Verify that you can list parameters."""
Expand Down

0 comments on commit 7c6d3dd

Please sign in to comment.