mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-10-14 19:38:02 +00:00
extract shared types (exceptions, enums), add module level doc, rename exception to be generic
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from ..protocol import TPLinkSmartHomeProtocol
|
||||
from .. import SmartPlugException
|
||||
from .. import SmartDeviceException
|
||||
import logging
|
||||
|
||||
|
||||
@@ -250,7 +250,7 @@ class FakeTransportProtocol(TPLinkSmartHomeProtocol):
|
||||
|
||||
def query(self, host, request, port=9999):
|
||||
if self.invalid:
|
||||
raise SmartPlugException("Invalid connection, can't query!")
|
||||
raise SmartDeviceException("Invalid connection, can't query!")
|
||||
|
||||
proto = self.proto
|
||||
|
||||
|
@@ -2,7 +2,7 @@ from unittest import TestCase, skip, skipIf
|
||||
from voluptuous import Schema, Invalid, All, Range
|
||||
from functools import partial
|
||||
|
||||
from .. import SmartBulb, SmartPlugException
|
||||
from .. import SmartBulb, SmartDeviceException
|
||||
from .fakes import FakeTransportProtocol, sysinfo_lb130
|
||||
|
||||
BULB_IP = '192.168.250.186'
|
||||
@@ -93,11 +93,11 @@ class TestSmartBulb(TestCase):
|
||||
bulb = SmartBulb('127.0.0.1',
|
||||
protocol=FakeTransportProtocol(sysinfo_lb130,
|
||||
invalid=True))
|
||||
with self.assertRaises(SmartPlugException):
|
||||
with self.assertRaises(SmartDeviceException):
|
||||
bulb.sys_info['model']
|
||||
|
||||
def test_query_helper(self):
|
||||
with self.assertRaises(SmartPlugException):
|
||||
with self.assertRaises(SmartDeviceException):
|
||||
self.bulb._query_helper("test", "testcmd", {})
|
||||
# TODO check for unwrapping?
|
||||
|
||||
|
@@ -4,7 +4,7 @@ from functools import partial
|
||||
import datetime
|
||||
import re
|
||||
|
||||
from .. import SmartPlug, SmartPlugException
|
||||
from .. import SmartPlug, SmartDeviceException
|
||||
from .fakes import FakeTransportProtocol, sysinfo_hs110, sysinfo_hs105
|
||||
|
||||
PLUG_IP = '192.168.250.186'
|
||||
@@ -87,11 +87,11 @@ class TestSmartPlug(TestCase):
|
||||
plug = SmartPlug('127.0.0.1',
|
||||
protocol=FakeTransportProtocol(sysinfo_hs110,
|
||||
invalid=True))
|
||||
with self.assertRaises(SmartPlugException):
|
||||
with self.assertRaises(SmartDeviceException):
|
||||
plug.sys_info['model']
|
||||
|
||||
def test_query_helper(self):
|
||||
with self.assertRaises(SmartPlugException):
|
||||
with self.assertRaises(SmartDeviceException):
|
||||
self.plug._query_helper("test", "testcmd", {})
|
||||
# TODO check for unwrapping?
|
||||
|
||||
|
Reference in New Issue
Block a user