Commit Graph

85 Commits

Author SHA1 Message Date
Steven B.
8bb2cca7cf Remove async magic patch from tests ()
Not required since AsyncMock available in python 3.8 and probably better
to keep magic to a minimum.
2024-10-02 17:12:10 +02:00
Steven B.
b4aba36b73 Use pytest-socket to ensure no tests are performing io () 2024-09-27 17:20:25 +01:00
Steven B.
db686e191a Add autouse fixture to patch asyncio.sleep () 2024-09-27 10:57:23 +01:00
Teemu R.
6a86ffbbba Add flake8-pytest-style (PT) for ruff ()
This will catch common issues with pytest code.

* Use `match` when using `pytest.raises()` for base exception types like
`TypeError` or `ValueError`
* Use tuples for `parametrize()`
* Enforces `pytest.raises()` to contain simple statements, using `noqa`
to skip this on some cases for now.
* Fixes incorrect exception type (valueerror instead of typeerror) for
iotdimmer.
* Adds check valid types for `iotbulb.set_hsv` and `color` smart module.
* Consolidate exception messages for common interface modules.
2024-08-30 17:30:07 +02:00
Steven B
1ba5c73279 Fix potential infinite loop if incomplete lists returned ()
Fixes the test framework to handle fixtures with incomplete lists better by checking for completeness and overriding the sum. Also adds a pytest-timeout dev dependency with timeout set to 10 seconds. Finally fixes smartprotocol to prevent an infinite loop if incomplete lists ever happens in the real world.

Co-authored-by: Teemu R. <tpr@iki.fi>
2024-05-19 10:34:52 +01:00
Steven B
203bd79253 Enable and convert to future annotations () 2024-04-17 15:39:24 +02:00
Steven B
7507837734 Fix slow aestransport and cli tests () 2024-03-11 10:17:12 +00:00
Teemu R
3495bd83df Add T315 fixture, tests for humidity&temperature modules () 2024-03-06 18:04:09 +00:00
Steven B
97680bdcee Refactor test framework ()
This is in preparation for tests based on supporting features amongst
other tweaks:

- Consolidates the filtering logic that was split across `filter_model`
and `filter_fixture`
- Allows filtering `dev` fixture by `component`
- Consolidates fixtures missing method warnings into one warning
- Does not raise exceptions from `FakeSmartTransport` for missing
methods (required for KS240)
2024-02-27 18:39:04 +01:00
Teemu R
a73e2a9ede Add H100 fixtures ()
One direct out of the box, another with upgraded fw & t315
2024-02-24 00:12:19 +01:00
Teemu R
c61f2e931c Add --child option to feature command ()
This allows listing and changing child device features that were previously not accessible using the cli tool.
2024-02-23 23:32:17 +01:00
Teemu R
bc65f96f85 Add initial support for H100 and T315 ()
Adds initial support for H100 and its alarmmodule.

Also implements the following modules for T315:
* reportmodule (reporting interval)
* battery
* humidity
* temperature
2024-02-22 23:09:38 +01:00
Teemu R
d9d2f1a430 Remove SmartPlug in favor of SmartDevice ()
With the move towards autodetecting available features, there is no reason to keep SmartPlug around.

kasa.smart.SmartPlug is removed in favor of kasa.smart.SmartDevice which offers the same functionality.
Information about auto_off can be accessed using Features of the AutoOffModule on supported devices.

Co-authored-by: Steven B. <51370195+sdb9696@users.noreply.github.com>
2024-02-22 14:34:55 +01:00
Steven B
215b8d4e4f Fix discovery cli to print devices not printed during discovery timeout ()
* Fix discovery cli to print devices not printed during discovery

* Fix tests

* Fix print exceptions not being propagated

* Fix tests

* Reduce test discover_send time

* Simplify wait logic

* Add tests

* Remove sleep loop and make auth failed a list
2024-02-05 17:53:09 +00:00
Steven B
0d119e63d0 Refactor devices into subpackages and deprecate old names ()
* Refactor devices into subpackages and deprecate old names

* Tweak and add tests

* Fix linting

* Remove duplicate implementations affecting project coverage

* Update post review

* Add device base class attributes and rename subclasses

* Rename Module to BaseModule

* Remove has_emeter_history

* Fix missing _time in init

* Update post review

* Fix test_readmeexamples

* Fix erroneously duped files

* Clean up iot and smart imports

* Update post latest review

* Tweak Device docstring
2024-02-04 16:20:08 +01:00
J. Nick Koston
1f62aee7b6 Add TP25 fixtures ()
* Add TP25 fixtures

* redump fixture
2024-02-01 19:52:57 +01:00
J. Nick Koston
8657959ace Add TP15 fixture () 2024-01-31 18:30:19 +01:00
Teemu R
55525fc58b Unignore F401 for tests ()
* Unignore F401 for tests

* Fix linting
2024-01-30 00:15:58 +01:00
Teemu R
9e6896a08f Various test code cleanups ()
* Separate fake protocols for iot and smart

* Move control_child impl into its own method

* Organize schemas into correct places

* Add test_childdevice

* Add missing return for _handle_control_child
2024-01-29 20:26:39 +01:00
Teemu R
f8e273981c Add P300 fixture ()
* Add P300 fixture

* fixture after update

* Add tests for p300
2024-01-29 18:14:30 +01:00
Steven B
0d0f56414c Switch from TPLinkSmartHomeProtocol to IotProtocol/XorTransport ()
* Switch from TPLinkSmartHomeProtocol to IotProtocol/XorTransport

* Add test

* Update docs

* Fix ruff deleting deprecated import
2024-01-26 09:11:31 +00:00
J. Nick Koston
716b1f82d9 Add support for the S500 ()
* Add support for the S500D

* tweak

* Add S505
2024-01-25 09:07:01 +01:00
J. Nick Koston
cba073ebde Add support for tapo wall switches (S500D) ()
* Add support for the S500D

* tweak

* Update README.md
2024-01-25 08:54:56 +01:00
J. Nick Koston
8947ffbc94 Add L930-5 fixture ()
* Add L930-5 fixture

* Mark L930-5 as variable temp

* Update readme

* Fix overly greedy _strip_rich_formatting

---------

Co-authored-by: Teemu Rytilahti <tpr@iki.fi>
2024-01-24 22:31:01 +00:00
J. Nick Koston
5907dc763a Add fixtures for L510E ()
* Add fixtures for L510E

* mac
2024-01-24 06:59:39 +00:00
Steven B
1788c50146 Update transport close/reset behaviour ()
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-01-23 12:15:18 -10:00
J. Nick Koston
d5fdf05ed2 Add P100 test fixture () 2024-01-23 10:12:24 +00:00
J. Nick Koston
abd3ee0768 Add P135 fixture ()
* Add P135 fixture

This device is a dimmer but we currently treat it as a on/off

* add to conftest
2024-01-23 08:31:19 +01:00
Steven B
e94cd118a4 Add fixtures with new MAC mask () 2024-01-20 13:22:54 +01:00
J. Nick Koston
eadf1203fc Add fixture for L920 () 2024-01-14 23:49:31 +01:00
Steven B
897db674c2 Add L900-10 fixture and it's additional component requests () 2024-01-10 19:40:36 +01:00
J. Nick Koston
efd67b9261 Add P125M and update EP25 fixtures ()
* Add P125M and update EP25 fixtures

* fix: adjust tests
2024-01-05 00:01:34 +01:00
Teemu R
17d96064c2 Mark L900-5 as supported ()
* Add fixture for L900-5

* Update readme
2024-01-04 19:52:11 +01:00
sdb9696
e9bf9f58ee Allow serializing and passing of credentials_hashes in DeviceConfig ()
* Allow passing of credentials_hashes in DeviceConfig

* Update following review
2024-01-03 22:46:08 +01:00
gimpy88
c810298b04 Add support for KS205 and KS225 wall switches ()
* KS205 Fixture

* KS225 Fixture

* Added Smart.KasaSwitch device type

* Added KS225 to test

* Added variable color temp check

* Added supported devices to readme

* Removed parenthesis

* Updated fixtures

* Fixed for ruff
2024-01-03 19:31:42 +01:00
sdb9696
f6fd898faf Add DeviceConfig to allow specifying configuration parameters ()
* Add DeviceConfig handling

* Update post review

* Further update post latest review

* Update following latest review

* Update docstrings and docs
2023-12-29 20:17:15 +01:00
sdb9696
6819c746d7 Enable multiple requests in smartprotocol ()
* Enable multiple requests in smartprotocol

* Update following review

* Remove error_code parameter in exceptions
2023-12-20 18:08:04 +01:00
sdb9696
209391c422 Improve CLI Discovery output ()
- Show discovery results for unsupported devices and devices that fail to authenticate.
- Rename `--show-unsupported` to `--verbose`.
- Remove separate `--timeout` parameter from cli discovery so it's not confused with `--timeout` now added to cli command.
- Add tests.
2023-12-19 13:50:33 +01:00
sdb9696
16ba87378d Add EP25 smart fixture and improve test framework for SMART devices () 2023-12-08 14:55:14 +01:00
Steven Bytnar
be289a5751 Add KP125M fixture and allow passing credentials for tests ()
* Add KP125M fixture. Enable tapo auth in pytest.

* authentication is not just for tapo

* Use "##MASKEDNAME##" base64 for nickname and ssid.

---------

Co-authored-by: Teemu R. <tpr@iki.fi>
2023-12-08 00:04:50 +01:00
Teemu R
f9b5003da2 Add support for tapo bulbs ()
* Add support for tapo light bulbs

* Use TapoDevice for on/off

* Add tapobulbs to discovery

* Add partial support for effects

Activating the effect does not work as I thought it would,
but this implements rest of the interface from SmartLightStrip.

* Add missing __init__ for tapo package

* Make mypy happy

* Add docstrings to make ruff happy

* Implement state_information and has_emeter

* Import tapoplug from kasa.tapo package

* Add tapo L530 fixture

* Enable tests for L530 fixture

* Make ruff happy

* Update fixture filename

* Raise exceptions on invalid parameters

* Return results in a wrapped dict

* Implement set_*

* Reorganize bulbs to iot&smart, fix tests for smarts

* Fix linting

* Fix BULBS_LIGHT_STRIP back to LIGHT_STRIPS
2023-12-05 20:07:10 +01:00
sdb9696
4a00199506 Add klap support for TAPO protocol by splitting out Transports and Protocols ()
* Add support for TAPO/SMART KLAP and seperate transports from protocols

* Add tests and some review changes

* Update following review

* Updates following review
2023-12-04 19:50:05 +01:00
J. Nick Koston
0ec0826cc7 Make timeout adjustable () 2023-10-07 20:58:00 +02:00
J. Nick Koston
677ef9c3ef Add tests for KP200 ()
* Add tests for KP200

This one worked out of the box sans the OUI not being in the list

https://github.com/home-assistant/core/pull/97062

* it is a strip
2023-07-22 23:55:42 +02:00
xinud190
b83986bd51 Add fixture for KP405 Smart Dimmer Plug ()
* Add files via upload

* Add to KP405 to dimmers, update README

---------

Co-authored-by: Teemu Rytilahti <tpr@iki.fi>
2023-06-30 02:53:23 +02:00
Julian Davis
866c8d6db5 Fix pytest warnings about asyncio ()
Turn on ayncio auto mode for pytest and remove the global async marking flag
2022-11-13 23:34:47 +01:00
gritstub
57fac9a156 Add fixtures for KS200M () 2022-06-28 18:53:23 +02:00
gritstub
d7295bdf6d Add fixtures for ES20M () ()
Co-authored-by: Teemu R <tpr@iki.fi>
2022-06-28 13:06:34 +02:00
gritstub
4c55289255 Add fixtures for KS230 () 2022-06-28 12:56:36 +02:00
James Alseth
91ba1d5ac6 Add KP125 test fixture and support note. ()
* Add KP125 test fixture and support note.

Signed-off-by: James Alseth <james@jalseth.me>

* mark KP125 having an emeter

Co-authored-by: Teemu R <tpr@iki.fi>
2022-06-27 03:39:57 +02:00