FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Use the real discovery reply in the TD21 fixture by Smugaski · Pull Request #1800 · python-kasa/python-kasa · GitHub

Repository navigation

Use the real discovery reply in the TD21 fixture - #1800

Merged
rytilahti merged 2 commits into
python-kasa:masterfrom
Smugaski:td21-real-discovery
Oct 14, 2026
Merged

rytilahti merged 2 commits into
python-kasa:masterfrom
Smugaski:td21-real-discovery

Conversation

Copy link
Copy Markdown
Contributor

Use the real discovery reply in the TD21 fixture

Follow-up to #1786. I said there that the TD21 doesn't answer UDP discovery, and that was wrong: it was asleep during my first attempt, and I had skipped discovery in dump_devinfo by passing the family flags. The doorbell does answer, from port 20004.

Changes

  • tests/fixtures/smartcam/TD21(EU)_2.0_1.1.5.json: replaces the hand-written discovery_result with the real, redacted reply (from dump_devinfo --host ...). The _comment marker is removed since nothing in the fixture is hand-made any more. The device state is re-recorded at the same time, so the rest of the fixture changes slightly (battery, clock, Wi-Fi scan).
  • tests/discovery_fixtures.py: the discovery mock now mirrors the fallback from Discovery: accept cameras that only send the encrypt_type list #1770.

Why a test helper change

The real reply has no encrypt_info and no encryption type in mgt_encrypt_schm, only the top-level encrypt_type: ["3"]. Discover._get_connection_parameters already handles that shape (#1770), but the mock derived the encryption type without the fallback and got None, which failed seven TD21 tests (test_discover_single, test_discover_try_connect_all, test_list_devices, test_list_update_failed). This is the first fixture with that reply shape. The helper change is four lines and does nothing for other fixtures.

Testing

  • All tests parametrized on the TD21 pass (108 passed, 2 skipped).
  • test_discovery.py, test_device_factory.py and test_devtools.py pass across all fixtures (3970 passed).
  • ruff, ruff format and mypy are clean on the changed files.

Mirror the fallback in Discover._get_connection_parameters (python-kasa#1770): when a discovery reply has no encryption type in mgt_encrypt_schm and no encrypt_info, but supports https and sends encrypt_type ["3"], treat it as AES. Needed so fixtures with such a reply can be used by the discovery mock.
The TD21 answers UDP discovery on port 20004, so replace the hand-written discovery_result with the redacted device response and drop the _comment marker.

codecov Bot commented Oct 13, 2026 •
edited
Loading

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.43%. Comparing base (f1a8d38) to head (9356be1).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1800   +/-   ##
=======================================
  Coverage   93.43%   93.43%           
=======================================
  Files         159      159           
  Lines       10116    10116           
  Branches     1044     1044           
=======================================
  Hits         9452     9452           
  Misses        471      471           
  Partials      193      193           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

rytilahti left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thank you @Smugaski!

rytilahti merged commit d6e80d2 into python-kasa:master Oct 14, 2026
22 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL