Rename and deprecate exception classes (#739)

# Public #
SmartDeviceException -> KasaException
UnsupportedDeviceException(SmartDeviceException) -> UnsupportedDeviceError(KasaException)
TimeoutException(SmartDeviceException, asyncio.TimeoutError) -> TimeoutError(KasaException, asyncio.TimeoutError)

Add new exception for error codes -> DeviceError(KasaException)
AuthenticationException(SmartDeviceException) -> AuthenticationError(DeviceError)

# Internal #
RetryableException(SmartDeviceException) -> _RetryableError(DeviceError)
ConnectionException(SmartDeviceException) -> _ConnectionError(KasaException)
This commit is contained in:
Steven B
2024-02-21 15:52:55 +00:00
committed by GitHub
parent 4beff228c9
commit 8c39e81a40
44 changed files with 393 additions and 361 deletions

View File

@@ -2,7 +2,7 @@ from datetime import datetime
import pytest
from kasa import SmartDeviceException
from kasa import KasaException
from kasa.iot import IotStrip
from .conftest import handle_turn_on, strip, turn_on
@@ -73,7 +73,7 @@ async def test_get_plug_by_name(dev: IotStrip):
name = dev.children[0].alias
assert dev.get_plug_by_name(name) == dev.children[0] # type: ignore[arg-type]
with pytest.raises(SmartDeviceException):
with pytest.raises(KasaException):
dev.get_plug_by_name("NONEXISTING NAME")
@@ -81,10 +81,10 @@ async def test_get_plug_by_name(dev: IotStrip):
async def test_get_plug_by_index(dev: IotStrip):
assert dev.get_plug_by_index(0) == dev.children[0]
with pytest.raises(SmartDeviceException):
with pytest.raises(KasaException):
dev.get_plug_by_index(-1)
with pytest.raises(SmartDeviceException):
with pytest.raises(KasaException):
dev.get_plug_by_index(len(dev.children))