Skip to content

fix: keep test doubles out of the shipped package; cover ftps and netsafety edge paths - #157

Merged
DLANSAMA merged 3 commits into
mainfrom
claude/project-thread-6iww3w
Nov 7, 2026
Merged

DLANSAMA merged 3 commits into
mainfrom
claude/project-thread-6iww3w

Conversation

@DLANSAMA

@DLANSAMA DLANSAMA commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

What and why

Plan box B-6 (v1.0.0 ship checklist). Two commits, both from the checklist audit.

1. Test doubles out of the shipped package, stale numbers refreshed

  • logging_utils.patched_logger imported unittest.mock inside bambu_cli. It had one caller, a test, so it moves there. set_logger / reset_logger stay.
  • argutils.namespace_get and netsafety._host_of keep their behaviour (never raise on odd input). Their docstrings now describe the real inputs instead of citing a MagicMock.
  • The CI grep now rejects import / from of unittest, pytest and mock in bambu_cli/. It matches the old tree and is clean on this one.
  • New tests/test_production_purity.py checks the same on the AST (imports, Mock class names, sys.modules probes), so the rule is a test and not only a sentence.

2. ftps.py and netsafety.py reach 100% branch coverage

Both were under the roadmap's own per-module bar (88.9% and 93.2%; A is 90 and 95). New tests/test_transport_edges.py (13 tests, no sockets) covers:

  • ImplicitFTPS.connect default-argument handling, and cleanup when the socket or file will not close (the handshake error still reaches the caller).
  • The unprotected data channel, a failed data-channel wrap, and a pin mismatch whose socket will not close.
  • The redirect handler: a response that will not close does not mask the hop-limit error; a cross-host redirect drops credentials.
  • The HTTPS handler's optional context and hostname check.
  • The per-host throttle table's size cap, both the stale-entry sweep and the full clear.

Docs

Roadmap, test backlog and README cite the re-measured numbers: 2239 tests, 93.8% over 9436 statements (local Linux, 2026-11-07). The roadmap's "coverage 91.0→92 remains" line is replaced with what actually remains.

Checklist

  • uvx ruff check bambu_cli
  • uvx ruff format --check bambu_cli
  • uvx mypy -p bambu_cli
  • uvx bandit -c pyproject.toml -r bambu_cli -ll
  • uv run python -m pytest tests/ -q -m "not live": 2239 passed, 1 skipped, 1 live deselected, with -W error::ResourceWarning
  • uv run python tests/python_compat_smoke.py

Also run: layers, schemas, syntax, ci_workflow, privacy and release_readiness smokes, and the docs-consistency tests. The full CI matrix (Linux 3.10/3.12/3.14, Windows, macOS) was green on the first commit; it re-runs for the second.

Public API note: bambu_cli.logging_utils.patched_logger is removed (listed in the changelog).

…uality numbers

patched_logger imported unittest.mock inside bambu_cli; it moves into the one test
that used it. namespace_get and _host_of keep their defensive behaviour with
docstrings that describe the real inputs. The CI grep now rejects unittest, pytest
and mock imports in bambu_cli/, and tests/test_production_purity.py checks the same
on the AST. Roadmap, backlog and README coverage and test counts re-measured.
@DLANSAMA DLANSAMA self-assigned this Nov 7, 2026
@DLANSAMA
DLANSAMA marked this pull request as ready for review November 7, 2026 16:25
Default-argument handling in ImplicitFTPS.connect, cleanup when a socket or file
will not close, the unprotected data channel, the redirect handler's header rules,
the HTTPS handler's optional context and the throttle table's size cap. Both
modules reach 100% branch coverage. Roadmap, backlog and README numbers
re-measured: 2239 tests, 93.8%.
@DLANSAMA DLANSAMA changed the title fix: keep test doubles out of the shipped package, refresh stale quality numbers fix: keep test doubles out of the shipped package; cover ftps and netsafety edge paths Nov 7, 2026
@DLANSAMA
DLANSAMA merged commit f1d12c1 into main Nov 7, 2026
7 checks passed
@DLANSAMA
DLANSAMA deleted the claude/project-thread-6iww3w branch November 7, 2026 18:09
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.

1 participant