Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix more missing Image parameters #417

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions axis/vapix/models/parameters/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class ImageParam(ParamItem):

enabled: str
name: str
source: str
source: str | None
appearance: ImageAppearanceParamT
mpeg: ImageMpegParamT | None
overlay: ImageOverlayParamT | None
Expand All @@ -141,9 +141,9 @@ def decode(cls, data: tuple[str, ImageParamT]) -> Self:
id, raw = data
return cls(
id=id,
enabled=raw["Enabled"],
enabled=raw.get("Enabled", "yes"),
name=raw["Name"],
source=raw["Source"],
source=raw.get("Source"),
appearance=raw["Appearance"],
mpeg=raw.get("MPEG"),
overlay=raw.get("Overlay"),
Expand Down
15 changes: 14 additions & 1 deletion tests/parameters/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,15 @@
"""


IMAGE_MINIMAL_RESPONSE = """root.Image.I0.Name=
root.Image.I0.Appearance.Resolution=4CIF
root.Image.I0.Appearance.Rotation=0
root.Image.I0.Appearance.MirrorEnabled=no
root.Image.I0.Appearance.SquarePixelEnabled=no
root.Image.I0.Stream.Duration=0
"""


@pytest.fixture
def image_handler(axis_device: AxisDevice) -> ImageParameterHandler:
"""Return the param cgi mock object."""
Expand Down Expand Up @@ -358,7 +367,11 @@ async def test_image_handler(respx_mock, image_handler: ImageParameterHandler):

@pytest.mark.parametrize(
("image_response"),
[IMAGE_RESPONSE2, IMAGE_RESPONSE_MISSING_MPEG_KEY],
[
IMAGE_RESPONSE2,
IMAGE_RESPONSE_MISSING_MPEG_KEY,
IMAGE_MINIMAL_RESPONSE,
],
)
async def test_limited_image_data(
respx_mock, image_handler: ImageParameterHandler, image_response
Expand Down