mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-09 20:24:02 +00:00
Rename smartcamera to smartcam (#1300)
This commit is contained in:
@@ -13,11 +13,11 @@ from kasa import (
|
||||
)
|
||||
from kasa.iot import IotBulb, IotDimmer, IotLightStrip, IotPlug, IotStrip, IotWallSwitch
|
||||
from kasa.smart import SmartDevice
|
||||
from kasa.smartcamera.smartcamera import SmartCamera
|
||||
from kasa.smartcam import SmartCamDevice
|
||||
|
||||
from .fakeprotocol_iot import FakeIotProtocol
|
||||
from .fakeprotocol_smart import FakeSmartProtocol
|
||||
from .fakeprotocol_smartcamera import FakeSmartCameraProtocol
|
||||
from .fakeprotocol_smartcam import FakeSmartCamProtocol
|
||||
from .fixtureinfo import (
|
||||
FIXTURE_DATA,
|
||||
ComponentFilter,
|
||||
@@ -317,16 +317,16 @@ device_smart = parametrize(
|
||||
device_iot = parametrize(
|
||||
"devices iot", model_filter=ALL_DEVICES_IOT, protocol_filter={"IOT"}
|
||||
)
|
||||
device_smartcamera = parametrize("devices smartcamera", protocol_filter={"SMARTCAMERA"})
|
||||
camera_smartcamera = parametrize(
|
||||
"camera smartcamera",
|
||||
device_smartcam = parametrize("devices smartcam", protocol_filter={"SMARTCAM"})
|
||||
camera_smartcam = parametrize(
|
||||
"camera smartcam",
|
||||
device_type_filter=[DeviceType.Camera],
|
||||
protocol_filter={"SMARTCAMERA"},
|
||||
protocol_filter={"SMARTCAM"},
|
||||
)
|
||||
hub_smartcamera = parametrize(
|
||||
"hub smartcamera",
|
||||
hub_smartcam = parametrize(
|
||||
"hub smartcam",
|
||||
device_type_filter=[DeviceType.Hub],
|
||||
protocol_filter={"SMARTCAMERA"},
|
||||
protocol_filter={"SMARTCAM"},
|
||||
)
|
||||
|
||||
|
||||
@@ -344,8 +344,8 @@ def check_categories():
|
||||
+ hubs_smart.args[1]
|
||||
+ sensors_smart.args[1]
|
||||
+ thermostats_smart.args[1]
|
||||
+ camera_smartcamera.args[1]
|
||||
+ hub_smartcamera.args[1]
|
||||
+ camera_smartcam.args[1]
|
||||
+ hub_smartcam.args[1]
|
||||
)
|
||||
diffs: set[FixtureInfo] = set(FIXTURE_DATA) - set(categorized_fixtures)
|
||||
if diffs:
|
||||
@@ -363,8 +363,8 @@ check_categories()
|
||||
def device_for_fixture_name(model, protocol):
|
||||
if protocol in {"SMART", "SMART.CHILD"}:
|
||||
return SmartDevice
|
||||
elif protocol == "SMARTCAMERA":
|
||||
return SmartCamera
|
||||
elif protocol == "SMARTCAM":
|
||||
return SmartCamDevice
|
||||
else:
|
||||
for d in STRIPS_IOT:
|
||||
if d in model:
|
||||
@@ -420,8 +420,8 @@ async def get_device_for_fixture(
|
||||
d.protocol = FakeSmartProtocol(
|
||||
fixture_data.data, fixture_data.name, verbatim=verbatim
|
||||
)
|
||||
elif fixture_data.protocol == "SMARTCAMERA":
|
||||
d.protocol = FakeSmartCameraProtocol(
|
||||
elif fixture_data.protocol == "SMARTCAM":
|
||||
d.protocol = FakeSmartCamProtocol(
|
||||
fixture_data.data, fixture_data.name, verbatim=verbatim
|
||||
)
|
||||
else:
|
||||
@@ -460,8 +460,8 @@ def get_fixture_info(fixture, protocol):
|
||||
def get_nearest_fixture_to_ip(dev):
|
||||
if isinstance(dev, SmartDevice):
|
||||
protocol_fixtures = filter_fixtures("", protocol_filter={"SMART"})
|
||||
elif isinstance(dev, SmartCamera):
|
||||
protocol_fixtures = filter_fixtures("", protocol_filter={"SMARTCAMERA"})
|
||||
elif isinstance(dev, SmartCamDevice):
|
||||
protocol_fixtures = filter_fixtures("", protocol_filter={"SMARTCAM"})
|
||||
else:
|
||||
protocol_fixtures = filter_fixtures("", protocol_filter={"IOT"})
|
||||
assert protocol_fixtures, "Unknown device type"
|
||||
|
@@ -11,7 +11,7 @@ from kasa.transports.xortransport import XorEncryption
|
||||
|
||||
from .fakeprotocol_iot import FakeIotProtocol
|
||||
from .fakeprotocol_smart import FakeSmartProtocol, FakeSmartTransport
|
||||
from .fakeprotocol_smartcamera import FakeSmartCameraProtocol
|
||||
from .fakeprotocol_smartcam import FakeSmartCamProtocol
|
||||
from .fixtureinfo import FixtureInfo, filter_fixtures, idgenerator
|
||||
|
||||
DISCOVERY_MOCK_IP = "127.0.0.123"
|
||||
@@ -194,8 +194,8 @@ def patch_discovery(fixture_infos: dict[str, FixtureInfo], mocker):
|
||||
protos = {
|
||||
ip: FakeSmartProtocol(fixture_info.data, fixture_info.name)
|
||||
if fixture_info.protocol in {"SMART", "SMART.CHILD"}
|
||||
else FakeSmartCameraProtocol(fixture_info.data, fixture_info.name)
|
||||
if fixture_info.protocol in {"SMARTCAMERA", "SMARTCAMERA.CHILD"}
|
||||
else FakeSmartCamProtocol(fixture_info.data, fixture_info.name)
|
||||
if fixture_info.protocol in {"SMARTCAM", "SMARTCAM.CHILD"}
|
||||
else FakeIotProtocol(fixture_info.data, fixture_info.name)
|
||||
for ip, fixture_info in fixture_infos.items()
|
||||
}
|
||||
@@ -221,8 +221,8 @@ def patch_discovery(fixture_infos: dict[str, FixtureInfo], mocker):
|
||||
protos[host] = (
|
||||
FakeSmartProtocol(fixture_info.data, fixture_info.name)
|
||||
if fixture_info.protocol in {"SMART", "SMART.CHILD"}
|
||||
else FakeSmartCameraProtocol(fixture_info.data, fixture_info.name)
|
||||
if fixture_info.protocol in {"SMARTCAMERA", "SMARTCAMERA.CHILD"}
|
||||
else FakeSmartCamProtocol(fixture_info.data, fixture_info.name)
|
||||
if fixture_info.protocol in {"SMARTCAM", "SMARTCAM.CHILD"}
|
||||
else FakeIotProtocol(fixture_info.data, fixture_info.name)
|
||||
)
|
||||
port = (
|
||||
|
@@ -5,16 +5,16 @@ from json import loads as json_loads
|
||||
from typing import Any
|
||||
|
||||
from kasa import Credentials, DeviceConfig, SmartProtocol
|
||||
from kasa.protocols.smartcameraprotocol import SmartCameraProtocol
|
||||
from kasa.protocols.smartcamprotocol import SmartCamProtocol
|
||||
from kasa.transports.basetransport import BaseTransport
|
||||
|
||||
from .fakeprotocol_smart import FakeSmartTransport
|
||||
|
||||
|
||||
class FakeSmartCameraProtocol(SmartCameraProtocol):
|
||||
class FakeSmartCamProtocol(SmartCamProtocol):
|
||||
def __init__(self, info, fixture_name, *, is_child=False, verbatim=False):
|
||||
super().__init__(
|
||||
transport=FakeSmartCameraTransport(
|
||||
transport=FakeSmartCamTransport(
|
||||
info, fixture_name, is_child=is_child, verbatim=verbatim
|
||||
),
|
||||
)
|
||||
@@ -25,7 +25,7 @@ class FakeSmartCameraProtocol(SmartCameraProtocol):
|
||||
return resp_dict
|
||||
|
||||
|
||||
class FakeSmartCameraTransport(BaseTransport):
|
||||
class FakeSmartCamTransport(BaseTransport):
|
||||
def __init__(
|
||||
self,
|
||||
info,
|
@@ -13,7 +13,7 @@ import pytest
|
||||
from kasa.device_type import DeviceType
|
||||
from kasa.iot import IotDevice
|
||||
from kasa.smart.smartdevice import SmartDevice
|
||||
from kasa.smartcamera.smartcamera import SmartCamera
|
||||
from kasa.smartcam import SmartCamDevice
|
||||
|
||||
|
||||
class FixtureInfo(NamedTuple):
|
||||
@@ -53,10 +53,10 @@ SUPPORTED_SMART_CHILD_DEVICES = [
|
||||
)
|
||||
]
|
||||
|
||||
SUPPORTED_SMARTCAMERA_DEVICES = [
|
||||
(device, "SMARTCAMERA")
|
||||
SUPPORTED_SMARTCAM_DEVICES = [
|
||||
(device, "SMARTCAM")
|
||||
for device in glob.glob(
|
||||
os.path.dirname(os.path.abspath(__file__)) + "/fixtures/smartcamera/*.json"
|
||||
os.path.dirname(os.path.abspath(__file__)) + "/fixtures/smartcam/*.json"
|
||||
)
|
||||
]
|
||||
|
||||
@@ -64,7 +64,7 @@ SUPPORTED_DEVICES = (
|
||||
SUPPORTED_IOT_DEVICES
|
||||
+ SUPPORTED_SMART_DEVICES
|
||||
+ SUPPORTED_SMART_CHILD_DEVICES
|
||||
+ SUPPORTED_SMARTCAMERA_DEVICES
|
||||
+ SUPPORTED_SMARTCAM_DEVICES
|
||||
)
|
||||
|
||||
|
||||
@@ -179,14 +179,14 @@ def filter_fixtures(
|
||||
IotDevice._get_device_type_from_sys_info(fixture_data.data)
|
||||
in device_type
|
||||
)
|
||||
elif fixture_data.protocol == "SMARTCAMERA":
|
||||
elif fixture_data.protocol == "SMARTCAM":
|
||||
info = fixture_data.data["getDeviceInfo"]["device_info"]["basic_info"]
|
||||
return SmartCamera._get_device_type_from_sysinfo(info) in device_type
|
||||
return SmartCamDevice._get_device_type_from_sysinfo(info) in device_type
|
||||
return False
|
||||
|
||||
filtered = []
|
||||
if protocol_filter is None:
|
||||
protocol_filter = {"IOT", "SMART", "SMARTCAMERA"}
|
||||
protocol_filter = {"IOT", "SMART", "SMARTCAM"}
|
||||
for fixture_data in fixture_list:
|
||||
if data_root_filter and data_root_filter not in fixture_data.data:
|
||||
continue
|
||||
|
@@ -5,21 +5,21 @@ from __future__ import annotations
|
||||
import pytest
|
||||
|
||||
from kasa import Device
|
||||
from kasa.smartcamera.modules.alarm import (
|
||||
from kasa.smartcam.modules.alarm import (
|
||||
DURATION_MAX,
|
||||
DURATION_MIN,
|
||||
VOLUME_MAX,
|
||||
VOLUME_MIN,
|
||||
)
|
||||
from kasa.smartcamera.smartcameramodule import SmartCameraModule
|
||||
from kasa.smartcam.smartcammodule import SmartCamModule
|
||||
|
||||
from ...conftest import hub_smartcamera
|
||||
from ...conftest import hub_smartcam
|
||||
|
||||
|
||||
@hub_smartcamera
|
||||
@hub_smartcam
|
||||
async def test_alarm(dev: Device):
|
||||
"""Test device alarm."""
|
||||
alarm = dev.modules.get(SmartCameraModule.SmartCameraAlarm)
|
||||
alarm = dev.modules.get(SmartCamModule.SmartCamAlarm)
|
||||
assert alarm
|
||||
|
||||
original_duration = alarm.alarm_duration
|
||||
@@ -70,10 +70,10 @@ async def test_alarm(dev: Device):
|
||||
await dev.update()
|
||||
|
||||
|
||||
@hub_smartcamera
|
||||
@hub_smartcam
|
||||
async def test_alarm_invalid_setters(dev: Device):
|
||||
"""Test device alarm invalid setter values."""
|
||||
alarm = dev.modules.get(SmartCameraModule.SmartCameraAlarm)
|
||||
alarm = dev.modules.get(SmartCamModule.SmartCamAlarm)
|
||||
assert alarm
|
||||
|
||||
# test set sound invalid
|
||||
@@ -92,10 +92,10 @@ async def test_alarm_invalid_setters(dev: Device):
|
||||
await alarm.set_alarm_duration(-3)
|
||||
|
||||
|
||||
@hub_smartcamera
|
||||
@hub_smartcam
|
||||
async def test_alarm_features(dev: Device):
|
||||
"""Test device alarm features."""
|
||||
alarm = dev.modules.get(SmartCameraModule.SmartCameraAlarm)
|
||||
alarm = dev.modules.get(SmartCamModule.SmartCamAlarm)
|
||||
assert alarm
|
||||
|
||||
original_duration = alarm.alarm_duration
|
||||
|
@@ -12,10 +12,10 @@ from freezegun.api import FrozenDateTimeFactory
|
||||
|
||||
from kasa import Credentials, Device, DeviceType, Module
|
||||
|
||||
from ..conftest import camera_smartcamera, device_smartcamera, hub_smartcamera
|
||||
from ..conftest import camera_smartcam, device_smartcam, hub_smartcam
|
||||
|
||||
|
||||
@device_smartcamera
|
||||
@device_smartcam
|
||||
async def test_state(dev: Device):
|
||||
if dev.device_type is DeviceType.Hub:
|
||||
pytest.skip("Hubs cannot be switched on and off")
|
||||
@@ -26,7 +26,7 @@ async def test_state(dev: Device):
|
||||
assert dev.is_on is not state
|
||||
|
||||
|
||||
@camera_smartcamera
|
||||
@camera_smartcam
|
||||
async def test_stream_rtsp_url(dev: Device):
|
||||
camera_module = dev.modules.get(Module.Camera)
|
||||
assert camera_module
|
||||
@@ -85,7 +85,7 @@ async def test_stream_rtsp_url(dev: Device):
|
||||
assert url is None
|
||||
|
||||
|
||||
@device_smartcamera
|
||||
@device_smartcam
|
||||
async def test_alias(dev):
|
||||
test_alias = "TEST1234"
|
||||
original = dev.alias
|
||||
@@ -100,7 +100,7 @@ async def test_alias(dev):
|
||||
assert dev.alias == original
|
||||
|
||||
|
||||
@hub_smartcamera
|
||||
@hub_smartcam
|
||||
async def test_hub(dev):
|
||||
assert dev.children
|
||||
for child in dev.children:
|
||||
@@ -112,7 +112,7 @@ async def test_hub(dev):
|
||||
assert child.time
|
||||
|
||||
|
||||
@device_smartcamera
|
||||
@device_smartcam
|
||||
async def test_device_time(dev: Device, freezer: FrozenDateTimeFactory):
|
||||
"""Test a child device gets the time from it's parent module."""
|
||||
fallback_time = datetime.now(UTC).astimezone().replace(microsecond=0)
|
||||
|
@@ -45,7 +45,7 @@ from kasa.cli.wifi import wifi
|
||||
from kasa.discover import Discover, DiscoveryResult
|
||||
from kasa.iot import IotDevice
|
||||
from kasa.smart import SmartDevice
|
||||
from kasa.smartcamera import SmartCamera
|
||||
from kasa.smartcam import SmartCamDevice
|
||||
|
||||
from .conftest import (
|
||||
device_smart,
|
||||
@@ -181,7 +181,7 @@ async def test_state(dev, turn_on, runner):
|
||||
|
||||
@turn_on
|
||||
async def test_toggle(dev, turn_on, runner):
|
||||
if isinstance(dev, SmartCamera) and dev.device_type == DeviceType.Hub:
|
||||
if isinstance(dev, SmartCamDevice) and dev.device_type == DeviceType.Hub:
|
||||
pytest.skip(reason="Hub cannot toggle state")
|
||||
|
||||
await handle_turn_on(dev, turn_on)
|
||||
@@ -214,7 +214,7 @@ async def test_raw_command(dev, mocker, runner):
|
||||
update = mocker.patch.object(dev, "update")
|
||||
from kasa.smart import SmartDevice
|
||||
|
||||
if isinstance(dev, SmartCamera):
|
||||
if isinstance(dev, SmartCamDevice):
|
||||
params = ["na", "getDeviceInfo"]
|
||||
elif isinstance(dev, SmartDevice):
|
||||
params = ["na", "get_device_info"]
|
||||
@@ -917,7 +917,7 @@ async def test_type_param(device_type, mocker, runner):
|
||||
|
||||
mocker.patch("kasa.cli.device.state", new=_state)
|
||||
if device_type == "camera":
|
||||
expected_type = SmartCamera
|
||||
expected_type = SmartCamDevice
|
||||
elif device_type == "smart":
|
||||
expected_type = SmartDevice
|
||||
else:
|
||||
|
@@ -30,7 +30,7 @@ from kasa.iot.iottimezone import (
|
||||
)
|
||||
from kasa.iot.modules import IotLightPreset
|
||||
from kasa.smart import SmartChildDevice, SmartDevice
|
||||
from kasa.smartcamera import SmartCamera
|
||||
from kasa.smartcam import SmartCamDevice
|
||||
|
||||
|
||||
def _get_subclasses(of_class):
|
||||
@@ -115,7 +115,7 @@ async def test_device_class_repr(device_class_name_obj):
|
||||
IotLightStrip: DeviceType.LightStrip,
|
||||
SmartChildDevice: DeviceType.Unknown,
|
||||
SmartDevice: DeviceType.Unknown,
|
||||
SmartCamera: DeviceType.Camera,
|
||||
SmartCamDevice: DeviceType.Camera,
|
||||
}
|
||||
type_ = CLASS_TO_DEFAULT_TYPE[klass]
|
||||
child_repr = "<DeviceType.Unknown(child) of <DeviceType.Unknown at 127.0.0.2 - update() needed>>"
|
||||
|
@@ -20,7 +20,7 @@ from kasa import (
|
||||
from kasa.device_factory import (
|
||||
Device,
|
||||
IotDevice,
|
||||
SmartCamera,
|
||||
SmartCamDevice,
|
||||
SmartDevice,
|
||||
connect,
|
||||
get_device_class_from_family,
|
||||
@@ -178,8 +178,8 @@ async def test_connect_http_client(discovery_mock, mocker):
|
||||
|
||||
async def test_device_types(dev: Device):
|
||||
await dev.update()
|
||||
if isinstance(dev, SmartCamera):
|
||||
res = SmartCamera._get_device_type_from_sysinfo(dev.sys_info)
|
||||
if isinstance(dev, SmartCamDevice):
|
||||
res = SmartCamDevice._get_device_type_from_sysinfo(dev.sys_info)
|
||||
elif isinstance(dev, SmartDevice):
|
||||
assert dev._discovery_info
|
||||
device_type = cast(str, dev._discovery_info["device_type"])
|
||||
|
@@ -6,7 +6,7 @@ from devtools.dump_devinfo import get_legacy_fixture, get_smart_fixtures
|
||||
from kasa.iot import IotDevice
|
||||
from kasa.protocols import IotProtocol
|
||||
from kasa.smart import SmartDevice
|
||||
from kasa.smartcamera import SmartCamera
|
||||
from kasa.smartcam import SmartCamDevice
|
||||
|
||||
from .conftest import (
|
||||
FixtureInfo,
|
||||
@@ -17,8 +17,8 @@ from .conftest import (
|
||||
smart_fixtures = parametrize(
|
||||
"smart fixtures", protocol_filter={"SMART"}, fixture_name="fixture_info"
|
||||
)
|
||||
smartcamera_fixtures = parametrize(
|
||||
"smartcamera fixtures", protocol_filter={"SMARTCAMERA"}, fixture_name="fixture_info"
|
||||
smartcam_fixtures = parametrize(
|
||||
"smartcam fixtures", protocol_filter={"SMARTCAM"}, fixture_name="fixture_info"
|
||||
)
|
||||
iot_fixtures = parametrize(
|
||||
"iot fixtures", protocol_filter={"IOT"}, fixture_name="fixture_info"
|
||||
@@ -27,8 +27,8 @@ iot_fixtures = parametrize(
|
||||
|
||||
async def test_fixture_names(fixture_info: FixtureInfo):
|
||||
"""Test that device info gets the right fixture names."""
|
||||
if fixture_info.protocol in {"SMARTCAMERA"}:
|
||||
device_info = SmartCamera._get_device_info(
|
||||
if fixture_info.protocol in {"SMARTCAM"}:
|
||||
device_info = SmartCamDevice._get_device_info(
|
||||
fixture_info.data, fixture_info.data.get("discovery_result")
|
||||
)
|
||||
elif fixture_info.protocol in {"SMART"}:
|
||||
@@ -62,11 +62,11 @@ async def test_smart_fixtures(fixture_info: FixtureInfo):
|
||||
assert fixture_info.data == fixture_result.data
|
||||
|
||||
|
||||
@smartcamera_fixtures
|
||||
async def test_smartcamera_fixtures(fixture_info: FixtureInfo):
|
||||
"""Test that smartcamera fixtures are created the same."""
|
||||
@smartcam_fixtures
|
||||
async def test_smartcam_fixtures(fixture_info: FixtureInfo):
|
||||
"""Test that smartcam fixtures are created the same."""
|
||||
dev = await get_device_for_fixture(fixture_info, verbatim=True)
|
||||
assert isinstance(dev, SmartCamera)
|
||||
assert isinstance(dev, SmartCamDevice)
|
||||
if dev.children:
|
||||
pytest.skip("Test not currently implemented for devices with children.")
|
||||
fixtures = await get_smart_fixtures(
|
||||
|
Reference in New Issue
Block a user