Skip to content

test: pin mdns_timeout seconds-to-milliseconds conversion#101

Merged
bdraco merged 1 commit into
aio-libs:mainfrom
aiolibsbot:koan/mdns-timeout-ms-conversion-test
May 21, 2026
Merged

test: pin mdns_timeout seconds-to-milliseconds conversion#101
bdraco merged 1 commit into
aio-libs:mainfrom
aiolibsbot:koan/mdns-timeout-ms-conversion-test

Conversation

@aiolibsbot
Copy link
Copy Markdown
Contributor

@aiolibsbot aiolibsbot commented May 21, 2026

What

Add regression tests that assert the timeout value AsyncMDNSResolver forwards to zeroconf's async_request.

Why

The public mdns_timeout argument is documented in seconds, but zeroconf's async_request expects milliseconds, so _resolve_mdns multiplies by 1000. Every existing test stubs async_request with return_value=True regardless of its arguments, so the conversion itself was never asserted. Dropping the * 1000 would silently turn a 5-second timeout into 5 milliseconds — breaking real on-network mDNS resolution — while the entire suite stayed green.

How

  • New self-contained file tests/test_mdns_timeout_conversion.py (kept separate to avoid conflicting with the in-flight test_impl.py PRs).
  • Patches load_from_cache to force the network path, captures async_request.call_args, and asserts the forwarded timeout is mdns_timeout * 1000 (2.5s → 2500.0; default 5.0s → 5000.0).
  • Also asserts the query is issued through the resolver's own zeroconf instance.

Testing

ruff check and ruff format --check pass. pytest cannot run in this environment (no zeroconf/aiohttp installed); correctness is validated by the CI matrix.


Quality Report

Changes: 2 files changed, 106 insertions(+)

Code scan: clean

Tests: failed (FAILED)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

The mdns_timeout constructor argument is documented in seconds, but
zeroconf's async_request expects milliseconds, so the resolver multiplies
by 1000 before issuing the network query. No existing test asserted the
value handed to async_request (they stub it regardless of arguments), so
dropping the * 1000 would silently turn a 5s timeout into 5ms with the
whole suite still green. These tests capture and assert the forwarded
timeout to lock that conversion.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (5a01499) to head (e7ec65e).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #101   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         7    +1     
  Lines          521       564   +43     
  Branches        23        24    +1     
=========================================
+ Hits           521       564   +43     

☔ View full report in Codecov by Sentry.
📢 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.

@bdraco bdraco marked this pull request as ready for review May 21, 2026 18:52
@bdraco bdraco merged commit 8ffa6b9 into aio-libs:main May 21, 2026
26 checks passed
@aiolibsbot aiolibsbot deleted the koan/mdns-timeout-ms-conversion-test branch May 21, 2026 19:07
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