Skip to content

Commit

Permalink
chore: add test coverage for chime type (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Jul 4, 2024
1 parent cbfaca1 commit 7de37ae
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/data/test_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from tests.conftest import TEST_CAMERA_EXISTS
from uiprotect.data import (
Camera,
ChimeType,
DoorbellMessageType,
HDRMode,
IRLEDMode,
Expand Down Expand Up @@ -482,6 +483,32 @@ async def test_camera_set_chime_duration_no_chime(camera_obj: Camera | None):
assert not camera_obj.api.api_request.called


@pytest.mark.skipif(not TEST_CAMERA_EXISTS, reason="Missing testdata")
@pytest.mark.asyncio()
async def test_camera_mechanical_chime(
camera_obj: Camera | None,
):
if camera_obj is None:
pytest.skip("No camera_obj obj found")
camera_obj.feature_flags.has_chime = True
camera_obj.chime_duration = timedelta(seconds=0.3)
assert camera_obj.chime_duration_seconds == 0.3
assert camera_obj.chime_type is ChimeType.MECHANICAL


@pytest.mark.skipif(not TEST_CAMERA_EXISTS, reason="Missing testdata")
@pytest.mark.asyncio()
async def test_camera_no_chime(
camera_obj: Camera | None,
):
if camera_obj is None:
pytest.skip("No camera_obj obj found")
camera_obj.feature_flags.has_chime = True
camera_obj.chime_duration = timedelta(seconds=0)
assert camera_obj.chime_duration_seconds == 0
assert camera_obj.chime_type is ChimeType.NONE


@pytest.mark.skipif(not TEST_CAMERA_EXISTS, reason="Missing testdata")
@pytest.mark.parametrize("duration", [-1, 0, 0.5, 1, 20])
@pytest.mark.asyncio()
Expand All @@ -497,6 +524,7 @@ async def test_camera_set_chime_duration_duration(
camera_obj.feature_flags.has_chime = True
camera_obj.chime_duration = timedelta(seconds=300)
assert camera_obj.chime_duration_seconds == 300
assert camera_obj.chime_type is ChimeType.DIGITAL
camera_obj.mic_volume = 10

if duration in {-1, 20}:
Expand Down

0 comments on commit 7de37ae

Please sign in to comment.