mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-09 20:24:02 +00:00
Add smartcam pet detection toggle module (#1465)
This commit is contained in:

committed by
GitHub

parent
980f6a38ca
commit
fd6067e5a0
45
tests/smartcam/modules/test_petdetection.py
Normal file
45
tests/smartcam/modules/test_petdetection.py
Normal file
@@ -0,0 +1,45 @@
|
||||
"""Tests for smartcam pet detection module."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from kasa import Device
|
||||
from kasa.smartcam.smartcammodule import SmartCamModule
|
||||
|
||||
from ...device_fixtures import parametrize
|
||||
|
||||
petdetection = parametrize(
|
||||
"has pet detection",
|
||||
component_filter="petDetection",
|
||||
protocol_filter={"SMARTCAM"},
|
||||
)
|
||||
|
||||
|
||||
@petdetection
|
||||
async def test_petdetection(dev: Device):
|
||||
"""Test device pet detection."""
|
||||
pet = dev.modules.get(SmartCamModule.SmartCamPetDetection)
|
||||
assert pet
|
||||
|
||||
pde_feat = dev.features.get("pet_detection")
|
||||
assert pde_feat
|
||||
|
||||
original_enabled = pet.enabled
|
||||
|
||||
try:
|
||||
await pet.set_enabled(not original_enabled)
|
||||
await dev.update()
|
||||
assert pet.enabled is not original_enabled
|
||||
assert pde_feat.value is not original_enabled
|
||||
|
||||
await pet.set_enabled(original_enabled)
|
||||
await dev.update()
|
||||
assert pet.enabled is original_enabled
|
||||
assert pde_feat.value is original_enabled
|
||||
|
||||
await pde_feat.set_value(not original_enabled)
|
||||
await dev.update()
|
||||
assert pet.enabled is not original_enabled
|
||||
assert pde_feat.value is not original_enabled
|
||||
|
||||
finally:
|
||||
await pet.set_enabled(original_enabled)
|
Reference in New Issue
Block a user